Add proper _exit procedure
This commit is contained in:
parent
bb675a67a7
commit
4d827ec4e9
23
main.asm
23
main.asm
@ -6,26 +6,37 @@ org 0x0000 ; if we are not at CS:0000, CS adjustment will fix it for us
|
|||||||
; es:bx probable pxeenv+ structure
|
; es:bx probable pxeenv+ structure
|
||||||
; ss:sp functional stack
|
; ss:sp functional stack
|
||||||
|
|
||||||
|
_startup:
|
||||||
; during PXE, CS=0000 and IP=7C00
|
; during PXE, CS=0000 and IP=7C00
|
||||||
; adjust CS so our offsets match org setting above
|
; adjust CS so our offsets match org setting above
|
||||||
push bx ; offset register for calculations
|
mov ax, _exit
|
||||||
call near __startup_push_ip ; push ip
|
push ax ; store exit addr on stack so main will return to it
|
||||||
__startup_push_ip:
|
push bx ; backup bx
|
||||||
|
call near .push_ip
|
||||||
|
.push_ip:
|
||||||
pop bx
|
pop bx
|
||||||
sub bx, __startup_push_ip ; subtract expected value ...
|
sub bx, .push_ip ; subtract expected value ...
|
||||||
shr bx,1 ; shift it to 4 bits to the right
|
shr bx,1 ; shift it to 4 bits to the right
|
||||||
shr bx,1
|
shr bx,1
|
||||||
shr bx,1
|
shr bx,1
|
||||||
shr bx,1
|
shr bx,1
|
||||||
mov ax,cs
|
mov ax,cs
|
||||||
add ax,bx ; so we can add it to cs
|
add ax,bx ; so we can add it to cs
|
||||||
pop bx
|
pop bx ; restore bx
|
||||||
push ax ; cs
|
push ax ; cs
|
||||||
mov ax, main
|
mov ax, main
|
||||||
push ax ; ip
|
push ax ; ip
|
||||||
|
sti
|
||||||
retf ; jump
|
retf ; jump
|
||||||
|
|
||||||
string_halt:
|
_exit:
|
||||||
|
mov si, .message
|
||||||
|
call kprintf
|
||||||
|
int 0x20
|
||||||
|
.loop:
|
||||||
|
hlt
|
||||||
|
jmp .loop
|
||||||
|
.message:
|
||||||
db "Halted: Waiting for poweroff...", 0
|
db "Halted: Waiting for poweroff...", 0
|
||||||
|
|
||||||
main:
|
main:
|
||||||
|
Loading…
Reference in New Issue
Block a user