2019-03-13 21:11:19 +01:00
|
|
|
; assumptions about the starting envionment
|
2019-03-10 20:23:09 +01:00
|
|
|
cpu 8086
|
2019-03-13 21:11:19 +01:00
|
|
|
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
|
2019-03-10 20:23:09 +01:00
|
|
|
|
2019-03-13 22:11:30 +01:00
|
|
|
_startup:
|
2019-03-13 21:11:19 +01:00
|
|
|
; during PXE, CS=0000 and IP=7C00
|
|
|
|
; adjust CS so our offsets match org setting above
|
2019-03-13 22:11:30 +01:00
|
|
|
mov ax, _exit
|
|
|
|
push ax ; store exit addr on stack so main will return to it
|
|
|
|
push bx ; backup bx
|
|
|
|
call near .push_ip
|
|
|
|
.push_ip:
|
2019-03-13 21:11:19 +01:00
|
|
|
pop bx
|
2019-03-13 22:11:30 +01:00
|
|
|
sub bx, .push_ip ; subtract expected value ...
|
2019-03-13 21:11:19 +01:00
|
|
|
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
|
2019-03-13 22:11:30 +01:00
|
|
|
pop bx ; restore bx
|
2019-03-13 21:11:19 +01:00
|
|
|
push ax ; cs
|
|
|
|
mov ax, main
|
|
|
|
push ax ; ip
|
2019-03-13 22:11:30 +01:00
|
|
|
sti
|
2019-03-13 21:11:19 +01:00
|
|
|
retf ; jump
|
2019-03-10 20:23:09 +01:00
|
|
|
|
2019-03-13 22:11:30 +01:00
|
|
|
_exit:
|
|
|
|
mov si, .message
|
|
|
|
call kprintf
|
|
|
|
int 0x20
|
|
|
|
.loop:
|
|
|
|
hlt
|
|
|
|
jmp .loop
|
|
|
|
.message:
|
2019-03-13 21:11:19 +01:00
|
|
|
db "Halted: Waiting for poweroff...", 0
|
2019-03-13 18:28:38 +01:00
|
|
|
|
2019-03-10 20:23:09 +01:00
|
|
|
main:
|
2019-03-14 17:17:02 +01:00
|
|
|
mov ax, cs
|
|
|
|
mov ds, ax
|
2019-03-13 22:11:49 +01:00
|
|
|
|
2019-03-14 17:17:02 +01:00
|
|
|
mov bx, 0x002E
|
|
|
|
mov dx, debug_reg_ir
|
2019-03-13 22:11:49 +01:00
|
|
|
|
2019-03-14 17:17:02 +01:00
|
|
|
call ivt_set
|
2019-03-13 22:11:49 +01:00
|
|
|
|
2019-03-18 14:27:00 +01:00
|
|
|
mov ax, 0
|
|
|
|
mov bx, 0
|
|
|
|
call cons
|
|
|
|
mov si, di
|
|
|
|
call print
|
2019-03-13 22:11:49 +01:00
|
|
|
|
|
|
|
ret
|
2019-03-10 20:23:09 +01:00
|
|
|
|
2019-03-14 17:17:02 +01:00
|
|
|
%include "intr.asm"
|
|
|
|
%include "debug.asm"
|
2019-03-10 20:23:09 +01:00
|
|
|
%include "kprintf.asm"
|
2019-03-16 11:46:01 +01:00
|
|
|
%include "heap.asm"
|
|
|
|
|
2019-03-18 14:27:00 +01:00
|
|
|
%include "cons.asm"
|
|
|
|
%include "int.asm"
|
|
|
|
%include "print.asm"
|
|
|
|
|
2019-03-16 11:46:01 +01:00
|
|
|
heap:
|
|
|
|
dw 0
|