Hi everyone!!!
I've decided to rewrite the whole code so, that it becomes cleaner and more scalable, also try using paging. Well, I ran into a problem.
USE16
ORG 0h
;NOT ASSEMBLED!!!
PRE_ASM_VAR:
SSBL_Size equ 80h ;should be like in MBR
SSBL_Stack equ 20h ;same
Primary_CS equ 8h
SDAq equ 0
KERN_LOAD_Seg equ 0
END_PRE_ASM_VARS:
;ASSEMBLED!!!
jmp START
DATASECT:
DAP: ;DATA;REL
DAP_Size db 10h ;0h ;1h
DAP_Res1 db 0 ;1h ;2h
DAP_Bytes2Transfer db 1h ;2h ;3h
DAP_Res2 db 0 ;3h ;4h
DAP_Buff_Addr1 dw 0h ;4h ;6h
DAP_Buff_Addr2 dw 8000h ;6h ;8h
DAP_LBA dq 1h ;8h ;9h
DAT_Disk_Num db 80h ;10h ;12h number of device 80h-winchester
DAT_Num_Of_Sects dw 04h ;11h ;13h the number of 512byte sectors, that contain your kernel your kernel + 1
END_DAP:
GDT:
dw GDT_ENDS + GDT_STARTS - 1h ;size of GDT
dd 0h ;value to be inserted during execution
GDT_STARTS:
REC0:
dq 0h
REC1:
dw 0FFFFh ;Limit_0_15
dw 00000h ;Base_0_15
db 00h ;Base_16_23
db 10011010b ;||Present bit||Priviligies||1||Code-1, Data - 0||if want to execute from low levels - 1, else 0|| can write here? yes=1||0||
db 11001111b ;||Granularity||1||0||0||Limit 16-19||
db 00h ;Base_24_31
REC2:
dw 0FFFFh ;Limit_0_15
dw 00000h ;Base_0_15
db 00h ;Base_16_23
db 10010010b ;||Present bit||Priviligies||1||Code-1, Data - 0||if want to execute from low levels - 1, else 0|| can write here? yes=1||0||
db 11001111b ;||Granularity||1||0||0||Limit 16-19||
db 00h ;Base_24_31
GDT_ENDS:
END_DATEASECT:
START:
SETREG_SSBL:
xor eax, eax ;clean eax
mov ax, cs ;ax = cs
mov ds, ax ;ds = cs
mov ss, ax ;ss = cs
mov sp, (SSBL_Stack + SSBL_Size)*10h;stack points 256 bytes above end of SSBL
shl eax, 4h ;get raw address of start of segment
add eax, GDT_STARTS ;adding ofset of start of GDT
mov dword [ds:GDT+2], eax ;GDT offset ready
mov bp, DATASECT ;base pointer = datasect
;well... thats all
PMJMP:
cli ;disable interrupts
lea eax, [ds:GDT]
lgdt [eax]
mov ax, 2401h
int 15h
xor eax, eax
mov ax, cs
shl eax, 4h
add eax, PMODE
mov ebx, cr0
or ebx, 1
mov cr0, ebx
jmp Primary_CS:eax ;!!! HERE ERROR!!!
USE32
PMODE:
FIN:
times 2047d - FIN db 0h
db 'F'
I need to make a jump into protected mode code through address calculated in eax, but compiller doesnt lets me do it! Code is loaded right before EBDA and I dont know address where it is executed before compilation. How do I make that jump???