Page 1 of 1

[BITS 16] in real mode

Posted: Mon Jun 23, 2025 9:06 pm
by karim
Do I have to write [BITS 16] at the beginning of the assembly code because in real mode all the registers in the CPU are only 16-bit, and also so that NASM compiles the code as 16-bit only? Is that correct?

Re: [BITS 16] in real mode

Posted: Mon Jun 23, 2025 9:25 pm
by Octocontrabass
No. You have to use "bits 16" because instructions are encoded differently in 16-bit mode, 32-bit mode, and 64-bit mode. The same registers are available in 16-bit mode and in 32-bit mode.