David Chouinard
David Chouinard

Reputation: 6836

Truncating 2 byte variable to 1 byte

This seems like a a trivial question, but I'm lost.

In this example character is a 2 byte variable, while the register bx is a single byte. I'm trying to do cmp bx, [character], which clearly won't work because of the difference in size.

I'm trying to compare bx to only the first byte of character. Thoughts?

Upvotes: 2

Views: 492

Answers (1)

GJ.
GJ.

Reputation: 10937

bx rebister is 16 bit size and is composed from two 8 bit bl and bh!

For 16 bit cmp you can use prefix:

cmp bx, word ptr[character]

for 8 bit bl cmp

 cmp bl, byte ptr[character]

or 8 bit bh cmp

 cmp bh, byte ptr[character + 1]

Upvotes: 4

Related Questions