1

I'm trying to write a simple code in assembly and I'm having troubles when comparing two values using cmp. I want to jump to a certain point if my value is not between 65 and 90.

 cmp $65, (%ebx)
 jl looping
 cmp $90, (%ebx)
 jg check_minusculas

Running gdb I have that %ebx value is 0x80490f9 and using:

x /1db 0x80490f9

I get that (%ebx) is 77. However, the program jumps to check_minusculas when obviously 77<90.
What am I missing here?

Thanks!

1 Answer 1

2

Your problem is that you forgot to use a size specifier and it defaults to long while you apparently want to use byte. Solution: use cmpb.

2
  • This worked, thanks! But what is happening "behind the scenes"? If it's a byte and defaults to long, doesn't it fill the other bytes as a 0?
    – tykey100
    Apr 29, 2017 at 21:45
  • 2
    No, it fetches the following 3 bytes as well from memory, whatever they may be.
    – Jester
    Apr 29, 2017 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.