Adjust CS at startup and HLT-loop after main
This commit is contained in:
parent
56f01a0888
commit
6ce37b4e28
38
main.asm
38
main.asm
@ -1,16 +1,42 @@
|
||||
; assumptions about the starting envionment
|
||||
cpu 8086
|
||||
org 0x0000 ; if we are not at CS:0000, CS adjustment will fix it for us
|
||||
; dl probable drive number
|
||||
; ds:si probable pointer to partition structure
|
||||
; es:bx probable pxeenv+ structure
|
||||
; ss:sp functional stack
|
||||
|
||||
org 0x0100
|
||||
jmp main
|
||||
; during PXE, CS=0000 and IP=7C00
|
||||
; adjust CS so our offsets match org setting above
|
||||
push bx ; offset register for calculations
|
||||
call near __startup_push_ip ; push ip
|
||||
__startup_push_ip:
|
||||
pop bx
|
||||
sub bx, __startup_push_ip ; subtract expected value ...
|
||||
shr bx,1 ; shift it to 4 bits to the right
|
||||
shr bx,1
|
||||
shr bx,1
|
||||
shr bx,1
|
||||
mov ax,cs
|
||||
add ax,bx ; so we can add it to cs
|
||||
pop bx
|
||||
push ax ; cs
|
||||
mov ax, main
|
||||
push ax ; ip
|
||||
retf ; jump
|
||||
|
||||
str1:
|
||||
db "Hello!", 0
|
||||
string_halt:
|
||||
db "Halted: Waiting for poweroff...", 0
|
||||
|
||||
main:
|
||||
call dumpreg
|
||||
mov ax,cs
|
||||
mov ds,ax
|
||||
mov si,str1
|
||||
mov si, string_halt
|
||||
call kprintf
|
||||
ret
|
||||
.loop:
|
||||
hlt
|
||||
jmp .loop
|
||||
|
||||
%include "dumpreg.asm"
|
||||
%include "kprintf.asm"
|
||||
|
Loading…
Reference in New Issue
Block a user