what does [BITS 32] do in nasm?
Posted: Fri Feb 08, 2013 6:22 am
Hi
I'm new to os development, and now some small questions confused me.
According to the book I am reading, when you are writing codes in protected mode using NASM, you should add [BITS 32] in place, just as follows:
I'm really confused with that [BITS 32], because I dont know what intheworld NASM does when I add it. I compiled the asm file and then disassembled it using ndisasm, founding the right codes generated as follows:
Exactly same with what I write in asm file, but once I changed the [BITS 32] to [BITS 16], I found the disassembled codes is whole different:
Why?
I'm new to os development, and now some small questions confused me.
According to the book I am reading, when you are writing codes in protected mode using NASM, you should add [BITS 32] in place, just as follows:
Code: Select all
[SECTION .s32]
ALIGN 32
[BITS 32]
LABEL_PM_START:
mov ax, SelectorVideo ;GDT Selector pointed to the video descriptor
mov gs, ax
mov ah, 0Fh
mov al, 'P'
mov [gs:((80 * 0 +39) * 2)], ax ;display 'P'
jmp $
Code: Select all
00090320 66B81B00 mov ax,0x1b
00090324 8EE8 mov gs,ax
00090326 B40F mov ah,0xf
00090328 B050 mov al,0x50
0009032A 6566A34E000000 mov [gs:0x4e],ax
00090331 EBFE jmp short 0x90331
Code: Select all
00090320 66B81B008EE8 mov eax,0xe88e001b
00090326 B40F mov ah,0xf
00090328 B050 mov al,0x50
0009032A 6566A34E00 mov [gs:0x4e],eax
0009032F 0000 add [bx+si],al
00090331 EBFE jmp short 0x331