I am using this to write to the video memory (%es = 0xb800):
movw $0x074b,%es:(0x0)
However, what if I want the offset to be in %ax?
I tried %es:%ax
, or %es:(%ax)
, but nothing worked, and I kept getting errors.
What am I doing wrong?
In 16 bit mode you are limited in usable address forms. You can't address using %ax
. The valid forms are:
bx
or bp
, plussi
or di
, plusAs such, movw $0x074b, %es:(%di)
would work, for example. See also Table 2-1. 16-Bit Addressing Forms with the ModR/M Byte in the official Intel® 64 and IA-32 Architectures Software Developer's Manual Volume 2: Instruction Set Reference, A-Z
PS: next time show what errors you got.