Code: Select all
; vim: ft=nasm noet ts=4 sw=4 sts=0
[bits 32]
[global bit16_init]
[global bit16_int]
; copy the 16bit codes into 0000:7c00h
;;;; this works correctly.
bit16_init:
mov edi, 7c00h
mov esi, do16_int
mov ecx, do16_int_len
repnz movsb
ret
bit16_int:
cli
jmp 18h:7c00h ; 3 * 8h = 4th descriptor in gdt = code 16-bit
ret
[bits 16]
do16_int:
mov eax, cr0
xor al, 1
mov cr0, eax
jmp dword 0:.real - do16_int + 7c00h ;; no `org' directive can be used in elf
.real:
mov ax, cs
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 7c00h - 1
; disable A20
in al, 92h
xor al, 10b
out 92h, al
sti
mov ax, 0b800h
mov gs, ax
mov al, 'A'
mov ah, 01110000b
mov [gs:0], ax
;;;; things work fine till here
; read key, just for testing the bios call
xor ah, ah
int 16h
;;;; both qemu and bochs crashed before reaching here
mov [gs:0], ax
jmp $
do16_int_len equ $-do16_int
I wonder if there is anything more to do with leaving pmode. I need you guys' help.
Thanks in advance. I apologize for my bad English.