From 31d05c35e5272307f5fbd66c6f3e1df333e7d1b5 Mon Sep 17 00:00:00 2001 From: Elaina Claus Date: Fri, 5 Sep 2025 16:18:34 -0400 Subject: [PATCH] move __TINY_DS_ES to unreal_mode function also some cleanup --- src/stage2/stage2.nasm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/stage2/stage2.nasm b/src/stage2/stage2.nasm index 42974b1..1af2838 100755 --- a/src/stage2/stage2.nasm +++ b/src/stage2/stage2.nasm @@ -162,12 +162,6 @@ main: ; enter unreal mode (16 bit code, 32 bit flat memory model) call EnterUnrealMode - - ; set ds, es to the STAGE2_SEGMENT, for our model (generally) ds == es == cs - ; fs, gs & ss are all still huge data model, and the macro "__REFLAT_DS_ES" exists - ; to easily access data outside of 64KiB boundries using ds/es addressing - __TINY_DS_ES - print_string UnrealMode_OK_info ; FAT Driver setup @@ -207,7 +201,6 @@ EnterUnrealMode: mov eax, cr0 or eax, 1 ; set pmode bit mov cr0, eax ; switch to pmode - ;jmp short $+2 ; i-cache flush ; set cs to a pm code segment (0x8) w/ the following jmp 0x0008:EnterUnrealMode.set_segs @@ -219,7 +212,6 @@ EnterUnrealMode: mov ds, ax ; 10h = 0001_0000b mov es, ax ; es to big data - mov ss, ax ; big stack mov fs, ax mov gs, ax ; extra segments to big data as well .pm_start: @@ -230,9 +222,14 @@ EnterUnrealMode: and eax, ~1 ; toggle bit 1 of cr0 mov cr0, eax ; back to realmode jmp 0x0000:EnterUnrealMode.endp - ;jmp short $+2 ; i-cache flush .endp: sti ; re-enable interupts + + ; set ds, es to the STAGE2_SEGMENT, for our model (generally) ds == es == cs + ; fs, gs & ss are all still huge data model, and the macro "__REFLAT_DS_ES" exists + ; to easily access data outside of 64KiB boundries using ds/es addressing + __TINY_DS_ES + __CDECL16_EXIT ret end_text: