Make relocation code not trash potentially important registers

This commit is contained in:
Nero 2019-03-23 20:54:08 +00:00
parent 5becc89872
commit d54f8ac4b9
2 changed files with 17 additions and 12 deletions

View File

@ -12,7 +12,11 @@ main:
mov ax, 18 mov ax, 18
call malloc call malloc
ret int 0x2E
.endloop:
hlt
jmp .endloop
%include "kernel/heap.asm" %include "kernel/heap.asm"
%include "kernel/intr.asm" %include "kernel/intr.asm"

23
nbp.asm
View File

@ -7,8 +7,12 @@ org 0x0000
; during PXE, CS=0000 and IP=7C00 ; during PXE, CS=0000 and IP=7C00
_startup: _startup:
xor ax, ax xor ax, ax
mov ss, ax
mov sp, 0x0000 push cx ; byte counter
push si ; source offset
push di ; destination offset
push es ; destination segment
mov ds, ax mov ds, ax
mov es, ax mov es, ax
@ -16,16 +20,13 @@ _startup:
mov di, 0x0500 mov di, 0x0500
mov cx, (_reloc_end) mov cx, (_reloc_end)
rep movsb rep movsb
jmp 0x0050:main
_exit: pop es
mov si, .message pop di
call kprintf pop si
.loop: pop cx
hlt
jmp .loop jmp 0x0050:main
.message:
db "Halted: Waiting for poweroff...", 0
%include "kernel/main.asm" %include "kernel/main.asm"