Pergunta

Can I access 16-bit registers (AX, CX etc...) in protected mode at Windows x86? Will be this code valid? mov ax,123 Thanks.

Foi útil?

Solução

There is a 32 bit and 16 bit mode.

  • In 32 bit mode you can access 16 bit registers by using a special prefix byte.

  • In 16 bit mode, the opposite is the case, i.e. the prefix makes instructions 32 bit.

So in each mode you can use all registers, but the code is not binary compatible. Even though protected mode often uses 32 bit mode, these are two different things.

So in your assembler you have to use the proper directive for 32 or 16 bit code (even though 16 and 32 bit registers can be accessed in both modes). The assembler then will output the appropriate prefix instruction without any interaction from the user.

So if you know that the protected mode is also in 32 bit mode, include the 32 bit directive in your assembler code and then you can use also 16 bit registers and it will work as expected.

If you omit the 32 bit directive your code will assemble but execution will not be what you intended!.

Outras dicas

Yes, it's totally fine (you can also access AH and AL).

Yes, you can use the eax,ax,ah,al in protected mode. Also you can use all of them in real mode even eax

But not rax (If your system supports it)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top