flat assembler
Message board for the users of flat assembler.

Index > Main > I don't understand ...

Author
Thread Post new topic Reply to topic
Ilmars



Joined: 29 Nov 2005
Posts: 3
Ilmars 29 Nov 2005, 13:33
I'm beginner in FASM. And I have some strange problem.
Here is a code:

Code:
org 100h

       mov al,36h
       mov bl,35h

       mov ah,9h
       mov dx,text1
       int 21h
       mov ah,2h
       mov dl,al  ;?? 36h
       int 21h
       mov ah,9h

       cmp al,bl

       jbe first_below_or_equal
       mov dx,above
       jmp continue

first_below_or_equal:
       je  both_are_equal
       jmp first_is_below

first_is_below:
       mov dx,below
       jmp continue

both_are_equal:
       mov dx,equal

continue:
       int 21h
       mov ah,2h
       mov dl,bl
       int 21h
       mov ah,9h
       mov dx,text
       int 21h
       int 20h

text1  db "first number $"
bigger db " > $"
equal  db " = $"
below  db " < $"
text2  db " second number $"                     
    


I don't understand why it isn't working well.
If I change al with 36h (near 2 question marks) , then it's working nice.

Thank you already now. (:


Last edited by Ilmars on 29 Nov 2005, 14:13; edited 1 time in total
Post 29 Nov 2005, 13:33
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 29 Nov 2005, 13:55
Post 29 Nov 2005, 13:55
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Ilmars



Joined: 29 Nov 2005
Posts: 3
Ilmars 29 Nov 2005, 14:09
To vid:
I don't need a string output, i need symbol's, whose ASCII code is stored in al, output.

In first case (mov dl,al) output is
first number $ < 5 second number.
But it must be, (as in case of mov dl,36h)
first number 6 > 5 second number.

It's that I don't understand.
Post 29 Nov 2005, 14:09
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 29 Nov 2005, 14:29
If you would read link i sent you precisely, you will find out: int 21h/9: Return: AL = 24h (the '$' terminating the string, despite official docs which state that nothing is returned)
Code:
mov ah,9h 
mov dx,text1 
int 21h  ;this returns with al='$'
    
Post 29 Nov 2005, 14:29
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 29 Nov 2005, 14:55
What he's telling you is that your al gets deleted from returning from int 21h so you are declaring al too soon. Here's code for example:
Code:
org 100h

;      mov al,36h ;This is too soon - it gets lost
       mov bl,35h

       mov ah,9h
       mov dx,text1
       int 21h
;      mov ah,2h
       mov ax,0236h ;You can define both (ah,al) here
       mov dl,al  ;al is 36h here and so will dl
       int 21h
       mov ah,9h

       cmp al,bl

       jbe first_below_or_equal
       mov dx,above
       jmp continue

first_below_or_equal:
       je  both_are_equal
       jmp first_is_below

first_is_below:
       mov dx,below
       jmp continue

both_are_equal:
       mov dx,equal

continue:
       int 21h
       mov ah,2h
       mov dl,bl
       int 21h
       mov ah,9h
       mov dx,text
       int 21h
       int 20h

text1  db "first number $"
bigger db " > $"
equal  db " = $"
below  db " < $"
text2  db " second number $"
    

Try that Wink
Post 29 Nov 2005, 14:55
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Ilmars



Joined: 29 Nov 2005
Posts: 3
Ilmars 30 Nov 2005, 09:41
Very big thank for you both (Madis731 and vid) !! Smile

Now it's OK.
Post 30 Nov 2005, 09:41
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.