flat assembler
Message board for the users of flat assembler.

 Index > Main > An algorithm to find the biggest number among set of numbers
Author
 Thread
extra_12345

Joined: 21 Apr 2020
Posts: 9
extra_12345
Heya!i was thinking of an algorithm to find the biggest number among set of numbers then return it but couldn't figure it out, any help will be appreciated.
30 Jul 2020, 15:42
Roman

Joined: 21 Apr 2012
Posts: 815
Roman
big numbers its 128 bits or 256 bits ?
900 trillion ?
30 Jul 2020, 16:03
extra_12345

Joined: 21 Apr 2020
Posts: 9
extra_12345
Roman wrote:
big numbers its 128 bits or 256 bits ?
900 trillion ?

Dwords,let's say I have 20 dword type numbers:
34
85
69
23
12
78
26
45
25
69
82
36
25
17
35
86
26
54
89
20

I want an algorithm that returns the biggest number amongst them,how can I accomplish this?
30 Jul 2020, 18:26
Roman

Joined: 21 Apr 2012
Posts: 815
Roman
89 is big. In ax register.

Code:
BigDig dw 34,85,69,23,12,78,26,45,25,69,82,36
dw 25,17,35,86,26,54,89,20

start:
mov ebx,BigDig
mov cx,20
xor ax,ax
.22:
cmp ax,word [ebx]
jae .33
mov ax,word [ebx]
.33:
add ebx,2
dec cx
jnz .22

Last edited by Roman on 30 Jul 2020, 19:29; edited 2 times in total
30 Jul 2020, 19:07
Roman

Joined: 21 Apr 2012
Posts: 815
Roman
Or this:
Code:
mov ebx,BigDig
mov cx,20
xor ax,ax
.22:
cmp ax,word [ebx]
cmovnae ax,word [ebx]
add ebx,2
dec cx
jnz .22

30 Jul 2020, 19:26
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum

Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.