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-13 22:10:23 +02:00
|
|
|
%include "inc/fcb.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
|
2020-08-27 22:52:16 +02:00
|
|
|
|
2020-12-22 22:14:16 +01:00
|
|
|
push dx
|
2021-01-13 19:32:17 +01:00
|
|
|
push ds
|
2020-12-22 22:14:16 +01:00
|
|
|
call dinit
|
2021-01-13 19:32:17 +01:00
|
|
|
pop ds
|
2020-12-22 22:14:16 +01:00
|
|
|
pop dx
|
|
|
|
|
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-02 04:45:03 +01:00
|
|
|
|
2021-01-05 00:29:50 +01:00
|
|
|
cmp dl, 0x80
|
|
|
|
jc .k
|
|
|
|
sub dl, (0x80-2)
|
|
|
|
.k: call setdd
|
|
|
|
|
2021-01-03 19:11:41 +01:00
|
|
|
mov ah, 2
|
2021-01-13 18:21:10 +01:00
|
|
|
mov dl, 0x37
|
2021-01-03 19:11:41 +01:00
|
|
|
int 0x21
|
2021-01-13 18:21:10 +01:00
|
|
|
|
|
|
|
mov dx, testfcb
|
|
|
|
mov ah, 0xF
|
2021-01-02 04:45:03 +01:00
|
|
|
int 0x21
|
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-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
|
|
|
|
|
|
|
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 $-$$
|