.text .globl _start .code16 _start: cld xorw %ax, %ax movw %ax, %ds movw %ax, %es movw %ax, %ss movw $_start, %sp xorw %dx, %dx movw $0xe3, %ax int $0x14 movw $0x2401, %ax int $0x15 movw $msg, %si callw puts lgdt gdt_desc movl %cr0, %eax orl $0x1, %eax movl %eax, %cr0 pushl $0x8 pushl $_start32 lretl puts: lodsb testb %al, %al jnz puts.1 retw puts.1: movb $0x1, %ah xorw %dx, %dx int $0x14 jmp puts .code32 _start32: cli movl $0x10, %eax movl %eax, %ds movl %eax, %es movl %eax, %ss movl $__bss_start, %esi movl $_end, %ecx subl $__bss_start, %ecx shrl $2, %ecx xorl %eax, %eax rep stosl call main _start32.1: jmp _start32.1 .data gdt: .word 0x0, 0x0, 0x0, 0x0 .word 0xffff, 0x0, 0x9a00, 0xcf # code .word 0xffff, 0x0, 0x9200, 0xcf # data gdt_desc: .word . - gdt - 1 .long gdt msg: .asciz "hello from real mode...\r\n" .comm pdpt, 32, 32 .comm ptd, 4 * 4096, 4096 .comm ptp, 4096, 4096