assembly - invalid instruction suffix for `mov' (movw %ax, %ebx) -
when try compile following program:
.globl _start .section .text _start: movw $-23, %ax movl $-1, %ebx # -1 = $0xffffffff movw %ax, %ebx movl $1, %eax movl $0, %ebx int $0x80
i error message:
demo.s: assembler messages: demo.s:7: error: invalid instruction suffix `mov'
so, root of proglem lies here:
movw %ax, %ebx
but thing don't think i'm doing totally wrong plus that's example used in book i'm reading: professional assembly language richard blum (2005)
you didn't write, want program.
first put -23
ax
, -1
ebx
, try move ax
ebx
, not valid on x86 processor, ax
16bit, , ebx
32bit register. mov
can't convert width of data during processing.
to make work there 2 basic options.
if want lower 16b of
ebx
modified (by 16bax
), canmov %ax, %bx
, keeping upper 16b ofebx
intact. (in case result-23
inebx/bx/bl
).if want extend 16b value 32b value, can either:
movswl %ax, %ebx # sign-extended conversion (movsx in intel syntax)
movzwl %ax, %ebx # zero-extended conversion (movzx in intel syntax)
in 1. ebx
(and bx
, bl
well) contain -23
. in 2. ebx
contain 0x0000ffe9, ebx
65513
, bx
, bl
-23
if treated signed integer. or 65513
bx
, 233
in bl
when treated unsigned integers.
about book... sure? read again, must typo, or overlooking tiny detail.
Comments
Post a Comment