Updated kernel and programs so that the segment in which programs are loaded and executed from is no longer fixed and is specified by the kernel

This commit is contained in:
Xnoe 2021-08-31 12:15:23 +01:00
parent 514f07e009
commit d9cc9a2fb6
Signed by: xnoe
GPG Key ID: 45AC398F44F0DAFE
3 changed files with 35 additions and 12 deletions

View File

@ -1,10 +1,14 @@
mov ax, 3000h
push bp
mov bp, sp
mov ax, [bp + 6]
mov ds, ax
mov si, hello_world_str
mov ah, 01h
int 22h
pop bp
retf
hello_world_str db "Hello, World!", 13, 10, 13, 10, 0
@ -12,3 +16,5 @@ new_line db 13, 10, 0
buffer:
times 32 db 0
program_segment dw 0

View File

@ -92,15 +92,22 @@ clear_loop:
cmp ax, 0
je handle_error
; If the file exists load it at 3000h:0
; Define the segment where we will load our programs
program_segment equ 4000h
; If the file exists load it at program_segment:0
push ax
push 0
push 3000h
push program_segment
call load_file
; Make a call to 3000h:0
call 3000h:0
; Let programs know what segment they're loaded at
push program_segment
; Make a call to program_segment:0
call program_segment:0
; We've now returned.
; Clean up pushed segment
pop ax

View File

@ -1,5 +1,9 @@
mov ax, 3000h
push bp
mov bp, sp
mov ax, [bp+6]
mov ds, ax
mov word [program_segment], ax
mov si, filename
mov ah, 4
@ -10,18 +14,22 @@
mov si, ax
mov di, 0
mov bx, 4000h
mov bx, word [program_segment]
add bx, 1000h
mov ah, 3
int 22h
mov ax, 4000h
push word [program_segment]
mov ax, word [program_segment]
add ax, 1000h
mov ds, ax
mov si, 0
mov ah, 1
int 22h
mov ax, 2000h
pop ax
mov ds, ax
jmp exit
error:
@ -30,7 +38,9 @@ error:
int 22h
exit:
pop bp
retf
filename db "HELLO TXT"
err_msg db "HELLO.TXT Missing!"
program_segment dw 0