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.

Sign up to request clarification or add additional context in comments.

2 Comments

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?
No, it fetches the following 3 bytes as well from memory, whatever they may be.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.