flat assembler
Message board for the users of flat assembler.

Index > Main > Comparing signed integers

Author
Thread Post new topic Reply to topic
denial



Joined: 12 Sep 2004
Posts: 98
denial 03 Feb 2005, 22:55
I think cmp has some problems with handling signed (negative) integers. What am I doing wrong? The following code is for DOS:

Code:
org 100h

mov ecx,-3
neg ecx
mov edx,5
cmp ecx,edx
ja @f
mov ah,2
mov dl,1
int 21h
@@:
int 20h    


If ecx is smaller than edx (-3 smaller than 5), the ASCII-Code 1 (a smiley Smile ) will be drawn. This works, because actually it GETS drawn Wink

But now, the with the following code, the smiley won't get drawn! I just changed -3 into -8.

Code:
org 100h

mov ecx,-8
neg ecx
mov edx,5
cmp ecx,edx
ja @f
mov ah,2
mov dl,1
int 21h
@@:
int 20h
    


So I think cmp cannot handle signed integers at all. Maybe the first code worked because even without the sign, 3 is still smaller than 5. But when the sign of -8 is taken away, 8 will be greater than 5.

So how to handle signed integervalues with cmp? Sad
Thank you...
Post 03 Feb 2005, 22:55
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 03 Feb 2005, 23:35
use jump if less, and greater Smile
jL
jG
Post 03 Feb 2005, 23:35
View user's profile Send private message Visit poster's website Reply with quote
denial



Joined: 12 Sep 2004
Posts: 98
denial 03 Feb 2005, 23:41
oh... Embarassed
That was easy... ok... thank you. Rolling Eyes
Post 03 Feb 2005, 23:41
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 04 Feb 2005, 01:17
you're welcome
Post 04 Feb 2005, 01:17
View user's profile Send private message Visit poster's website 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.