From what I understand reading the Intel manuals, it should be possible to write an instruction like add $0x7f, %ebx and it should be encoded as 83 /0 ib for a total of three bytes.
However, when I do this (whether I use add, addb, or addl) it always “promotes” the immediate value to a 32-bit value and encodes as 81 /0 id and takes up six bytes. The same problem exists with adc, sub, etc. Note that I am using AT&T syntax with GNU as.
I have been looking for a solution for over a day and haven’t found it. Can anyone please advise?
Surprisingly, I don’t have such a problem.
I took this assembly code produced by
gcc(DJGPP):And compiled it with
asand this is what I’m seeing in a.out:And the C program was:
Are you sure your immediate operand can be represented as an 8-bit signed integer? If it’s outside the -128 to +127 range, the assembler will have to use a longer encoding.