2020-07-04 10:35:38 +02:00
|
|
|
cpu 8086
|
2021-01-13 18:21:10 +01:00
|
|
|
org 0x0700
|
2020-04-15 00:17:58 +02:00
|
|
|
|
2020-07-04 10:35:38 +02:00
|
|
|
%include "inc/bpb.asm"
|
2020-09-15 21:44:32 +02:00
|
|
|
%include "inc/mbr.asm"
|
2020-10-25 00:50:23 +02:00
|
|
|
%include "inc/dpt.asm"
|
2020-04-15 00:17:58 +02:00
|
|
|
|
2020-07-04 10:35:38 +02:00
|
|
|
init: cli
|
|
|
|
xor ax, ax
|
|
|
|
mov ds, ax
|
|
|
|
mov es, ax
|
|
|
|
mov ss, ax
|
2021-01-02 04:45:03 +01:00
|
|
|
mov sp, ax
|
2020-04-26 23:14:34 +02:00
|
|
|
|
2021-01-13 18:21:10 +01:00
|
|
|
mov si, 0x7C00
|
|
|
|
; relocate to 00700
|
|
|
|
mov di, text_start
|
|
|
|
mov cx, text_length + rodata_length + data_length
|
|
|
|
rep movsb
|
|
|
|
; clear out bss section
|
|
|
|
mov cx, bss_length
|
|
|
|
rep stosb
|
|
|
|
; jump to copy
|
|
|
|
call 0:relinit
|
|
|
|
|
|
|
|
section .rodata
|
|
|
|
|
|
|
|
%define V 0x %+ VERSION
|
|
|
|
version: dd V
|
|
|
|
|
|
|
|
section .text
|
|
|
|
|
|
|
|
relinit: ; print banner
|
|
|
|
push word [version]
|
|
|
|
push word [version+2]
|
2020-12-26 17:03:15 +01:00
|
|
|
call printf
|
2021-01-13 18:21:10 +01:00
|
|
|
db "RDOS ",2,2, 0x0A, 0x0D, 0
|
2021-01-23 18:32:53 +01:00
|
|
|
; initialize the disk i/o
|
2020-12-22 22:14:16 +01:00
|
|
|
call dinit
|
2021-01-23 18:32:53 +01:00
|
|
|
; init 21h vector
|
2021-01-02 04:45:03 +01:00
|
|
|
mov word [0x21*4], int21
|
|
|
|
mov word [0x21*4+2], cs
|
2021-01-13 18:21:10 +01:00
|
|
|
; set current PSP, directly after us
|
|
|
|
mov ax, stack
|
|
|
|
mov cl, 4
|
|
|
|
shr ax, cl
|
|
|
|
mov word [curpsp], ax
|
2021-01-23 18:32:53 +01:00
|
|
|
; also the DTA
|
|
|
|
mov bx, dta
|
|
|
|
call setdta
|
|
|
|
; set current drive to boot drive
|
|
|
|
mov al, dl
|
|
|
|
rol al, 1
|
|
|
|
rol al, 1
|
|
|
|
or dl, al
|
|
|
|
and dl, 3
|
|
|
|
call setdd
|
|
|
|
|
|
|
|
mov bx, testfcb
|
|
|
|
call fndfst
|
2020-12-26 18:44:48 +01:00
|
|
|
|
2021-01-02 04:45:03 +01:00
|
|
|
restart:
|
2020-09-15 21:44:32 +02:00
|
|
|
hlt: hlt
|
|
|
|
jmp hlt
|
2020-04-20 19:13:06 +02:00
|
|
|
|
2021-01-21 23:28:57 +01:00
|
|
|
%include "kernel/psp.asm"
|
2021-01-05 00:00:53 +01:00
|
|
|
%include "kernel/syscall.asm"
|
2021-01-05 00:19:14 +01:00
|
|
|
%include "kernel/char.asm"
|
2020-10-13 22:10:23 +02:00
|
|
|
%include "kernel/fcb.asm"
|
2021-01-02 04:45:03 +01:00
|
|
|
%include "kernel/drive.asm"
|
2020-12-26 17:03:15 +01:00
|
|
|
%include "kernel/printf.asm"
|
2020-10-13 22:10:23 +02:00
|
|
|
|
2021-01-23 18:32:53 +01:00
|
|
|
section .bss
|
|
|
|
|
|
|
|
dta: resb 128
|
|
|
|
|
2020-10-13 22:10:23 +02:00
|
|
|
section .data
|
|
|
|
|
|
|
|
testfcb: db 0
|
|
|
|
db "HELLO ", "COM"
|
|
|
|
times 30 db 0
|
2020-09-17 07:57:46 +02:00
|
|
|
|
2021-01-13 18:21:10 +01:00
|
|
|
section .text
|
|
|
|
|
|
|
|
text_start equ $$
|
|
|
|
text_length equ $-$$
|
|
|
|
|
|
|
|
section .rodata
|
|
|
|
|
|
|
|
rodata_start equ $$
|
|
|
|
rodata_length equ $-$$
|
|
|
|
|
|
|
|
section .data
|
|
|
|
|
|
|
|
data_start equ $$
|
|
|
|
data_length equ $-$$
|
|
|
|
|
2020-04-23 21:36:20 +02:00
|
|
|
section .bss
|
2020-09-15 21:44:32 +02:00
|
|
|
|
2021-01-13 18:21:10 +01:00
|
|
|
resw 256 ; 512b kern stack
|
|
|
|
alignb 16
|
|
|
|
stack: ; stack grows into this ^
|
|
|
|
; this is also the end marker
|
|
|
|
; programs with their psp start here
|
|
|
|
|
|
|
|
bss_start equ $$
|
|
|
|
bss_length equ $-$$
|