Compare commits
2 Commits
86c9baa87b
...
b3ca33653f
Author | SHA1 | Date |
---|---|---|
Juhani Krekelä | b3ca33653f | |
Juhani Krekelä | 094def1194 |
|
@ -3,3 +3,5 @@
|
|||
*.OBJ
|
||||
*.COM
|
||||
*.SYS
|
||||
*.BIN
|
||||
*.img
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
ordos.img: BOOT.BIN IO.SYS ORDOS.SYS COMMAND.COM
|
||||
rm -f ordos.img
|
||||
mkdosfs -C $@ -M 0xff 320
|
||||
rw -I 0x7c00 -i BOOT.BIN -o $@ -c 512
|
||||
mcopy -i $@ IO.SYS ::
|
||||
mcopy -i $@ ORDOS.SYS ::
|
||||
mcopy -i $@ COMMAND.COM ::
|
||||
|
||||
BOOT.BIN IO.SYS ORDOS.SYS COMMAND.COM:
|
||||
dosbox -exit build.bat
|
||||
|
||||
BOOT.BIN: boot.asm
|
||||
|
||||
IO.SYS: io.asm
|
||||
|
||||
ORDOS.SYS: msdos.asm stddos.asm
|
||||
|
||||
COMMAND.COM: command.asm
|
||||
|
||||
clean:
|
||||
rm -f ordos.img
|
||||
dosbox -exit clean.bat
|
2
README
2
README
|
@ -8,12 +8,14 @@ File origins & License
|
|||
Here 'ms-dos' refers to the Microsoft repository, while 'ordos' refers to
|
||||
new files for Ordos. Everything is under the MIT license.
|
||||
|
||||
boot.asm ordos
|
||||
build.bat ordos
|
||||
clean.bat ordos
|
||||
command.asm ms-dos v1.25/source/COMMAND.ASM
|
||||
debug.com ms-dos v1.25/bin/DEBUG.COM
|
||||
edlin.com ms-dos v1.25/bin/EDLIN.COM
|
||||
exe2bin.exe ms-dos v1.25/bin/EXE2BIN.EXE
|
||||
io.asm ordos
|
||||
link.exe ms-dos v1.25/bin/LINK.EXE
|
||||
masm.exe ms-dos v2.0/bin/MASM.EXE
|
||||
msdos.asm ms-dos v1.25/source/MSDOS.ASM
|
||||
|
|
|
@ -0,0 +1,170 @@
|
|||
; SPDX-License-Identifier: MIT
|
||||
; Copyright (c) 2021 Juhani 'nortti' Krekelä.
|
||||
|
||||
iosegment segment at 60h
|
||||
ioinit proc far
|
||||
ioinit endp
|
||||
iosegment ends
|
||||
|
||||
bootloader segment
|
||||
assume cs:bootloader, ds:bootloader, es:bootloader, ss:bootloader
|
||||
org 7c00h
|
||||
|
||||
jmp code
|
||||
|
||||
; BPB
|
||||
db "Ordos " ; OEM Identifier
|
||||
dw 512 ; Bytes per sector
|
||||
db 2 ; Sectors per cluster
|
||||
dw 1 ; Reserved sectors
|
||||
db 2 ; FATs
|
||||
dw 112 ; Root directory entries
|
||||
dw 2*320 ; Total sectors
|
||||
db 0ffh ; Media descriptor
|
||||
dw 1 ; Sectors per fat
|
||||
sectorspertrack dw 8
|
||||
heads dw 2
|
||||
dd 0 ; Hidden sectors
|
||||
dd 0 ; Total sectors (large)
|
||||
|
||||
code:
|
||||
cld
|
||||
mov ax, cs
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
cli
|
||||
mov ss, ax
|
||||
mov sp, 7c00h
|
||||
sti
|
||||
|
||||
mov drivenumber, dl
|
||||
|
||||
; TODO: Check we actually have the OS
|
||||
mov ax, 10
|
||||
mov bx, 600h
|
||||
mov cx, 17 ; This is what PC-DOS 1.10's full size ends up at
|
||||
call loadsectors
|
||||
|
||||
mov si, offset success_msg
|
||||
call printstr
|
||||
|
||||
jmp ioinit
|
||||
|
||||
; IN:
|
||||
; ax = LBA of first sector
|
||||
; es:bx = destination buffer
|
||||
; cx = number of sectors to load
|
||||
loadsectors proc
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push di
|
||||
|
||||
loading_loop:
|
||||
mov di, 3 + 1 ; Retry thrice, + 1 is since we dec first
|
||||
|
||||
retry:
|
||||
|
||||
push ax
|
||||
push cx
|
||||
|
||||
chs:
|
||||
xor dx, dx
|
||||
; cylinder (track) - head - sector
|
||||
; cylinder = LBA / sectorspertrack / heads
|
||||
; head = LBA / sectorspertrack % heads
|
||||
; sector = LBA % sectorspertrack + 1
|
||||
div sectorspertrack
|
||||
; ax = LBA / sectorspertrack
|
||||
; dx = LBA % sectorspertrack
|
||||
|
||||
; sector
|
||||
mov cl, dl
|
||||
inc cl
|
||||
|
||||
xor dx, dx
|
||||
div heads
|
||||
; ax = LBA / sectorspertrack / heads
|
||||
; dx = LBA / sectorspertrack % heads
|
||||
|
||||
; head
|
||||
mov dh, dl
|
||||
|
||||
; cylinder (track)
|
||||
mov ch, al
|
||||
shr ax, 1
|
||||
shr ax, 1
|
||||
and al, 0c0h
|
||||
or cl, al
|
||||
|
||||
mov ax, 0201h
|
||||
mov dl, drivenumber
|
||||
int 13h
|
||||
|
||||
jc disk_error
|
||||
|
||||
mov ax, 0e00h + '.'
|
||||
int 10h
|
||||
|
||||
pop cx
|
||||
pop ax
|
||||
|
||||
inc ax
|
||||
add bx, 512
|
||||
|
||||
loop loading_loop
|
||||
|
||||
pop di
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
disk_error:
|
||||
; Do we still have retries remaining?
|
||||
dec di
|
||||
jnz reset_disk
|
||||
|
||||
; No, die
|
||||
mov si, offset error_msg
|
||||
call printstr
|
||||
|
||||
hang:
|
||||
hlt
|
||||
jmp hang
|
||||
|
||||
reset_disk:
|
||||
; Yes, reset disk and retry
|
||||
xor ah, ah
|
||||
int 13h
|
||||
|
||||
pop cx
|
||||
pop ax
|
||||
jmp retry
|
||||
loadsectors endp
|
||||
|
||||
; IN:
|
||||
; si = null-terminated string
|
||||
printstr proc
|
||||
lodsb
|
||||
test al, al
|
||||
jz ret_printstr
|
||||
mov ah, 0eh
|
||||
int 10h
|
||||
jmp printstr
|
||||
|
||||
ret_printstr:
|
||||
ret
|
||||
printstr endp
|
||||
|
||||
drivenumber db (?)
|
||||
|
||||
success_msg db 13, 10, "DOS Loaded", 13, 10, 0
|
||||
error_msg db 13, 10, "Disk error", 0
|
||||
|
||||
org 7c00h + 510
|
||||
dw 0aa55h
|
||||
|
||||
bootloader ends
|
||||
|
||||
end
|
|
@ -5,3 +5,11 @@ exe2bin command.exe command.com
|
|||
masm stddos;
|
||||
link stddos;
|
||||
exe2bin stddos.exe ordos.sys
|
||||
|
||||
masm boot;
|
||||
link boot;
|
||||
exe2bin boot.exe boot.bin
|
||||
|
||||
masm io;
|
||||
link io;
|
||||
exe2bin io.exe io.sys
|
||||
|
|
|
@ -5,3 +5,11 @@ del command.com
|
|||
del stddos.obj
|
||||
del stddos.exe
|
||||
del ordos.sys
|
||||
|
||||
del boot.obj
|
||||
del boot.exe
|
||||
del boot.bin
|
||||
|
||||
del io.obj
|
||||
del io.exe
|
||||
del io.sys
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
; SPDX-License-Identifier: MIT
|
||||
; Copyright (c) 2021 Juhani 'nortti' Krekelä.
|
||||
|
||||
iosegment equ 60h
|
||||
dossegment equ iosegment + 1*1024/16 ; DOS starts 1KiB after IO system
|
||||
|
||||
dos segment at dossegment
|
||||
org 0
|
||||
dosinit proc far
|
||||
dosinit endp
|
||||
dos ends
|
||||
|
||||
code segment
|
||||
code ends
|
||||
|
||||
constants segment
|
||||
constants ends
|
||||
|
||||
data segment
|
||||
data ends
|
||||
|
||||
iogroup group code, constants, data
|
||||
|
||||
code segment
|
||||
assume cs:iogroup, ds:iogroup, es:iogroup
|
||||
org 0
|
||||
|
||||
; Jump table
|
||||
jmp init
|
||||
jmp status
|
||||
jmp getch
|
||||
jmp putch
|
||||
jmp unimplemented ; Output to printer
|
||||
jmp unimplemented ; Serial read
|
||||
jmp unimplemented ; Serial write
|
||||
jmp diskread
|
||||
jmp diskwrite
|
||||
jmp diskchange
|
||||
jmp setdate
|
||||
jmp settime
|
||||
jmp gettime
|
||||
jmp flush
|
||||
jmp mapdev
|
||||
|
||||
init:
|
||||
cld
|
||||
|
||||
cli
|
||||
mov ax, cs
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
; Put setup stack just below 32K
|
||||
xor ax, ax
|
||||
mov ss, ax
|
||||
mov sp, 8000h
|
||||
sti
|
||||
|
||||
; Figure out memory size
|
||||
int 12h
|
||||
; AX = memory size in kilobytes
|
||||
; We want it in paragraphs
|
||||
; There are 64 paragraphs in a kilobyte
|
||||
mov cx, 64
|
||||
shl al, cl
|
||||
; Memory size is passed in dx
|
||||
mov dx, ax
|
||||
|
||||
; Disk table is passed in si
|
||||
mov si, offset iogroup:disks_table
|
||||
|
||||
call dosinit
|
||||
|
||||
mov al, 'c'
|
||||
jmp error
|
||||
|
||||
; OUT:
|
||||
; al = character if any
|
||||
; zf = there were no characters
|
||||
status proc far
|
||||
; TODO: Implement
|
||||
xor ax, ax
|
||||
test ax, ax
|
||||
ret
|
||||
status endp
|
||||
|
||||
getch:
|
||||
mov al, 'g'
|
||||
jmp error
|
||||
|
||||
; IN:
|
||||
; ax = character
|
||||
putch proc far
|
||||
push ax
|
||||
mov ah, 0eh
|
||||
int 10h
|
||||
pop ax
|
||||
ret
|
||||
putch endp
|
||||
|
||||
diskread:
|
||||
mov al, 'r'
|
||||
jmp error
|
||||
diskwrite:
|
||||
mov al, 'w'
|
||||
jmp error
|
||||
diskchange:
|
||||
mov al, 'c'
|
||||
jmp error
|
||||
setdate:
|
||||
mov al, 'd'
|
||||
jmp error
|
||||
settime:
|
||||
mov al, 't'
|
||||
jmp error
|
||||
gettime:
|
||||
mov al, 'T'
|
||||
jmp error
|
||||
flush:
|
||||
mov al, 'f'
|
||||
jmp error
|
||||
|
||||
mapdev:
|
||||
mov al, 'm'
|
||||
jmp error
|
||||
|
||||
unimplemented:
|
||||
mov al, '@'
|
||||
|
||||
error:
|
||||
mov ah, 0eh
|
||||
int 10h
|
||||
|
||||
hang:
|
||||
hlt
|
||||
jmp hang
|
||||
|
||||
code ends
|
||||
|
||||
constants segment
|
||||
|
||||
disks_table:
|
||||
db 1 ; 1 drive
|
||||
|
||||
db 0 ; Physical drive 0
|
||||
dw offset iogroup:parameters_320k
|
||||
|
||||
parameters_320k:
|
||||
dw 512 ; Sector size in bytes
|
||||
db 2 ; Sectors per cluster
|
||||
dw 1 ; Number of reserved sectors
|
||||
dw 2 ; Number of FATs
|
||||
dw 112 ; Number of directory entries
|
||||
dw 320*2 ; Number of sectors
|
||||
|
||||
constants ends
|
||||
|
||||
end
|
Loading…
Reference in New Issue