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 Post new topic Reply to topic
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.
Post 30 Jul 2020, 15:42
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 815
Roman
big numbers its 128 bits or 256 bits ?
900 trillion ?
Post 30 Jul 2020, 16:03
View user's profile Send private message Reply with quote
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?
Post 30 Jul 2020, 18:26
View user's profile Send private message Reply with quote
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
Post 30 Jul 2020, 19:07
View user's profile Send private message Reply with quote
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 
    
Post 30 Jul 2020, 19:26
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


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

Website powered by rwasa.