assembly - NASM add byte to register ebx -
is there simple way make nasm snippet work?
add ebx, byte [ebp-10+ecx]
i following error: error: mismatch in operand sizes
. want add byte in memory address [ebp-10+ecx]
least significant byte of ebx. of course ebx 4 or 8 byte register , causes error.
you can load byte 32 bit register using zero-extend move instruction, , use add ebx:
movzx eax,byte ptr [ebp-10+ecx] add ebx,eax
or, if want perform 8-bit addition , don't care rest of bits of ebx, add byte lowest part of ebx. aware won't carry bit 7 bit 8 in ebx)
add bl,byte ptr [ebp-10+ecx]
you can add signed byte 32 bit number using movsx
instruction instead of movzx
. movsx
stands "move sign extend".
Comments
Post a Comment