Assembler throws error for my 16 bit code movzbw (%ax), %ax Error: `(%ax)' is not a valid base/index expression
But the below instruction is valid on 32 bit code generation. movzbl (%eax), %eax
Environment: Processor: Intel(x86) Assembler: "GNU AS" Operating System: "Linux" Purpose: While writing a very simple bootloader which prints "Hello, World" to the screen, I am trying to pass a string to a function and then traverse byte by byte and then print it.
What is the equivalent instruction that I can use to avoid error in writing 16 bit real mode code?
More information: Below is the C code that I am trying to simulate in "16 bit GNU AS" assembler
void _prints(char*);
int main(void)
{
char* mess = "hello";
_prints(mess);
return 0;
}
void _prints(char* str)
{
while(*str)
{
++str;
}
}
Note:While trying to generate the assembly file using command "gcc -S test.c", I see that in _prints function the instruction "movzbl (%eax), %eax". I want to simulate a 16-bit real mode code using the same assembler, but it throws error while using "movzbw (%ax), %ax"
Please help