still not working.
I did
.486
.686p
I am using the more elaborate old way of declaring the segments. I am wondering if that is the cause:
.486
.686p
include macros.inc
sta segment para stack use16 'stack'
db 100h dup(0)
sta ends
data segment para public 'data'
str0 db 'test string in asmfile.asm$'
str1 db 'str1$'
acpiPtr db 'RSD PTR$'
bdaPtr db 0f8h, 03h, '$'
; dw gdt_end - gdt - 1 ;last byte in table
; dd gdt ;start of table
gdtPtrSize db 0,0
gdtPtrAddr db 0,0,0,0
; 0:15 - limit 0:15
; 15:31 - base 0:15
; 0:7 - base 16:23
; 8:15 - access byte
; 16:19 - limit 16:19
; 20:23 - flags
; 24:31 - base 24:31
; entry0 - not used
; entry1 - dw ffff - limit 0:15
; db 0 -
; base 0:31 = 00000000h
; limit 0:19 = ffffffh
; access byte = 10010010b?
; flags = 1100b?
; gdt start
; entry 0 (always unused)
gdt dd 0,0 ; entry 0 is always unused
; entry 1
flatdesc dw 0ffffh ; limit 0:15
db 0, 0 ; base 0:15
db 0 ; base 16:23
db 10010010b ; access byte
; 1 - present (yes)
; 00 - privilige 00
; 1?
; 0 - data selector
; 0 - can only executed from ring set in priv level.
; 1 - readable code segment
; 0 - accessed bit. cpu sets this bit when accessed.
db 11001111b ; limit 16:19 flag
; 1 - granularity bit - 1 limit is in 4KiB blocks
; 1 - Sz - 32-bit protected mode
; 00 - ??
db 0 ; base 24:31
gdtEnd dw 0
data ends
code segment para public use16 'code'
assume cs:code, ds:data,ss:sta
M_EXTERNDEF
main proc far
mov ax, DATA
mov ds, ax
...
switchPmode:
; must run from DOS not WINDOWS!!!
;
; create PTR TO GDT
; create GDT and fill up.
; load GDT
; disable all INT-s
; switch to pmode
; fetch data
; enable all INT-s back
; display fetched data.
; Check if already in protected mode
mov eax, cr0
test al, 01h
jz pmodeTestDone
M_PRINTF "\nSystem is already in protected mode"
jmp exit
pmodeTestDone:
M_PRINTF "\nSwitching to protecte mode"
; disable interrupts
cli
; DS=0
sub ax, ax
mov ds, ax
lgdt [gdtPtr]
mov eax, cr0
or al, 01h
mov cr0, eax
jmp $+2
; DS = set segment descriptor entry 1 in GDT
mov bx, 08h
mov ds, bx
; grab memory from ext.memory
; ...
; exit protected mode
mov eax, cr0
and eax, 0fffffffeh
mov cr0, eax
; enable back interrupts
sti
exit:
mov ax, 4c00h
int 21h
main endp
; input
; DS:BP - pointer to string ($) terminated.
code ends
end main