Using EAX in 16-Bit ASM
Using EAX in 16-Bit ASM
I've made a 16-Bit DOS style OS but in one section of code, I needed to store my data into a 32-Bit value, so I put it in EAX! Will this conflict or anything? The code works but i'm not sure what to expect later on...
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Using EAX in 16-Bit ASM
I don't think so. You just need to take care to tell the processor that 32 bit values are to be expected/handled. Maybe you gonna need some prefixes (don't know them by heart. The Faq might contain some hints about that)
*shrugs* Others mileage might be different.
*shrugs* Others mileage might be different.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
Re:Using EAX in 16-Bit ASM
If using the AT&T syntax, specify the command with the "l" suffix, e.g. movl $1, %eax. The assembler will insert an "opsize" command before the opcode (0x67, i think) and this will tell the machine to use the 32-bit register (as long as it is not a 286 or older!)
The "l" suffix isn't strictly needed, but it helps and can make it easier to spot certain errors (e.g. movl $1, %ax).
One last thing - remember that if you use the eax register, you will trash any value stored in ax.
The "l" suffix isn't strictly needed, but it helps and can make it easier to spot certain errors (e.g. movl $1, %ax).
One last thing - remember that if you use the eax register, you will trash any value stored in ax.
Re:Using EAX in 16-Bit ASM
The prefixes, in Intel/NASM Syntax, are o32, a32, o16 and a16. The "o" prefixes are for the operation, "a" is address size.
http://nasm.sourceforge.net/doc/html/nasmdoc9.html#section-9.3
NASM will automatically prefix the instructions for you though, dec eax and dec ax have the same opcode so NASM will prefix it to achieve the desired effect
http://nasm.sourceforge.net/doc/html/nasmdoc9.html#section-9.3
NASM will automatically prefix the instructions for you though, dec eax and dec ax have the same opcode so NASM will prefix it to achieve the desired effect
Re:Using EAX in 16-Bit ASM
since the processor knows all its regs (in 16bit and 32bit modes) using EAX will not make any conflit, the only problem you can get, can happens with old CPUs
Re:Using EAX in 16-Bit ASM
why not use a 32-bit variable?
Re:Using EAX in 16-Bit ASM
Yeah I know that I can easily use a variable, but I was just asking about the use of EAX, etc.