├── .gitignore ├── README.md ├── bios ├── aux.asm ├── clock.asm ├── config.asm ├── console.asm ├── devsw.asm ├── dosbios.asm ├── floppy.asm ├── fxdisk.asm ├── prhex.asm ├── prn.asm └── rawcon.asm ├── boot ├── boot.asm └── mboot.asm ├── disk └── msdos20.img ├── dostxt ├── license.bio └── license.dos ├── etc ├── autoexec.bat ├── autoexec.fxd ├── install.bat └── install.txt ├── genimage ├── legal ├── license.bio └── license.dos ├── mkexe.c ├── msdos ├── LICENSE.md ├── chkdsk.com ├── command.com ├── cref.exe ├── debug.com ├── diskcopy.com ├── edlin.com ├── exe2bin.exe ├── fc.exe ├── find.exe ├── link.exe ├── masm.exe ├── more.com ├── msdos.sys ├── print.com ├── recover.com └── sort.exe ├── msdos1 ├── LICENSE.md └── mode.com ├── mtools.cfg ├── newinit ├── EXE2BIN.EXE ├── LICENSE.md ├── LINK.EXE ├── MASM.EXE ├── NEWINIT.ASM ├── NEWINIT.BIN ├── NEWINIT.EXE ├── NEWINIT.OBJ ├── SKELIO.ASM ├── SYSCALL.DOC ├── SYSIMES.OBJ ├── SYSINIT.DOC └── SYSINIT.OBJ ├── oemfunc.txt ├── patch ├── command.com └── command.txt ├── run-a ├── run-c ├── run-qemu.sh ├── run-small └── util ├── attrib.asm ├── chkver.asm ├── clrbss.asm ├── colorbar.asm ├── dosdefs.asm ├── dosutil.asm ├── egamode.asm ├── fdisk.asm ├── format.asm ├── license.asm ├── loadfile.asm ├── mem.asm ├── oemdefs.asm ├── reboot.asm ├── reveal.asm ├── savefile.asm ├── setcolor.asm ├── setmem.asm └── setup.asm /.gitignore: -------------------------------------------------------------------------------- 1 | /bios/version.asm 2 | /bios/dosbios.sys 3 | /boot/boot.com 4 | /boot/mboot.bin 5 | /disk/disk.img 6 | /disk/newdos.img 7 | /disk/newdos.tmp 8 | /disk/smldos.img 9 | /disk/smldos.tmp 10 | /disk/scratch.img 11 | /util/attrib.com 12 | /util/egamode.com 13 | /util/fdisk.com 14 | /util/fdisk.exe 15 | /util/format.com 16 | /util/format.exe 17 | /util/mem.com 18 | /util/reboot.com 19 | /util/setcolor.com 20 | /util/setup.com 21 | /util/setup.exe 22 | /util/colorbar.com 23 | /util/license.com 24 | /util/reveal.com 25 | /util/setmem.com 26 | /mkexe 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MS-DOS 2.0 restoration project 2 | 3 | A reimplementation of the missing parts needed to run MS-DOS 2.0 (MBR, DBR, **DOS BIOS**, FORMAT, FDISK). 4 | 5 | Done mostly **for fun**, and because AFAIK there was no **freely redistributable** drop-in replacement of the closed-source IBMBIO.COM (IO.SYS). 6 | 7 | Allows to actually **run and install** MS-DOS 2.0 on a PC. 8 | 9 | Includes support for **3.5"** floppy disks and a single hard disk partition of size up to **whooping 20 MiB**. 10 | 11 | Also includes the CON, PRN, AUX and CLOCK$ device drivers. 12 | 13 | Works best on a PC with **640 KiB** of RAM :-D 14 | -------------------------------------------------------------------------------- /bios/aux.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | d_aux: dw d_prn, BIOSSEG 28 | dw 0x8000 29 | dw strategy 30 | dw aux_io 31 | d_auxn: db "AUX " 32 | 33 | aux_io: push si 34 | mov si, aux_switch 35 | jmp d_switch 36 | 37 | aux_init: 38 | mov word [es:bx + 3], 0x0100 39 | mov word [es:bx + 14], endresid 40 | mov word [es:bx + 16], cs 41 | ret 42 | 43 | aux_havechr: 44 | db 0 45 | aux_cbuf: 46 | db 0 47 | 48 | aux_read: 49 | push ax 50 | push cx 51 | push dx 52 | push di 53 | push es 54 | mov cx, [es:bx + 18] ; Byte count 55 | les di, [es:bx + 14] ; Transfer address 56 | test byte [cs:aux_havechr], -1 57 | jnz .havechr 58 | .loop: xor dx, dx 59 | mov ax, 0x0200 60 | int 0x14 61 | test ah, 0x80 62 | jnz .stop 63 | stosb 64 | loop .loop 65 | .stop: pop es 66 | sub [es:bx + 18], cx 67 | mov [es:bx + 3 ], word 0x0100 68 | pop di 69 | pop dx 70 | pop cx 71 | pop ax 72 | ret 73 | .havechr: 74 | mov byte [cs:aux_havechr], 0 75 | mov al, [cs:aux_cbuf] 76 | stosb 77 | dec cx 78 | jmp .stop 79 | 80 | aux_read_no_wait: 81 | push ax 82 | .loop: mov ax, 0x0300 83 | xor dx, dx 84 | int 0x14 85 | test ah, 0x01 86 | jz .nochr 87 | sub [es:bx + 18], cx 88 | mov [es:bx + 3 ], word 0x0100 89 | pop ax 90 | ret 91 | .nochr: mov word [es:bx + 3 ], 0x0300 92 | pop ax 93 | ret 94 | 95 | aux_write: 96 | push ds 97 | push cx 98 | push dx 99 | push si 100 | lds si, [es:bx + 14] ; Transfer address 101 | mov cx, [es:bx + 18] ; Byte count 102 | .loop: xor dx, dx 103 | mov ah, 0x01 104 | lodsb 105 | int 0x14 106 | jc .fail 107 | loop .loop 108 | mov word [es:bx + 3], 0x0100 109 | .fini: pop si 110 | pop dx 111 | pop cx 112 | pop ds 113 | ret 114 | .fail: mov word [es:bx + 3], 0x800c 115 | jmp .fini 116 | 117 | aux_status: 118 | mov word [es:bx + 3], 0x0100 119 | ret 120 | 121 | aux_flush: 122 | push ax 123 | push dx 124 | mov ax, 0x0300 125 | xor dx, dx 126 | int 0x14 127 | test ah, 0x01 128 | jz .nochr 129 | mov ax, 0x0200 130 | xor dx, dx 131 | int 0x14 132 | .nochr: mov word [es:bx + 3], 0x0100 133 | pop dx 134 | pop ax 135 | ret 136 | 137 | aux_switch: 138 | dw aux_init ; Init 139 | dw d_nofunc ; Media check (block only) 140 | dw d_nofunc ; Build BPB (block only) 141 | dw d_nofunc ; IOCTL input 142 | dw aux_read ; Input 143 | dw aux_read_no_wait ; Non-destructive input (no wait, char devs only) 144 | dw d_nofunc ; Input status 145 | dw aux_flush ; Input flush 146 | dw aux_write ; Output 147 | dw aux_write ; Output with verify 148 | dw aux_status ; Output flush 149 | -------------------------------------------------------------------------------- /bios/clock.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | d_clk: dw d_floppy, BIOSSEG 28 | dw 0x8008 29 | dw strategy 30 | dw clk_io 31 | d_clkn: db "CLOCK$ " 32 | 33 | clk_io: 34 | push si 35 | mov si, clk_switch 36 | jmp d_switch 37 | 38 | clk_init: 39 | mov word [es:bx + 3], 0x0100 40 | mov word [es:bx + 14], endresid 41 | mov word [es:bx + 16], cs 42 | ret 43 | 44 | clk_bcd2int: 45 | push bx 46 | push cx 47 | push dx 48 | mov bx, ax 49 | and ax, 0xf0f0 50 | mov cl, 4 51 | shr ax, cl 52 | mov cx, 10 53 | mul cx 54 | and bx, 0x0f0f 55 | add ax, bx 56 | pop dx 57 | pop cx 58 | pop bx 59 | ret 60 | 61 | ; XXX this code is crude 62 | 63 | clk_read: 64 | push ax 65 | push bx 66 | push cx 67 | push dx 68 | push si 69 | push di 70 | push es 71 | 72 | les di, [es:bx + 14] ; Transfer address 73 | mov cx, [es:bx + 18] ; Byte count 74 | cmp cx, 6 75 | jb .fail 76 | 77 | mov ah, 0x04 78 | clc 79 | int 0x1a 80 | jc .fail 81 | 82 | push bx 83 | 84 | mov ax, cx 85 | call clk_bcd2int 86 | mov cx, ax 87 | 88 | mov ax, dx 89 | call clk_bcd2int 90 | mov dx, ax 91 | 92 | xor ah, ah 93 | mov bx, ax 94 | 95 | mov si, clk_md - 2 96 | test cl, 3 97 | jnz .nleap 98 | mov si, clk_lmd - 2 99 | .nleap: 100 | 101 | xor ah, ah 102 | mov al, dh 103 | add si, ax 104 | add si, ax 105 | mov ax, [cs:si] 106 | add bx, ax 107 | 108 | xor ah, ah 109 | mov al, cl 110 | add al, 3 111 | shr al, 1 112 | shr al, 1 113 | add bx, ax 114 | 115 | mov al, cl 116 | mov cx, 365 117 | mul cx 118 | 119 | add ax, bx 120 | add ax, 0x1c88 121 | 122 | cld 123 | stosw 124 | 125 | pop bx 126 | 127 | mov ah, 0x02 128 | clc 129 | int 0x1a 130 | jc .fail 131 | 132 | mov ax, cx 133 | call clk_bcd2int 134 | stosw 135 | xor al, al 136 | mov ax, dx 137 | call clk_bcd2int 138 | stosw 139 | 140 | mov word [es:bx + 3], 0x0100 141 | mov word [es:bx + 18], 6 ; Byte count 142 | 143 | .fini: pop es 144 | pop di 145 | pop si 146 | pop dx 147 | pop cx 148 | pop bx 149 | pop ax 150 | ret 151 | .fail: mov word [es:bx + 3], 0x800c 152 | mov word [es:bx + 18], 0 153 | jmp .fini 154 | clk_md: dw 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 155 | clk_lmd:dw 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 156 | 157 | clk_int2bcd8: 158 | push cx 159 | push dx 160 | xor ah, ah 161 | mov dl, 10 162 | div dl 163 | mov cl, 4 164 | shl al, cl 165 | or al, ah 166 | pop dx 167 | pop cx 168 | ret 169 | 170 | clk_write: 171 | push ax 172 | push cx 173 | push dx 174 | push si 175 | push ds 176 | 177 | lds si, [es:bx + 14] ; Transfer address 178 | mov cx, [es:bx + 18] ; Byte count 179 | cmp cx, 6 180 | jb .fail 181 | 182 | lodsw 183 | 184 | mov dx, ax 185 | mov cl, 14 186 | shr dx, cl 187 | shl ax, 1 188 | shl ax, 1 189 | mov cx, 365 * 4 + 1 190 | div cx 191 | cmp ax, 20 192 | jb .fail 193 | sub ax, 20 194 | 195 | ; convert the year to BCD and load into CX 196 | 197 | call clk_int2bcd8 198 | mov cl, al 199 | mov ch, 0x20 200 | 201 | mov bx, clk_md + 2 202 | test al, 3 203 | jnz .noleap 204 | mov bx, clk_lmd + 2 205 | 206 | .noleap:mov ax, 1 207 | shr dx, 1 208 | shr dx, 1 209 | .loop: cmp dx, [cs:bx] 210 | jl .found 211 | add bx, 2 212 | inc ax 213 | jmp .loop 214 | .found: sub dx, [cs:bx - 2] 215 | inc dx 216 | call clk_int2bcd8 217 | mov dh, al 218 | mov al, dl 219 | call clk_int2bcd8 220 | mov dl, al 221 | 222 | mov ah, 0x05 223 | int 0x1a 224 | 225 | lodsb 226 | call clk_int2bcd8 227 | mov cl, al 228 | 229 | lodsb 230 | call clk_int2bcd8 231 | mov ch, al 232 | 233 | lodsb 234 | lodsb 235 | call clk_int2bcd8 236 | mov dh, al 237 | xor dl, dl 238 | 239 | mov ah, 0x03 240 | int 0x1a 241 | 242 | mov word [es:bx + 3], 0x0100 243 | mov word [es:bx + 18], 6 ; Byte count 244 | 245 | .fini: pop ds 246 | pop si 247 | pop dx 248 | pop cx 249 | pop ax 250 | ret 251 | .fail: mov word [es:bx + 3], 0x800c 252 | mov word [es:bx + 18], 0 253 | jmp .fini 254 | 255 | clk_switch: 256 | dw clk_init ; Init 257 | dw d_nofunc ; Media check (block only) 258 | dw d_nofunc ; Build BPB (block only) 259 | dw d_nofunc ; IOCTL input 260 | dw clk_read ; Input 261 | dw clk_read ; Non-destructive input (no wait, char devs only) 262 | dw d_nofunc ; Input status 263 | dw d_nofunc ; Input flush 264 | dw clk_write ; Output 265 | dw clk_write ; Output with verify 266 | dw d_nofunc ; Output flush 267 | -------------------------------------------------------------------------------- /bios/config.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | cpu 8086 28 | 29 | BIOSSEG equ 0x0070 30 | INITSEG equ 0x0800 31 | DOSSEG equ 0x0200 32 | 33 | DIRBUF equ 0x0500 34 | IOBUF equ 0x0500 35 | STKTOP equ 0x8000 36 | 37 | MINMEM equ 48 38 | 39 | PARTID equ 0xd2 40 | PARTID2 equ 0x01 41 | 42 | RELDATE equ (43 << 9) | (11 << 5) | 10 43 | RELTIME equ ( 2 << 11) 44 | -------------------------------------------------------------------------------- /bios/console.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | d_con: dw d_aux, BIOSSEG 28 | dw 0x8013 29 | dw strategy 30 | dw con_io 31 | d_conn: db "CON " 32 | 33 | con_io: 34 | push si 35 | mov si, con_switch 36 | jmp d_switch 37 | 38 | con_init: 39 | mov word [es:bx + 3], 0x0100 40 | mov word [es:bx + 14], endresid 41 | mov word [es:bx + 16], cs 42 | ret 43 | 44 | con_clear: 45 | push bx 46 | push cx 47 | push dx 48 | push si 49 | mov ah, 0x0f 50 | int 0x10 51 | mov dl, ah 52 | dec dl 53 | mov bx, 0x0700 54 | cmp al, 0x14 55 | jae .doclr 56 | cmp al, 0x59 57 | jne .nsvga 58 | xor bh, bh 59 | jmp .doclr 60 | .nsvga: mov si, con_attr 61 | xor ah, ah 62 | add si, ax 63 | mov bh, [cs:si] 64 | .doclr: xor ax, ax 65 | mov ds, ax 66 | mov dh, [0x484] 67 | mov ax, cs 68 | mov ds, ax 69 | test dh, dh 70 | jnz .havrow 71 | mov dh, 0x18 72 | .havrow:mov ax, 0x0600 73 | xor cx, cx 74 | ; mov dh, 0x18 75 | int 0x10 76 | mov ah, 0x02 77 | xor bx, bx 78 | xor dx, dx 79 | int 0x10 80 | pop si 81 | pop dx 82 | pop cx 83 | pop bx 84 | ret 85 | 86 | con_getattr: 87 | mov ax, cs 88 | mov cx, con_attr_end - con_attr 89 | mov dx, con_attr 90 | iret 91 | 92 | con_attr: 93 | db 7 ; 00: 40x25 Text, grayscale 94 | db 7 ; 01: 40x25 Text 95 | db 7 ; 02: 80x25 Text, grayscale 96 | db 7 ; 03: 80x25 Text 97 | db 0 ; 04: CGA 320x200 98 | db 0 ; 05: CGA 320x200, grayscale 99 | db 0 ; 06: CGA 640x200 100 | db 7 ; 07: 80x25 Mono text 101 | db 7 ; 08: Various modes, assume text 102 | db 0 ; 09: PCjr 320x200 103 | db 0 ; 0a: PCjr 640x200 104 | db 0 ; 0b: Tandy 1000 SL/TL 105 | db 7 ; 0c: Reserved 106 | db 0 ; 0d: EGA/VGA 320x200, 16 colors 107 | db 0 ; 0e: EGA/VGA 640x200, 16 colors 108 | db 0 ; 0f: EGA/VGA 640x350, mono 109 | db 0 ; 10: EGA/VGA 640x350, 4 or 16 colors 110 | db 0 ; 11: VGA 640x480, mono 111 | db 0 ; 12: VGA 640x480, 16 colors 112 | db 0 ; 13: VGA 320x200, 256 colors 113 | con_attr_end: 114 | 115 | con_fastout: 116 | push ax 117 | mov ah, [cs:.state] 118 | cmp ax, 27 119 | je .incr 120 | cmp ax, 0x0100 + "[" 121 | je .incr 122 | cmp ax, 0x0200 + "2" 123 | je .incr 124 | cmp ax, 0x0300 + "J" 125 | je .clear 126 | mov byte [cs:.state], 0 127 | call chrout 128 | .fini: pop ax 129 | iret 130 | .clear: mov byte [cs:.state], 0 131 | call con_clear 132 | jmp .fini 133 | .incr: inc byte [cs:.state] 134 | jmp .fini 135 | .state: db 0 136 | 137 | con_read: 138 | push ax 139 | push cx 140 | push di 141 | .loop: xor ax, ax 142 | int 0x16 143 | test al, al 144 | jz .loop 145 | push es 146 | les di, [es:bx + 14] ; Transfer address 147 | stosb 148 | pop es 149 | mov [es:bx + 18], byte 1 ; Byte count 150 | mov [es:bx + 3 ], word 0x0100 151 | pop di 152 | pop cx 153 | pop ax 154 | ret 155 | 156 | con_write: 157 | push cx 158 | push si 159 | lds si, [es:bx + 14] ; Transfer address 160 | mov cx, [es:bx + 18] ; Byte count 161 | .loop: lodsb 162 | call chrout 163 | loop .loop 164 | mov word [es:bx + 3], 0x0100 165 | pop si 166 | pop cx 167 | ret 168 | 169 | con_read_no_wait: 170 | push ax 171 | .loop: mov ax, 0x0100 172 | int 0x16 173 | jz .nokey 174 | test al, al 175 | jz .skip 176 | mov byte [es:bx + 13], al 177 | mov word [es:bx + 3 ], 0x0100 178 | pop ax 179 | ret 180 | .nokey: mov word [es:bx + 3 ], 0x0300 181 | pop ax 182 | ret 183 | .skip: xor ah, ah 184 | int 0x16 185 | jmp .loop 186 | 187 | con_status: 188 | mov word [es:bx + 3], 0x0100 189 | ret 190 | 191 | con_flush: 192 | push ax 193 | .loop: mov ah, 0x01 194 | int 0x16 195 | jz .nokey 196 | xor ah, ah 197 | int 0x16 198 | jmp .loop 199 | .nokey: mov word [es:bx + 3], 0x0100 200 | pop ax 201 | ret 202 | 203 | con_switch: 204 | dw con_init ; Init 205 | dw d_nofunc ; Media check (block only) 206 | dw d_nofunc ; Build BPB (block only) 207 | dw d_nofunc ; IOCTL input 208 | dw con_read ; Input 209 | dw con_read_no_wait ; Non-destructive input (no wait, char devs only) 210 | dw d_nofunc ; Input status 211 | dw con_flush ; Input flush 212 | dw con_write ; Output 213 | dw con_write ; Output with verify 214 | dw con_status ; Output flush 215 | -------------------------------------------------------------------------------- /bios/devsw.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | strategy: 28 | retf 29 | 30 | d_switch: 31 | push ax 32 | mov al, [es:bx + 2] 33 | cmp al, 11 34 | jg d_nofunc 35 | xor ah, ah 36 | add si, ax 37 | add si, ax 38 | 39 | call near [cs:si] 40 | 41 | pop ax 42 | pop si 43 | retf 44 | 45 | d_nofunc: 46 | pop ax 47 | mov word [es:bx + 3], 0x800c ; XXX General Failure 48 | mov word [es:bx + 18], 0 49 | pop ax 50 | pop si 51 | retf 52 | 53 | lsegs: push cs 54 | pop ds 55 | push cs 56 | pop es 57 | ret 58 | -------------------------------------------------------------------------------- /bios/dosbios.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "bios/config.asm" 28 | %include "bios/version.asm" 29 | 30 | call init 31 | 32 | %include "bios/rawcon.asm" 33 | %include "bios/devsw.asm" 34 | 35 | %include "bios/console.asm" 36 | %include "bios/aux.asm" 37 | %include "bios/prn.asm" 38 | %include "bios/clock.asm" 39 | %include "bios/floppy.asm" 40 | %include "bios/fxdisk.asm" 41 | 42 | ; ---- DOS Patch ------------------------------------------------------------- 43 | 44 | newsc: cmp ah, 0x47 45 | je getcwd 46 | ; cmp ah, 0xff 47 | ; je oemfunc 48 | cmp ax, 0x3305 49 | je getboot 50 | jmp far [cs:oldvec] 51 | 52 | getcwd: pushf 53 | call far [cs:oldvec] 54 | jc .fini 55 | push ax 56 | push si 57 | xor al, al 58 | cld 59 | .loop: lodsb 60 | cmp al, 'a' 61 | jb .skip 62 | cmp al, 'z' 63 | ja .skip 64 | sub byte [si - 1], 32 65 | .skip: test al, al 66 | jnz .loop 67 | pop si 68 | pop ax 69 | .fini: iret 70 | 71 | getboot:mov dl, [cs:drive] 72 | iret 73 | 74 | oemfunc:test al, al 75 | je con_getattr 76 | cmp al, 0x01 77 | je clrscr 78 | cmp al, 0xff 79 | je oemver 80 | iret 81 | oemver: mov al, 0x20 82 | mov cx, ver0 83 | mov dx, ver1 84 | nointr: iret 85 | 86 | clrscr: call con_clear 87 | iret 88 | 89 | oldvec: dw 0, 0 90 | 91 | reinit: push ax 92 | push dx 93 | push ds 94 | push cs 95 | pop ds 96 | mov ax, 0x3521 97 | int 0x21 98 | mov [cs:oldvec ], bx 99 | mov [cs:oldvec + 2], es 100 | mov ax, 0x2521 101 | mov dx, newsc 102 | int 0x21 103 | mov dx, oemfunc 104 | mov ah, 0xf8 105 | int 0x21 106 | pop ds 107 | pop dx 108 | pop ax 109 | retf 110 | 111 | drive: dw 1 112 | 113 | ; ---- Initialization -------------------------------------------------------- 114 | 115 | endresid: 116 | ; db "$ENDRES$" 117 | 118 | init: pop ax 119 | cmp ax, 0x100 120 | jge comprog 121 | xor ax, ax 122 | mov ss, ax 123 | mov sp, BIOSSEG << 4 124 | mov ax, INITSEG 125 | mov es, ax 126 | push cs 127 | pop ds 128 | mov si, endinit - 2 129 | mov di, endinit - dosinit - 2 130 | mov cx, (endinit - dosinit) / 2 131 | std 132 | rep movsw 133 | test dl, 0x80 134 | jz .floppy 135 | mov word [drive], 0x3 136 | .floppy:xor ax, ax 137 | mov ss, ax 138 | mov sp, STKTOP 139 | ; mov ah, 0x02 140 | ; int 0x16 141 | ; test al, 0x5f 142 | ; jz .noshft 143 | mov si, banner 144 | call strout 145 | .noshft:xor ax, ax 146 | mov ds, ax 147 | mov word [0x29 * 4 ], con_fastout 148 | mov word [0x29 * 4 + 2], cs 149 | mov word [0x03 * 4 ], nointr 150 | mov word [0x03 * 4 + 2], cs 151 | mov ax, INITSEG 152 | mov ds, ax 153 | mov byte [0x03], 0xea 154 | mov word [0x04], reinit 155 | mov word [0x06], cs 156 | push word [cs:drive] 157 | push cs 158 | mov ax, d_con 159 | push ax 160 | int 0x12 161 | cmp ax, MINMEM 162 | jb nomem 163 | mov cl, 6 164 | shl ax, cl 165 | push ax 166 | 167 | mov ax, BIOSSEG + (endresid - $$ + 15) / 16 168 | push ax 169 | 170 | mov ax, DOSSEG 171 | push ax 172 | 173 | jmp INITSEG:0 174 | 175 | nomem: mov si, lowmem 176 | call strout 177 | .loop: hlt 178 | jmp .loop 179 | 180 | comprog:mov dx, banner + 0x100 181 | mov ah, 0x09 182 | int 0x21 183 | mov dx, date + 0x100 184 | mov ah, 0x09 185 | int 0x21 186 | int 0x20 187 | 188 | ; ---- Strings --------------------------------------------------------------- 189 | 190 | banner db 13, 10, "DOSBIOS Copyright (C) Piotr Durlej", 13, 10 191 | db "SYSINIT Copyright (C) Microsoft Corp.", 13, 10 192 | db "$" 193 | date db 10 194 | db "Build date: ", __DATE__, 13, 10 195 | db "$" 196 | 197 | lowmem db 13, 10, "48K of RAM or more is required", 13, 10, "$" 198 | 199 | ; ---- DOS Init -------------------------------------------------------------- 200 | 201 | dosinit incbin "newinit/NEWINIT.BIN" 202 | endinit: 203 | -------------------------------------------------------------------------------- /bios/floppy.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | d_floppy: 28 | dw d_fxdisk, BIOSSEG 29 | dw 0x2000 30 | dw strategy 31 | dw floppy_io 32 | flpcnt: db 2 33 | db 0, 0, 0, 0, 0, 0, 0 34 | 35 | ; ---- Floppy ---------------------------------------------------------------- 36 | 37 | floppy_io: 38 | push si 39 | mov si, floppy_switch 40 | jmp d_switch 41 | 42 | floppy_init: 43 | mov byte [es:bx + 13], 2 ; number of units 44 | mov word [es:bx + 14], endresid 45 | mov word [es:bx + 16], cs 46 | mov word [es:bx + 18], floppy_bpba ; BPB list offset 47 | mov word [es:bx + 20], cs ; BPB list segment 48 | mov word [es:bx + 3], 0x0100 ; DONE 49 | ret 50 | 51 | floppy_mcheck: 52 | mov byte [es:bx + 14], 0 ; Not sure if media changed 53 | ; mov byte [es:bx + 14], 1 ; Media has been changed 54 | mov word [es:bx + 3], 0x0100 ; DONE 55 | ret 56 | 57 | floppy_lgeom: 58 | mov word [cs:nhead], 2 59 | mov word [cs:nsect], 18 60 | ret 61 | 62 | floppy_bbpb: 63 | mov word [es:bx + 3], 0x0100 ; DONE 64 | mov word [es:bx + 18], floppy_bpb 65 | mov word [es:bx + 20], cs 66 | ret 67 | 68 | floppy_ppkt: 69 | mov cx, [es:bx + 18] ; Sector count 70 | mov ax, [es:bx + 20] ; Starting sector 71 | mov dl, [es:bx + 1] ; Unit number 72 | mov si, [es:bx + 14] 73 | mov [cs:coff], si 74 | mov si, [es:bx + 16] 75 | mov [cs:cseg], si 76 | mov [cs:ccnt], cx 77 | mov [cs:cunit], dl 78 | ret 79 | 80 | floppy_read: 81 | push ds 82 | push ax 83 | push bx 84 | push cx 85 | push dx 86 | push si 87 | push di 88 | 89 | call floppy_lgeom 90 | call floppy_ppkt 91 | call seek 92 | .loop: call split 93 | call spldma 94 | call read3 95 | jc .fail 96 | call next 97 | sub cx, [cs:ccnt] 98 | jnz .loop 99 | 100 | mov word [es:bx + 3], 0x0100 ; DONE 101 | .fini: pop di 102 | pop si 103 | pop dx 104 | pop cx 105 | pop bx 106 | pop ax 107 | pop ds 108 | ret 109 | .fail: mov word [es:bx + 3], 0x800c ; General Failure 110 | mov word [es:bx + 18], 0 111 | jmp .fini 112 | 113 | floppy_write: 114 | push ds 115 | push ax 116 | push bx 117 | push cx 118 | push dx 119 | push si 120 | push di 121 | 122 | call floppy_lgeom 123 | call floppy_ppkt 124 | call seek 125 | .loop: call split 126 | call spldma 127 | call write3 128 | jc .fail 129 | call next 130 | sub cx, [cs:ccnt] 131 | jnz .loop 132 | mov word [es:bx + 3], 0x0100 ; DONE 133 | .fini: pop di 134 | pop si 135 | pop dx 136 | pop cx 137 | pop bx 138 | pop ax 139 | pop ds 140 | ret 141 | .fail: mov word [es:bx + 3], 0x800c ; General Failure 142 | mov word [es:bx + 18], 0 143 | jmp .fini 144 | 145 | floppy_wrver: 146 | push ds 147 | push ax 148 | push bx 149 | push cx 150 | push dx 151 | push si 152 | push di 153 | 154 | call floppy_lgeom 155 | call floppy_ppkt 156 | call seek 157 | .loop: call split 158 | call spldma 159 | call write3 160 | jc .fail 161 | call verify3 162 | jc .fail 163 | call next 164 | sub cx, [cs:ccnt] 165 | jnz .loop 166 | mov word [es:bx + 3], 0x0100 ; DONE 167 | .fini: pop di 168 | pop si 169 | pop dx 170 | pop cx 171 | pop bx 172 | pop ax 173 | pop ds 174 | ret 175 | .fail: mov word [es:bx + 3], 0x800c ; General Failure 176 | mov word [es:bx + 18], 0 177 | jmp .fini 178 | 179 | seek: push bx 180 | push dx 181 | 182 | xor dx, dx 183 | mov bx, word [cs:nsect] 184 | div bx 185 | mov [cs:csect], dx 186 | xor dx, dx 187 | mov bx, word [cs:nhead] 188 | div bx 189 | mov byte [cs:chead], dl 190 | mov [cs:ccyl], ax 191 | 192 | pop dx 193 | pop bx 194 | ret 195 | 196 | split: mov ax, [cs:csect] 197 | add ax, cx 198 | cmp ax, [cs:nsect] 199 | jle .fits 200 | 201 | mov ax, [cs:nsect] 202 | sub ax, [cs:csect] 203 | mov [cs:ccnt], ax 204 | ret 205 | 206 | .fits: mov [cs:ccnt], cx 207 | ret 208 | 209 | spldma: push cx 210 | 211 | mov ax, [cs:cseg] 212 | mov cl, 4 213 | shl ax, cl 214 | add ax, [cs:coff] 215 | neg ax 216 | 217 | mov cl, 9 218 | shr ax, cl 219 | 220 | cmp ax, [cs:ccnt] 221 | jge .fits 222 | 223 | test ax, ax 224 | jnz .nzero 225 | inc ax 226 | .nzero: mov [cs:ccnt], ax 227 | .fits: pop cx 228 | ret 229 | 230 | bncaddr: 231 | dw 0, IOBUF >> 4 232 | 233 | lparm: les bx, [cs:caddr] 234 | mov ah, 0x02 235 | mov al, byte [cs:ccnt] 236 | mov ch, byte [cs:ccyl] 237 | mov cl, byte [cs:ccyl + 1] ; This code is also used by the HD driver 238 | ror cl, 1 239 | ror cl, 1 240 | or cl, byte [cs:csect] 241 | mov dh, byte [cs:chead] 242 | mov dl, byte [cs:cunit] 243 | inc cl 244 | ret 245 | 246 | read: push ds 247 | push es 248 | push ax 249 | push bx 250 | push cx 251 | push dx 252 | push si 253 | push di 254 | 255 | call lparm 256 | int 0x13 257 | jc .error 258 | 259 | .fini: clc 260 | .fail: pop di 261 | pop si 262 | pop dx 263 | pop cx 264 | pop bx 265 | pop ax 266 | pop es 267 | pop ds 268 | ret 269 | .error: cmp ah, 0x09 270 | je .bounce 271 | stc 272 | jmp .fail 273 | .bounce:mov word [cs:ccnt], 1 ; xxx 274 | call lparm 275 | les bx, [cs:bncaddr] 276 | int 0x13 277 | jc .fail 278 | 279 | lds si, [cs:bncaddr] 280 | les di, [cs:caddr] 281 | mov cx, 0x100 282 | cld 283 | rep movsw 284 | 285 | jmp .fini 286 | 287 | verify: mov byte [cs:wrcmd], 0x04 288 | jmp wrcom 289 | write: mov byte [cs:wrcmd], 0x03 290 | wrcom: push ds 291 | push es 292 | push ax 293 | push bx 294 | push cx 295 | push dx 296 | push si 297 | push di 298 | 299 | call lparm 300 | mov ah, [cs:wrcmd] 301 | int 0x13 302 | jc .error 303 | 304 | .fini: clc 305 | .fail: pop di 306 | pop si 307 | pop dx 308 | pop cx 309 | pop bx 310 | pop ax 311 | pop es 312 | pop ds 313 | ret 314 | .error: cmp ah, 0x09 315 | je .bounce 316 | stc 317 | jmp .fail 318 | .bounce:les di, [cs:bncaddr] 319 | lds si, [cs:caddr] 320 | mov cx, 0x100 321 | cld 322 | rep movsw 323 | 324 | mov word [cs:ccnt], 1 ; xxx 325 | call lparm 326 | mov ah, [cs:wrcmd] 327 | les bx, [cs:bncaddr] 328 | int 0x13 329 | jnc .fini 330 | jmp .fail 331 | 332 | next: push cx 333 | 334 | mov ax, [cs:ccnt] 335 | mov cl, 5 336 | shl ax, cl 337 | add [cs:cseg], ax 338 | 339 | mov ax, [cs:chead] 340 | mov cx, [cs:ccnt] 341 | add cx, [cs:csect] 342 | cmp cx, [cs:nsect] 343 | jne .fini 344 | 345 | xor cx, cx 346 | inc ax 347 | cmp ax, [cs:nhead] 348 | jb .fini 349 | 350 | xor ax, ax 351 | inc word [cs:ccyl] 352 | .fini: mov [cs:csect], cx 353 | mov [cs:chead], ax 354 | 355 | pop cx 356 | ret 357 | 358 | read3: call read 359 | jnc .fini 360 | call read 361 | jnc .fini 362 | call read 363 | .fini: ret 364 | 365 | write3: call write 366 | jnc .fini 367 | call write 368 | jnc .fini 369 | call write 370 | .fini: ret 371 | 372 | verify3:call verify 373 | jnc .fini 374 | call verify 375 | jnc .fini 376 | call verify 377 | .fini: ret 378 | 379 | wrcmd db 0x03 380 | nsect dw 18 381 | nhead dw 2 382 | 383 | caddr: 384 | coff dw 0 385 | cseg dw 0 386 | ccyl dw 0 387 | ccnt dw 0 388 | chead dw 0 389 | csect dw 0 390 | cunit db 0 391 | 392 | floppy_bpba: 393 | dw floppy_bpb 394 | dw floppy_bpb 395 | 396 | floppy_bpb: 397 | dw 0x0200 ; bytes per sector 398 | db 0x01 ; sectors per cluster 399 | dw 0x01 ; reserved sectors 400 | db 0x02 ; number of FATs 401 | dw 0x00e0 ; number of dir entries 402 | dw 0x0b40 ; number of sectors 403 | db 0xf0 ; media descriptor 404 | dw 0x0009 ; sectors per FAT 405 | 406 | floppy_switch: 407 | dw floppy_init ; Init 408 | dw floppy_mcheck ; Media check (block only) 409 | dw floppy_bbpb ; Build BPB (block only) 410 | dw d_nofunc ; IOCTL input 411 | dw floppy_read ; Input 412 | dw d_nofunc ; Non-destructive input (no wait, char devs only) 413 | dw d_nofunc ; Input status 414 | dw d_nofunc ; Input flush 415 | dw floppy_write ; Output 416 | dw floppy_wrver ; Output with verify 417 | dw d_nofunc ; Output flush 418 | -------------------------------------------------------------------------------- /bios/fxdisk.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | d_fxdisk: 28 | dw -1, -1 29 | dw 0x2000 30 | dw strategy 31 | dw fxdisk_io 32 | fxcnt: db 1 33 | db 0, 0, 0, 0, 0, 0, 0 34 | 35 | ; ---- fxdisk ---------------------------------------------------------------- 36 | 37 | fxdisk_io: 38 | push si 39 | mov si, fxdisk_switch 40 | jmp d_switch 41 | 42 | fxdisk_readpart: 43 | mov ax, 0x0201 44 | mov cx, 0x0001 45 | mov dx, 0x0080 46 | mov bx, IOBUF >> 4 47 | mov ds, bx 48 | mov es, bx 49 | xor bx, bx 50 | int 0x13 51 | ret 52 | 53 | fxdisk_getpart: 54 | call fxdisk_readpart 55 | jnc .ok 56 | call fxdisk_readpart 57 | jnc .ok 58 | call fxdisk_readpart 59 | jc .fini 60 | 61 | .ok: mov bx, 0x1be 62 | .loop: mov al, [bx + 0x4] 63 | cmp al, PARTID 64 | je .found 65 | cmp al, PARTID2 66 | je .found 67 | add bx, 0x10 68 | cmp bx, 0x1fe 69 | jne .loop 70 | stc 71 | .fini: push cs 72 | pop es 73 | push cs 74 | pop ds 75 | ret 76 | .found: mov ax, [bx + 0x8] 77 | mov cx, [bx + 0xc] 78 | 79 | mov [cs:fxoff ], ax 80 | mov [cs:fxtots], cx 81 | 82 | jmp .fini 83 | 84 | fxdisk_init: 85 | mov byte [es:bx + 13], 1 ; number of units 86 | mov word [es:bx + 14], endresid 87 | mov word [es:bx + 16], cs 88 | mov word [es:bx + 18], fxdisk_bpba ; BPB list offset 89 | mov word [es:bx + 20], cs ; BPB list segment 90 | mov word [es:bx + 3], 0x0100 ; DONE 91 | 92 | mov ah, 0x08 93 | mov dl, 0x80 94 | int 0x13 95 | jc .fail 96 | 97 | inc dh 98 | 99 | mov al, cl 100 | xor ah, ah 101 | shl ax, 1 102 | shl ax, 1 103 | mov al, ch 104 | inc ax 105 | 106 | mov [cs:fxdisk_geom ], ax 107 | mov [cs:fxdisk_geom + 2], dh 108 | and cl, 0x3f 109 | mov [cs:fxdisk_geom + 4], cl 110 | 111 | call fxdisk_getpart 112 | .fail: ret 113 | 114 | fxdisk_mcheck: 115 | mov byte [es:bx + 14], 0 ; Not sure if media changed 116 | ; mov byte [es:bx + 14], 1 ; Media has been changed 117 | mov word [es:bx + 3], 0x0100 ; DONE 118 | ret 119 | 120 | fxdisk_bbpb: 121 | mov word [es:bx + 3], 0x0100 ; DONE 122 | mov word [es:bx + 18], fxdisk_bpb 123 | mov word [es:bx + 20], cs 124 | ret 125 | 126 | fxdisk_lgeom: 127 | push ax 128 | mov ax, [cs:fxdisk_geom + 2] 129 | mov [cs:nhead], ax 130 | mov ax, [cs:fxdisk_geom + 4] 131 | mov [cs:nsect], ax 132 | pop ax 133 | ret 134 | 135 | fxdisk_ppkt: 136 | call floppy_ppkt 137 | add byte [cs:cunit], 0x80 138 | ret 139 | 140 | fxdisk_nogeom: 141 | mov word [es:bx + 3], 0x800c 142 | mov word [es:bx + 18], 0 143 | ret 144 | 145 | fxdisk_read: 146 | test word [cs:fxtots], -1 147 | jz fxdisk_nogeom 148 | 149 | push ds 150 | push ax 151 | push bx 152 | push cx 153 | push dx 154 | push si 155 | push di 156 | 157 | call fxdisk_lgeom 158 | call fxdisk_ppkt 159 | add ax, [cs:fxoff] 160 | call seek 161 | 162 | .loop: call split 163 | call read3 164 | jc .fail 165 | call next 166 | sub cx, [cs:ccnt] 167 | jnz .loop 168 | 169 | mov word [es:bx + 3], 0x0100 ; DONE 170 | .fini: pop di 171 | pop si 172 | pop dx 173 | pop cx 174 | pop bx 175 | pop ax 176 | pop ds 177 | ret 178 | .fail: mov word [es:bx + 3], 0x800c ; General Failure 179 | mov word [es:bx + 18], 0 180 | jmp .fini 181 | 182 | fxdisk_write: 183 | test word [cs:fxtots], -1 184 | jz fxdisk_nogeom 185 | 186 | push ds 187 | push ax 188 | push bx 189 | push cx 190 | push dx 191 | push si 192 | push di 193 | 194 | call fxdisk_lgeom 195 | call fxdisk_ppkt 196 | add ax, [cs:fxoff] 197 | call seek 198 | .loop: call split 199 | call write3 200 | jc .fail 201 | call next 202 | sub cx, [cs:ccnt] 203 | jnz .loop 204 | mov word [es:bx + 3], 0x0100 ; DONE 205 | .fini: pop di 206 | pop si 207 | pop dx 208 | pop cx 209 | pop bx 210 | pop ax 211 | pop ds 212 | ret 213 | .fail: mov word [es:bx + 3], 0x800c ; General Failure 214 | mov word [es:bx + 18], 0 215 | jmp .fini 216 | 217 | fxdisk_wrver: 218 | test word [cs:fxtots], -1 219 | jz fxdisk_nogeom 220 | 221 | push ds 222 | push ax 223 | push bx 224 | push cx 225 | push dx 226 | push si 227 | push di 228 | 229 | call fxdisk_lgeom 230 | call fxdisk_ppkt 231 | add ax, [cs:fxoff] 232 | call seek 233 | .loop: call split 234 | call spldma 235 | call write3 236 | jc .fail 237 | call verify3 238 | jc .fail 239 | call next 240 | sub cx, [cs:ccnt] 241 | jnz .loop 242 | mov word [es:bx + 3], 0x0100 ; DONE 243 | .fini: pop di 244 | pop si 245 | pop dx 246 | pop cx 247 | pop bx 248 | pop ax 249 | pop ds 250 | ret 251 | .fail: mov word [es:bx + 3], 0x800c ; General Failure 252 | mov word [es:bx + 18], 0 253 | jmp .fini 254 | 255 | fxdisk_bpba: 256 | dw fxdisk_bpb 257 | dw fxdisk_bpb 258 | 259 | fxdisk_geom: 260 | dw 0 ; Cylinders 261 | dw 0 ; Heads 262 | dw 0 ; Sectors 263 | fxoff: dw 0 ; Partition offset 264 | 265 | fxdisk_bpb: 266 | dw 0x0200 ; bytes per sector 267 | db 0x10 ; sectors per cluster 268 | dw 0x01 ; reserved sectors 269 | db 0x02 ; number of FATs 270 | dw 0x0200 ; number of dir entries 271 | fxtots: dw 0x0000 ; number of sectors 272 | db 0xf8 ; media descriptor 273 | dw 0x0008 ; sectors per FAT 274 | 275 | fxdisk_switch: 276 | dw fxdisk_init ; Init 277 | dw fxdisk_mcheck ; Media check (block only) 278 | dw fxdisk_bbpb ; Build BPB (block only) 279 | dw d_nofunc ; IOCTL input 280 | dw fxdisk_read ; Input 281 | dw d_nofunc ; Non-destructive input (no wait, char devs only) 282 | dw d_nofunc ; Input status 283 | dw d_nofunc ; Input flush 284 | dw fxdisk_write ; Output 285 | dw fxdisk_wrver ; Output with verify 286 | dw d_nofunc ; Output flush 287 | -------------------------------------------------------------------------------- /bios/prhex.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | phex: push ax 28 | push bx 29 | push si 30 | push ds 31 | 32 | mov bx, cs 33 | mov ds, bx 34 | xchg al, ah 35 | call phex8 36 | xchg al, ah 37 | call phex8 38 | 39 | pop ds 40 | pop si 41 | pop bx 42 | pop ax 43 | ret 44 | 45 | phex8: push ax 46 | and ax, $00f0 47 | shr ax, 1 48 | shr ax, 1 49 | shr ax, 1 50 | shr ax, 1 51 | call pdigit 52 | pop ax 53 | 54 | push ax 55 | and ax, $000f 56 | call pdigit 57 | pop ax 58 | 59 | ret 60 | 61 | pdigit: mov si, .digits 62 | add si, ax 63 | mov al, [cs:si] 64 | call chrout 65 | ret 66 | 67 | .digits db "0123456789ABCDEF" 68 | -------------------------------------------------------------------------------- /bios/prn.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | d_prn: dw d_clk, BIOSSEG 28 | dw 0x8000 29 | dw strategy 30 | dw prn_io 31 | d_prnn: db "PRN " 32 | 33 | prn_io: push si 34 | mov si, prn_switch 35 | jmp d_switch 36 | 37 | prn_init: 38 | mov word [es:bx + 3], 0x0100 39 | mov word [es:bx + 14], endresid 40 | mov word [es:bx + 16], cs 41 | ret 42 | 43 | prn_write: 44 | push ds 45 | push cx 46 | push dx 47 | push si 48 | lds si, [es:bx + 14] ; Transfer address 49 | mov cx, [es:bx + 18] ; Byte count 50 | .loop: xor dx, dx 51 | xor ah, ah 52 | lodsb 53 | int 0x17 54 | jc .fail 55 | loop .loop 56 | mov word [es:bx + 3], 0x0100 57 | .fini: pop si 58 | pop dx 59 | pop cx 60 | pop ds 61 | ret 62 | .fail: mov word [es:bx + 3], 0x800c 63 | jmp .fini 64 | 65 | prn_read_no_wait: 66 | prn_read: 67 | mov word [es:bx + 18], 0x0000 ; Byte count 68 | mov word [es:bx + 3 ], 0x0100 69 | ret 70 | 71 | prn_status: 72 | mov word [es:bx + 3], 0x0100 73 | ret 74 | 75 | prn_flush: 76 | mov word [es:bx + 3], 0x0100 77 | ret 78 | 79 | prn_switch: 80 | dw prn_init ; Init 81 | dw d_nofunc ; Media check (block only) 82 | dw d_nofunc ; Build BPB (block only) 83 | dw d_nofunc ; IOCTL input 84 | dw prn_read ; Input 85 | dw prn_read_no_wait ; Non-destructive input (no wait, char devs only) 86 | dw d_nofunc ; Input status 87 | dw prn_flush ; Input flush 88 | dw prn_write ; Output 89 | dw prn_write ; Output with verify 90 | dw prn_status ; Output flush 91 | -------------------------------------------------------------------------------- /bios/rawcon.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | chrout: push ax 28 | push bx 29 | mov ah, 0x0e 30 | mov bx, 0x0007 31 | int 0x10 32 | pop bx 33 | pop ax 34 | ret 35 | 36 | strout: push ax 37 | push bx 38 | push si 39 | push ds 40 | push cs 41 | pop ds 42 | cld 43 | .loop: lodsb 44 | cmp al, "$" 45 | je .fini 46 | mov ah, 0x0e 47 | mov bx, 0x0007 48 | int 0x10 49 | jmp .loop 50 | .fini: pop ds 51 | pop si 52 | pop bx 53 | pop ax 54 | ret 55 | -------------------------------------------------------------------------------- /boot/boot.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "bios/config.asm" 28 | 29 | org 0x7c00 30 | base: 31 | jmp start 32 | nop 33 | 34 | db "P-DURLEJ" ; OEM 35 | dw 0x0200 ; bytes per sector 36 | clstsz: db 0x01 ; sectors per cluster 37 | rsvds: dw 0x01 ; reserved sectors 38 | nfats: db 0x02 ; number of FATs 39 | ndire: dw 0x00e0 ; number of dir entries 40 | dw 0x0b40 ; number of sectors 41 | db 0xf0 ; media descriptor 42 | fatsz: dw 0x0009 ; sectors per FAT 43 | nsect: dw 0x0012 ; sectors per head 44 | nhead: dw 0x0002 ; heads per cylinder 45 | dd 0x000000000 ; hidden sectors 46 | dd 0x000000000 ; large total logical sectors 47 | db 0x00 ; physical drive number 48 | db 0x00 ; flags 49 | db 0x00 ; extended boot signature 50 | dd 0x12345678 ; volume serial number 51 | db "DOS " ; volume label 52 | times 8 db 0 ; filesystem type 53 | 54 | start: mov bx, [si + 8] 55 | cli ; Don't rely on the interrupt shadow (some CPUs are buggy) 56 | xor ax, ax 57 | mov ss, ax 58 | mov sp, STKTOP 59 | xor ax, ax 60 | mov ds, ax 61 | mov es, ax 62 | cld 63 | sti 64 | 65 | mov [drive], dl 66 | test dl, 0x80 67 | jz .floppy 68 | mov [poff], bx 69 | .floppy: 70 | 71 | ; load IO.SYS and MSDOS.SYS 72 | 73 | mov word [cseg], BIOSSEG 74 | mov word [cname], ionam 75 | call loadfile 76 | 77 | mov word [cseg], DOSSEG 78 | mov word [cname], dosnam 79 | call loadfile 80 | 81 | ; transfer control to IO.SYS 82 | 83 | mov dl, [drive] 84 | mov ax, BIOSSEG 85 | mov ds, ax 86 | mov es, ax 87 | jmp BIOSSEG:0 88 | 89 | loadfile: 90 | mov ax, [fatsz] 91 | mov bl, [nfats] 92 | xor bh, bh 93 | mul bx 94 | add ax, [rsvds] 95 | mov bx, [ndire] 96 | add bx, 15 97 | mov cl, 4 98 | shr bx, cl 99 | mov [resid], bx 100 | push ax 101 | call seek 102 | .nextdt:push word [cseg] ; XXX 103 | mov word [cseg], DIRBUF >> 4 104 | call read 105 | pop word [cseg] ; XXX 106 | 107 | ; find the directory entry 108 | 109 | mov di, DIRBUF 110 | .next: mov si, [cname] 111 | mov cx, 11 112 | rep cmpsb 113 | je .found 114 | and di, 0xffe0 115 | add di, 32 116 | cmp di, DIRBUF + 512 117 | jne .next 118 | dec word [resid] 119 | cmp word [resid], 0 120 | jne .nextdt 121 | jmp fail 122 | 123 | ; calculate the first sector CHS address of the file 124 | 125 | .found: mov ax, [di + 0x1a - 11] ; first cluster 126 | sub ax, 2 127 | mov bl, [clstsz] 128 | xor bh, bh 129 | mul bx 130 | pop bx 131 | add ax, bx 132 | mov bx, [ndire] 133 | add bx, 15 134 | mov cl, 4 135 | shr bx, cl 136 | add ax, bx 137 | call seek 138 | 139 | ; calculate the number of sectors to load 140 | 141 | mov cx, [di + 0x1c - 11] ; file size 142 | add cx, 511 143 | mov cl, ch 144 | shr cl, 1 145 | xor ch, ch 146 | mov word [resid], cx 147 | 148 | ; load the file 149 | 150 | .load: call read 151 | add word [cseg], 0x20 152 | dec word [resid] 153 | cmp word [resid], 0 154 | jne .load 155 | 156 | seek: add ax, [poff] 157 | xor dx, dx 158 | mov bx, word [nsect] 159 | div bx 160 | inc dx 161 | mov byte [csect], dl 162 | xor dx, dx 163 | mov bx, word [nhead] 164 | div bx 165 | mov byte [chead], dl 166 | mov [ccyl], ax 167 | ret 168 | 169 | read: push es 170 | mov ax, word [cseg] 171 | mov es, ax 172 | mov ax, 0x0201 173 | mov ch, byte [ccyl] 174 | mov cl, byte [ccyl + 1] 175 | ror cl, 1 176 | ror cl, 1 177 | or cl, byte [csect] 178 | mov dh, byte [chead] 179 | mov dl, byte [drive] 180 | xor bx, bx 181 | int 0x13 182 | jc fail 183 | pop es 184 | inc byte [csect] 185 | mov cl, [nsect] 186 | cmp [csect], cl 187 | jbe .fini 188 | mov byte [csect], 1 189 | inc byte [chead] 190 | mov cl, [nhead] 191 | cmp [chead], cl 192 | jb .fini 193 | mov byte [chead], 0 194 | inc byte [ccyl] 195 | .fini: ret 196 | 197 | fail: mov bx, 0x0007 198 | mov ah, 0x0e 199 | mov si, .msg 200 | .loop: lodsb 201 | test al, al 202 | jz .halt 203 | int 0x10 204 | jmp .loop 205 | .halt: xor ah, ah 206 | int 0x16 207 | int 0x19 208 | .msg db 13, 10, "Not a system disk or disk error", 13, 10, 0 209 | 210 | dosnam db "MSDOS SYS" 211 | ionam db "IO SYS" 212 | 213 | ccyl dw 0 214 | chead db 0 215 | csect db 0 216 | cseg dw 0xb800 217 | cname dw 0 218 | drive db 0 219 | resid dw 0 220 | poff dw 0 221 | 222 | times 0x01fe - ($ - $$) db 0 223 | dw 0xaa55 224 | -------------------------------------------------------------------------------- /boot/mboot.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "bios/config.asm" 28 | 29 | jmp 0x07c0:start 30 | 31 | start: cli ; Don't rely on the interrupt shadow (some CPUs are buggy) 32 | xor ax, ax 33 | mov ss, ax 34 | mov sp, STKTOP 35 | sti 36 | push cs 37 | pop ds 38 | cld 39 | 40 | mov ax, 0x50 41 | mov es, ax 42 | xor si, si 43 | xor di, di 44 | mov cx, 0x100 45 | rep movsw 46 | mov ds, ax 47 | jmp 0x50:.moved 48 | 49 | .moved: mov si, 0x1be 50 | .loop: test byte [si], 0x80 51 | jnz .found 52 | add si, 0x10 53 | cmp si, 0x1fe 54 | jne .loop 55 | mov si, mnoact 56 | call puts 57 | jmp $ 58 | 59 | .found: mov bx, 0x07c0 60 | mov es, bx 61 | xor bx, bx 62 | mov ax, 0x0201 63 | mov dx, [si ] 64 | mov cx, [si + 2] 65 | int 0x13 66 | jc fail 67 | 68 | jmp 0x0000:0x7c00 69 | 70 | puts: mov dx, 0x0007 71 | mov ah, 0x0e 72 | .loop: lodsb 73 | test al, al 74 | jz .fini 75 | int 0x10 76 | jmp .loop 77 | .fini: ret 78 | 79 | fail: mov si, mrfail 80 | call puts 81 | int 0x18 82 | 83 | mrfail: db "Error loading operating system", 13, 10, 0 84 | mnoact: db "Missing operating system", 13, 10, 0 85 | -------------------------------------------------------------------------------- /disk/msdos20.img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/disk/msdos20.img -------------------------------------------------------------------------------- /dostxt/license.bio: -------------------------------------------------------------------------------- 1 | Copyright (c) Piotr Durlej 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /dostxt/license.dos: -------------------------------------------------------------------------------- 1 | # MS-DOS v1.25 and v2.0 Source Code 2 | 3 | Copyright (c) Microsoft Corporation. 4 | All rights reserved. 5 | 6 | ## MIT License. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the 10 | Software), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, sublicense, and/or sell copies of the Software, and to 13 | permit persons to whom the Software is furnished to do so, subject to 14 | the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included 17 | in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 | CONTRACT,TORT OR OTHERWISE, ARISING FROM OUT OF OR IN CONNECTION WITH 25 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /etc/autoexec.bat: -------------------------------------------------------------------------------- 1 | TYPE INSTALL.TXT 2 | PROMPT $P$G 3 | -------------------------------------------------------------------------------- /etc/autoexec.fxd: -------------------------------------------------------------------------------- 1 | PATH C:\DOS 2 | PROMPT $P$G 3 | -------------------------------------------------------------------------------- /etc/install.bat: -------------------------------------------------------------------------------- 1 | ECHO OFF 2 | CLS 3 | 4 | FORMAT C: /S /M 5 | REM PAUSE 6 | REM CLS 7 | 8 | COPY AUTOEXEC.FXD C:\AUTOEXEC.BAT > NUL 9 | MD C:\DOS 10 | REM COPY *.COM C:\DOS > NUL 11 | REM COPY *.EXE C:\DOS > NUL 12 | 13 | ECHO Copying files 14 | 15 | COPY attrib.com C:\DOS > NUL 16 | COPY chkdsk.com C:\DOS > NUL 17 | COPY command.com C:\DOS > NUL 18 | COPY colorbar.com C:\DOS > NUL 19 | COPY cref.exe C:\DOS > NUL 20 | COPY debug.com C:\DOS > NUL 21 | COPY diskcopy.com C:\DOS > NUL 22 | COPY edlin.com C:\DOS > NUL 23 | COPY exe2bin.exe C:\DOS > NUL 24 | COPY fc.exe C:\DOS > NUL 25 | COPY find.exe C:\DOS > NUL 26 | COPY format.com C:\DOS > NUL 27 | COPY fdisk.com C:\DOS > NUL 28 | COPY license.com C:\DOS > NUL 29 | COPY link.exe C:\DOS > NUL 30 | COPY masm.exe C:\DOS > NUL 31 | COPY mem.com C:\DOS > NUL 32 | COPY mode.com C:\DOS > NUL 33 | COPY more.com C:\DOS > NUL 34 | COPY print.com C:\DOS > NUL 35 | COPY reboot.com C:\DOS > NUL 36 | COPY recover.com C:\DOS > NUL 37 | COPY reveal.com C:\DOS > NUL 38 | COPY setcolor.com C:\DOS > NUL 39 | COPY setup.com C:\DOS > NUL 40 | 41 | ECHO Installation complete 42 | -------------------------------------------------------------------------------- /etc/install.txt: -------------------------------------------------------------------------------- 1 | 2 | To install MS-DOS 2.0 on the hard disk: 3 | 4 | FORMAT C: /M - Minimal system 5 | SETUP - User system 6 | INSTALL - Devel system 7 | 8 | Use FDISK to create the C: partition. 9 | 10 | Type LICENSE for legal information. 11 | -------------------------------------------------------------------------------- /genimage: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | asm() { 6 | nasm -o $2 $1 7 | } 8 | 9 | # Build MKEXE 10 | 11 | cc -o mkexe mkexe.c 12 | 13 | # Generate version information 14 | 15 | cat > bios/version.asm << EOF 16 | ver0 equ 0x$(git rev-parse HEAD | cut -c 1-4) 17 | ver1 equ 0x$(git rev-parse HEAD | cut -c 5-8) 18 | EOF 19 | 20 | # Build the DOS BIOS 21 | 22 | asm bios/dosbios.asm bios/dosbios.sys 23 | 24 | # Build the boot code 25 | 26 | asm boot/mboot.asm boot/mboot.bin 27 | asm boot/boot.asm boot/boot.com 28 | 29 | # Build the commands 30 | 31 | asm util/fdisk.asm util/fdisk.com 32 | asm util/format.asm util/format.com 33 | asm util/reboot.asm util/reboot.com 34 | asm util/mem.asm util/mem.com 35 | asm util/egamode.asm util/egamode.com 36 | asm util/attrib.asm util/attrib.com 37 | asm util/colorbar.asm util/colorbar.com 38 | asm util/setcolor.asm util/setcolor.com 39 | asm util/license.asm util/license.com 40 | asm util/reveal.asm util/reveal.com 41 | asm util/setmem.asm util/setmem.com 42 | asm util/setup.asm util/setup.com 43 | 44 | ./mkexe util/fdisk.com util/fdisk.exe 1024 45 | ./mkexe util/format.com util/format.exe 1024 46 | ./mkexe util/setup.com util/setup.exe 1024 47 | 48 | # Make the floppy image 49 | 50 | #dd if=/dev/null of=dosbios.sys bs=512 seek=9 51 | 52 | export MTOOLSRC=mtools.cfg 53 | 54 | perl -e 'print chr(0xf6) x 2880 x 512' > disk/newdos.tmp 55 | 56 | mformat -m 0xf8 -v DOS a: 57 | mcopy bios/dosbios.sys a:io.sys 58 | mcopy msdos/msdos.sys a: 59 | mcopy patch/command.com a: 60 | 61 | mattrib -a +s +h +r a:io.sys 62 | mattrib -a +s +h +r a:msdos.sys 63 | 64 | mcopy msdos/command.com a:command.old 65 | mcopy msdos/chkdsk.com a: 66 | mcopy util/attrib.com a: 67 | mcopy util/colorbar.com a: 68 | mcopy msdos/cref.exe a: 69 | mcopy msdos/debug.com a: 70 | mcopy msdos/diskcopy.com a: 71 | mcopy msdos/edlin.com a: 72 | mcopy util/egamode.com a: 73 | mcopy msdos/exe2bin.exe a: 74 | mcopy msdos/fc.exe a: 75 | #mcopy util/fdisk.exe a:fdisk.com 76 | mcopy util/fdisk.com a: 77 | mcopy msdos/find.exe a: 78 | #mcopy util/format.exe a:format.com 79 | mcopy util/format.com a: 80 | mcopy msdos/link.exe a: 81 | mcopy msdos/masm.exe a: 82 | mcopy util/mem.com a: 83 | mcopy msdos1/mode.com a: 84 | mcopy msdos/more.com a: 85 | mcopy msdos/print.com a: 86 | mcopy util/reboot.com a: 87 | mcopy msdos/recover.com a: 88 | mcopy util/reveal.com a: 89 | #mcopy msdos/sort.exe a: # Binary doesn't seem to work 90 | #mcopy util/setup.exe a: 91 | mcopy util/setcolor.com a: 92 | mcopy util/setmem.com a: 93 | mcopy util/setup.com a: 94 | mcopy util/license.com a: 95 | 96 | mcopy -a legal/* a: 97 | mcopy -a etc/* a: 98 | 99 | dd status=none if=boot/boot.com of=disk/newdos.tmp conv=notrunc 100 | mv disk/newdos.tmp disk/newdos.img 101 | 102 | # Make the small floppy image 103 | 104 | export MTOOLSRC=mtools.cfg 105 | 106 | perl -e 'print chr(0xf6) x 2880 x 512' > disk/smldos.tmp 107 | 108 | mformat -m 0xf8 -v DOS b: 109 | mcopy bios/dosbios.sys b:io.sys 110 | mcopy msdos/msdos.sys b: 111 | mcopy patch/command.com b: 112 | 113 | mattrib -a +s +h +r b:io.sys 114 | mattrib -a +s +h +r b:msdos.sys 115 | #mattrib -a +s +h +r b:command.com 116 | 117 | mcopy msdos/chkdsk.com b: 118 | mcopy util/fdisk.com b:fdisk.com 119 | mcopy util/format.com b:format.com 120 | mcopy util/setup.com b: 121 | mcopy util/license.com b: 122 | 123 | dd status=none if=boot/boot.com of=disk/smldos.tmp conv=notrunc 124 | mv disk/smldos.tmp disk/smldos.img 125 | -------------------------------------------------------------------------------- /legal/license.bio: -------------------------------------------------------------------------------- 1 | Copyright (c) Piotr Durlej 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /legal/license.dos: -------------------------------------------------------------------------------- 1 | # MS-DOS v1.25 and v2.0 Source Code 2 | 3 | Copyright (c) Microsoft Corporation. 4 | All rights reserved. 5 | 6 | ## MIT License. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a 9 | copy of this software and associated documentation files (the 10 | Software), to deal in the Software without restriction, including 11 | without limitation the rights to use, copy, modify, merge, publish, 12 | distribute, sublicense, and/or sell copies of the Software, and to 13 | permit persons to whom the Software is furnished to do so, subject to 14 | the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included 17 | in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS 20 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 23 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 | CONTRACT,TORT OR OTHERWISE, ARISING FROM OUT OF OR IN CONNECTION WITH 25 | THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /mkexe.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017, Piotr Durlej 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions are met: 6 | * 7 | * 1. Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | * POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | static char *srcname, *dstname; 35 | static long srcsz; 36 | static long stacksz; 37 | static int srcfd; 38 | 39 | struct __attribute__((packed)) hdr 40 | { 41 | uint16_t magic; 42 | uint16_t lastsz; 43 | uint16_t npages; 44 | uint16_t relcnt; 45 | uint16_t hdrsz; 46 | uint16_t minmem; 47 | uint16_t maxmem; 48 | uint16_t ss; 49 | uint16_t sp; 50 | uint16_t cksum; 51 | uint16_t ip; 52 | uint16_t cs; 53 | uint16_t reloc; 54 | uint16_t ovl1; 55 | uint16_t ovl2; 56 | uint16_t padding; 57 | } hdr = 58 | { 59 | .magic = 0x5a4d, 60 | .hdrsz = sizeof hdr / 16, 61 | }; 62 | 63 | static void opensrc(void) 64 | { 65 | struct stat st; 66 | 67 | srcfd = open(srcname, O_RDONLY); 68 | if (srcfd < 0) 69 | goto fail; 70 | 71 | if (fstat(srcfd, &st)) 72 | goto fail; 73 | srcsz = st.st_size; 74 | return; 75 | fail: 76 | err(1, "%s", srcname); 77 | } 78 | 79 | static void save(void) 80 | { 81 | char buf[4096]; 82 | ssize_t wcnt; 83 | ssize_t cnt; 84 | int fd; 85 | 86 | fd = open(dstname, O_CREAT | O_TRUNC | O_WRONLY, 0666); 87 | if (fd < 0) 88 | goto fail; 89 | 90 | wcnt = write(fd, &hdr, sizeof hdr); 91 | if (wcnt != sizeof hdr) 92 | goto wrfail; 93 | 94 | while (cnt = read(srcfd, buf, sizeof buf), cnt) 95 | { 96 | if (cnt < 0) 97 | err(1, "%s", srcname); 98 | 99 | wcnt = write(fd, buf, cnt); 100 | if (wcnt != cnt) 101 | goto wrfail; 102 | srcsz -= wcnt; 103 | } 104 | 105 | if (close(fd)) 106 | goto fail; 107 | return; 108 | 109 | wrfail: 110 | if (wcnt >= 0) 111 | errx(1, "%s: Short write", dstname); 112 | fail: 113 | err(1, "%s", dstname); 114 | } 115 | 116 | static void fillhdr(void) 117 | { 118 | long mem; 119 | 120 | mem = 256 + srcsz + stacksz; 121 | mem += 15; 122 | mem /= 16; 123 | 124 | hdr.npages = (srcsz + 511) / 512; 125 | hdr.lastsz = srcsz & 511; 126 | hdr.minmem = mem; 127 | hdr.maxmem = mem; 128 | hdr.ss = -16; 129 | hdr.sp = mem; 130 | hdr.ip = 0x100; 131 | hdr.cs = -16; 132 | 133 | if (!stacksz) 134 | hdr.sp = 0x100; 135 | } 136 | 137 | int main(int argc, char **argv) 138 | { 139 | if (argc != 4) 140 | errx(1, "arg count"); 141 | 142 | srcname = argv[1]; 143 | dstname = argv[2]; 144 | stacksz = atoi(argv[3]); 145 | 146 | opensrc(); 147 | fillhdr(); 148 | save(); 149 | return 0; 150 | } 151 | -------------------------------------------------------------------------------- /msdos/LICENSE.md: -------------------------------------------------------------------------------- 1 | # MS-DOS v1.25 and v2.0 Source Code 2 | 3 | Copyright (c) Microsoft Corporation. 4 | All rights reserved. 5 | 6 | ## MIT License. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 13 | -------------------------------------------------------------------------------- /msdos/chkdsk.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/chkdsk.com -------------------------------------------------------------------------------- /msdos/command.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/command.com -------------------------------------------------------------------------------- /msdos/cref.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/cref.exe -------------------------------------------------------------------------------- /msdos/debug.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/debug.com -------------------------------------------------------------------------------- /msdos/diskcopy.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/diskcopy.com -------------------------------------------------------------------------------- /msdos/edlin.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/edlin.com -------------------------------------------------------------------------------- /msdos/exe2bin.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/exe2bin.exe -------------------------------------------------------------------------------- /msdos/fc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/fc.exe -------------------------------------------------------------------------------- /msdos/find.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/find.exe -------------------------------------------------------------------------------- /msdos/link.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/link.exe -------------------------------------------------------------------------------- /msdos/masm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/masm.exe -------------------------------------------------------------------------------- /msdos/more.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/more.com -------------------------------------------------------------------------------- /msdos/msdos.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/msdos.sys -------------------------------------------------------------------------------- /msdos/print.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/print.com -------------------------------------------------------------------------------- /msdos/recover.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/recover.com -------------------------------------------------------------------------------- /msdos/sort.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos/sort.exe -------------------------------------------------------------------------------- /msdos1/LICENSE.md: -------------------------------------------------------------------------------- 1 | # MS-DOS v1.25 and v2.0 Source Code 2 | 3 | Copyright (c) Microsoft Corporation. 4 | All rights reserved. 5 | 6 | ## MIT License. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 13 | -------------------------------------------------------------------------------- /msdos1/mode.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/msdos1/mode.com -------------------------------------------------------------------------------- /mtools.cfg: -------------------------------------------------------------------------------- 1 | # Copyright (c) Piotr Durlej 2 | # All rights reserved. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # 7 | # 1. Redistributions of source code must retain the above copyright notice, 8 | # this list of conditions and the following disclaimer. 9 | # 10 | # 2. Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | # 26 | 27 | drive a: file="disk/newdos.tmp" cylinders=80 heads=2 sectors=18 mformat_only 28 | drive b: file="disk/smldos.tmp" cylinders=80 heads=2 sectors=18 mformat_only 29 | -------------------------------------------------------------------------------- /newinit/EXE2BIN.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/newinit/EXE2BIN.EXE -------------------------------------------------------------------------------- /newinit/LICENSE.md: -------------------------------------------------------------------------------- 1 | # MS-DOS v1.25 and v2.0 Source Code 2 | 3 | Copyright (c) Microsoft Corporation. 4 | All rights reserved. 5 | 6 | ## MIT License. 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the Software), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 11 | 12 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 13 | -------------------------------------------------------------------------------- /newinit/LINK.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/newinit/LINK.EXE -------------------------------------------------------------------------------- /newinit/MASM.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/newinit/MASM.EXE -------------------------------------------------------------------------------- /newinit/NEWINIT.ASM: -------------------------------------------------------------------------------- 1 | ; I/O system for Version 2.x of MSDOS. 2 | 3 | ;This BIOS designed to be linked with the SYSINIT module provided by 4 | ;Microsoft 5 | 6 | ;Things needed to communicate with SYSINIT 7 | 8 | EXTRN SYSINIT:FAR ;The entry point of SYSINIT 9 | EXTRN CURRENT_DOS_LOCATION:WORD ;Where the DOS is when SYSINIT called 10 | EXTRN FINAL_DOS_LOCATION:WORD ;Where I want SYSINIT to put the DOS 11 | EXTRN DEVICE_LIST:DWORD ;Pointer to the DEVICE list. 12 | EXTRN MEMORY_SIZE:WORD ;Size in paragraphs of Physical memory. 13 | EXTRN DEFAULT_DRIVE:BYTE ;Default Drive to use when system booted 14 | EXTRN BUFFERS:BYTE ;Number of default buffers. 15 | ; Leave as is and SYSINIT uses only 2. 16 | 17 | PUBLIC RE_INIT 18 | 19 | CODE SEGMENT 20 | ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE 21 | 22 | ORG 0 ;Starts at an offset of zero. 23 | 24 | INIT: JMP HWINIT 25 | 26 | RINITP PROC FAR 27 | 28 | RE_INIT: 29 | RET 30 | NOP 31 | NOP 32 | NOP 33 | NOP 34 | 35 | RINITP ENDP 36 | 37 | HWINIT: PUSH CS 38 | POP ES 39 | 40 | MOV DI,SEG SYSINIT 41 | MOV DS,DI 42 | 43 | ASSUME DS:SEG SYSINIT 44 | 45 | POP DS:[CURRENT_DOS_LOCATION] 46 | POP DS:[FINAL_DOS_LOCATION] 47 | POP DS:[MEMORY_SIZE] 48 | POP WORD PTR DS:[DEVICE_LIST ] 49 | POP WORD PTR DS:[DEVICE_LIST + 2] 50 | POP AX 51 | MOV BYTE PTR DS:[DEFAULT_DRIVE], AL 52 | JMP SYSINIT 53 | 54 | DOSSPOT LABEL WORD 55 | 56 | CODE ENDS 57 | 58 | END 59 | -------------------------------------------------------------------------------- /newinit/NEWINIT.BIN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/newinit/NEWINIT.BIN -------------------------------------------------------------------------------- /newinit/NEWINIT.EXE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/newinit/NEWINIT.EXE -------------------------------------------------------------------------------- /newinit/NEWINIT.OBJ: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/newinit/NEWINIT.OBJ -------------------------------------------------------------------------------- /newinit/SKELIO.ASM: -------------------------------------------------------------------------------- 1 | TITLE IO.SYS for the ALTOS ACS-86C. 2 | 3 | ; I/O system for Version 2.x of MSDOS. 4 | 5 | ;This BIOS designed to be linked with the SYSINIT module provided by 6 | ;Microsoft 7 | 8 | BIOSIZ EQU 4096 ;Size of BIOS in bytes. 9 | BIOSIZS EQU 100H ;Size of BIOS in Paragraphs. 10 | ANSI EQU 0 ;Ansi switch. 11 | 12 | ;Additional Information for the ALTOS machine. 13 | 14 | QSIZE EQU 100 ;Input queue size. 15 | BIOSSEG EQU 0200H ;I/O system segment. 16 | MAX_MEM EQU 4000H ;Memory size in paragraphs. 17 | 18 | ; Constants for commands in Altos ROM. 19 | 20 | ROM_CONSTA EQU 01 ;Return status AL of console selected in CX. 21 | ROM_CONIN EQU 02 ;Get char. from console in CX to AL 22 | ROM_CONOUT EQU 03 ;Write char. in DL to console in CX. 23 | ROM_PMSG EQU 07 ;Write string ES:DX to console in CX. 24 | ROM_DISKIO EQU 08 ;Perform disk I/O from IOPB in ES:CX. 25 | ROM_INIT EQU 10 ;Returns boot console and top memory ES:DX. 26 | 27 | ;Things needed to communicate with SYSINIT 28 | 29 | EXTRN SYSINIT:FAR ;The entry point of SYSINIT 30 | EXTRN CURRENT_DOS_LOCATION:WORD ;Where the DOS is when SYSINIT called 31 | EXTRN FINAL_DOS_LOCATION:WORD ;Where I want SYSINIT to put the DOS 32 | EXTRN DEVICE_LIST:DWORD ;Pointer to the DEVICE list. 33 | EXTRN MEMORY_SIZE:WORD ;Size in paragraphs of Physical memory. 34 | EXTRN DEFAULT_DRIVE:BYTE ;Default Drive to use when system booted 35 | EXTRN BUFFERS:BYTE ;Number of default buffers. 36 | ; Leave as is and SYSINIT uses only 2. 37 | 38 | CODE SEGMENT 39 | ASSUME CS:CODE,DS:CODE,ES:CODE,SS:CODE 40 | 41 | ORG 0 ;Starts at an offset of zero. 42 | 43 | INIT: JMP HWINIT 44 | 45 | RINITP PROC FAR 46 | 47 | RE_INIT: 48 | RET 49 | 50 | RINITP ENDP 51 | 52 | HWINIT: PUSH CS 53 | POP ES 54 | 55 | MOV AX,SEG SYSINIT 56 | MOV DS,AX 57 | 58 | ASSUME DS:SEG SYSINIT 59 | 60 | MOV DS:[CURRENT_DOS_LOCATION],AX 61 | MOV DS:[FINAL_DOS_LOCATION],BX 62 | MOV DS:[MEMORY_SIZE],CX 63 | MOV WORD PTR DS:[DEVICE_LIST+2],DX 64 | MOV WORD PTR DS:[DEVICE_LIST],SI 65 | JMP SYSINIT 66 | 67 | DOSSPOT LABEL WORD 68 | 69 | CODE ENDS 70 | 71 | END 72 | -------------------------------------------------------------------------------- /newinit/SYSIMES.OBJ: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/newinit/SYSIMES.OBJ -------------------------------------------------------------------------------- /newinit/SYSINIT.DOC: -------------------------------------------------------------------------------- 1 | SYSINIT is a module linked behind the OEM bios. It takes 2 | over the system initialization after the OEM bios has 3 | performed any initialization it needs to do. Control is 4 | transfered with a long jump to the external variable SYSINIT 5 | 6 | 7 | The OEM has the following variables declared external: 8 | 9 | CURRENT_DOS_LOCATION WORD 10 | 11 | This word contains the segment number of the DOS before it 12 | is relocated. The OEM bios must set this value. 13 | 14 | FINAL_DOS_LOCATION WORD 15 | 16 | This word contains the segment number of the DOS after SYSINIT 17 | moves it. The OEM bios must set this value. 18 | 19 | DEVICE_LIST DWORD 20 | 21 | This double word pointer points to the linked list of 22 | character and block device drivers. The OEM must set this 23 | value. 24 | 25 | MEMORY_SIZE WORD 26 | 27 | This word contains the number of RAM paragraphs. If the 28 | bios doesn't set this variable SYSINIT will automatically 29 | calculate it. NOTE: systems with PARITY checked memory must 30 | size memory in the BIOS. SYSINITs method is to write memory 31 | and read it back until it gets a mismatch. 32 | 33 | DEFAULT_DRIVE BYTE 34 | 35 | This is the initial default drive when the system first comes 36 | up. drive a=0, drive b=1, etc. If the bios doesn't set 37 | it then drive a is assumed. 38 | 39 | BUFFERS BYTE 40 | 41 | This is the default number of buffers for the system. This 42 | value may be overridden by the user in the CONFIG.SYS file. 43 | It is DBed to 2 in SYSINIT it should be greater than 1. 44 | 45 | FILES BYTE 46 | 47 | This is the default number of files for the system. This 48 | value may be overridden by the user in the CONFIG.SYS file. 49 | It is DBed to 8 in SYSINIT, values less than 5 are ignored. 50 | 51 | SYSINIT FAR 52 | 53 | The entry point of the SYSINIT module. OEM BIOS jumps to 54 | this label at the end of its INIT code. 55 | 56 | The OEM has the following variables declared public: 57 | 58 | RE_INIT FAR 59 | 60 | This is an entry point which allows the BIOS to do some INIT 61 | work after the DOS is initialized. ALL REGISTERS MUST BE 62 | PRESERVED. On entry DS points to the first available memory 63 | (after the DOS). DS:0 points to a 100H byte program header 64 | prefix which represents the "program" currently running. 65 | This program should be thought of as the OEM BIOS and 66 | SYSINIT taken together. This is not a normal program in 67 | that no memory is allocated to it, it is running in free 68 | memory. 69 | NOTES: 70 | At the time this routine is called SYSINIT occupies the 71 | highest 10K of memory ("highest" is determined by the value 72 | of the MEMORY_SIZE variable), DO NOT DO WRITES THERE. 73 | Since this is called AFTER DOS is initialized, you can 74 | make system calls. This also implies that the code for this 75 | routine CANNOT be thrown away by use of the 76 | FINAL_DOS_LOCATION since the DOS has already been moved. 77 | If you don't want anything done just set this to point 78 | at a FAR RET instruction. 79 | -------------------------------------------------------------------------------- /newinit/SYSINIT.OBJ: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/newinit/SYSINIT.OBJ -------------------------------------------------------------------------------- /oemfunc.txt: -------------------------------------------------------------------------------- 1 | ffff get version (returns: al = 0x20, cx:dx = git commit id) 2 | ff00 get console attribute table pointer (returns: ax:dx = address, cx = length) 3 | ff01 clear the screen 4 | -------------------------------------------------------------------------------- /patch/command.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/p-durlej/dosbios/f20e8e0b08bf4df09f78e7f83dfc0cc702b2eb27/patch/command.com -------------------------------------------------------------------------------- /patch/command.txt: -------------------------------------------------------------------------------- 1 | 2 | ************************************ LICENSE ********************************** 3 | 4 | ; Copyright (c) Piotr Durlej 5 | ; All rights reserved. 6 | ; 7 | ; Redistribution and use in source and binary forms, with or without 8 | ; modification, are permitted provided that the following conditions are met: 9 | ; 10 | ; 1. Redistributions of source code must retain the above copyright notice, 11 | ; this list of conditions and the following disclaimer. 12 | ; 13 | ; 2. Redistributions in binary form must reproduce the above copyright 14 | ; notice, this list of conditions and the following disclaimer in the 15 | ; documentation and/or other materials provided with the distribution. 16 | ; 17 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 21 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | ; POSSIBILITY OF SUCH DAMAGE. 28 | ; 29 | 30 | ********************************** DESCRIPTION ******************************** 31 | 32 | Patch COMMAND.COM to disable echo on AUTOEXEC.BAT execution. 33 | 34 | Put the extra initialization code in the FORSET buffer (defined in RDATA.ASM), 35 | the buffer isn't used by COMMAND.COM until a FOR command is executed. 36 | 37 | Also modify the banner message to indicate modified COMMAND.COM. 38 | 39 | Finally disable printing the banner message at boot time. 40 | 41 | ************************************* PATCH *********************************** 42 | 43 | C:\>debug command.com 44 | -a e57 45 | 0988:0E57 jmp 872 46 | 0988:0E5A nop 47 | 0988:0E5B 48 | -a 872 49 | 0988:0872 mov byte ptr [867], 0 50 | 0988:0877 mov ah, 3e 51 | 0988:0879 int 21 52 | 0988:087B jmp e5b 53 | 0988:087E 54 | -w 55 | Writing 3C78 bytes 56 | -q 57 | 58 | C:\> 59 | 60 | A:\>debug command.com 61 | -e f28 0d 0a "Command V2.02M" 0d 0a "$" 62 | -w 63 | Writing 3C78 bytes 64 | - 65 | 66 | C:\>debug command.com 67 | -e f28 24 68 | -w 69 | Writing 3C78 bytes 70 | -q 71 | 72 | ********************************** DISASSEMBLY ******************************** 73 | 74 | -u e57 75 | 0986:0E57 E918FA JMP 0872 76 | 0986:0E5A 90 NOP 77 | 78 | -u 872 79 | 0986:0872 C606670800 MOV BYTE PTR [0867],00 80 | 0986:0877 B43E MOV AH,3E 81 | 0986:0879 CD21 INT 21 82 | 0986:087B E9DD05 JMP 0E5B 83 | 84 | ******************************************************************************* 85 | -------------------------------------------------------------------------------- /run-a: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #NCYL=306 4 | NCYL=615 5 | 6 | set -e 7 | 8 | . ./run-qemu.sh 9 | 10 | dd if=/dev/null of=disk/scratch.img bs=512 seek=2880 11 | dd if=/dev/null of=disk/disk.img bs=512 seek=$(($NCYL * 4 * 17)) 12 | #dd if=/dev/null of=disk.img bs=1M seek=504 13 | 14 | run_qemu a disk/newdos.img 15 | -------------------------------------------------------------------------------- /run-c: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #NCYL=306 4 | NCYL=615 5 | 6 | set -e 7 | 8 | . ./run-qemu.sh 9 | 10 | dd if=/dev/null of=disk/scratch.img bs=512 seek=2880 11 | dd if=/dev/null of=disk/disk.img bs=512 seek=$(($NCYL * 4 * 17)) 12 | #dd if=/dev/null of=disk.img bs=1M seek=504 13 | 14 | run_qemu c disk/newdos.img 15 | -------------------------------------------------------------------------------- /run-qemu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | run_qemu() { 4 | if [ "$DISPLAY" = "" ]; then 5 | qdpy=curses 6 | else 7 | qdpy="sdl -full-screen" 8 | fi 9 | 10 | exec qemu-system-i386 \ 11 | -fda $2 \ 12 | -fdb disk/scratch.img \ 13 | -hda disk/disk.img \ 14 | -rtc base=localtime \ 15 | -boot $1 \ 16 | -serial telnet:0.0.0.0:2000,server,nowait \ 17 | -display $qdpy 18 | } 19 | -------------------------------------------------------------------------------- /run-small: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #NCYL=306 4 | NCYL=615 5 | 6 | set -e 7 | 8 | . ./run-qemu.sh 9 | 10 | dd if=/dev/null of=disk/scratch.img bs=512 seek=2880 11 | dd if=/dev/null of=disk/disk.img bs=512 seek=$(($NCYL * 4 * 17)) 12 | #dd if=/dev/null of=disk.img bs=1M seek=504 13 | 14 | run_qemu a disk/smldos.img 15 | -------------------------------------------------------------------------------- /util/attrib.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | 29 | main: ; NUL-terminate the command line tail 30 | 31 | mov bl, [0x80] 32 | xor bh, bh 33 | add bx, 0x81 34 | xor al, al 35 | mov [bx], al 36 | 37 | ; get command-line switches 38 | 39 | call getsw 40 | cmp byte [mflag], 1 41 | je modify 42 | 43 | ; set the DTA address 44 | 45 | mov ah, 0x1a 46 | mov dx, dta 47 | int 0x21 48 | 49 | ; default to *.* 50 | 51 | cmp [0x80], byte 2 52 | jge .havnam 53 | mov [nammask], word allfil 54 | .havnam: 55 | 56 | ; find the first file 57 | 58 | mov ax, 0x4e00 59 | mov dx, [nammask] 60 | mov cx, 0x27 61 | int 0x21 62 | jc nofile 63 | 64 | ; print the file information 65 | 66 | gotfile:call prfile 67 | 68 | mov ah, 0x4f 69 | int 0x21 70 | jnc gotfile 71 | int 0x20 72 | 73 | ; no files found 74 | 75 | nofile: mov ah, 0x09 76 | mov dx, mnofil 77 | int 0x21 78 | int 0x20 79 | 80 | prfile: mov dl, [dta + 0x15] 81 | mov si, mattr 82 | mov cx, 8 83 | mov [curattr], dl 84 | cld 85 | .atrlop:lodsb 86 | mov dl, [curattr] 87 | shr dl, 1 88 | mov [curattr], dl 89 | 90 | jnc .clear 91 | mov dl, al 92 | mov ah, 0x02 93 | int 0x21 94 | loop .atrlop 95 | jmp .skip 96 | .clear: call space 97 | loop .atrlop 98 | .skip: mov ah, 0x02 99 | mov dl, ' ' 100 | int 0x21 101 | mov si, dta + 0x1e 102 | .loop: lodsb 103 | test al, al 104 | jz .end 105 | mov dl, al 106 | mov ah, 0x02 107 | int 0x21 108 | jmp .loop 109 | .end: jmp crlf 110 | 111 | crlf: mov dx, mcrlf 112 | mov ah, 0x09 113 | int 0x21 114 | ret 115 | 116 | space: mov ah, 0x02 117 | mov dl, ' ' 118 | int 0x21 119 | ret 120 | 121 | modify: mov ax, 0x4300 122 | mov dx, bx 123 | int DOSINT 124 | jc nofile 125 | 126 | mov ax, 0x4301 127 | and cx, [mask] 128 | or cx, [set] 129 | int DOSINT 130 | jc nofile 131 | int XITINT 132 | 133 | getsw: mov bl, [0x80] 134 | xor bh, bh 135 | add bx, 0x81 136 | xor al, al 137 | mov [bx], al 138 | mov bx, 0x81 139 | .loop: cmp word [bx], '+A' 140 | je .archiv 141 | cmp word [bx], '+a' 142 | je .archiv 143 | cmp word [bx], '+H' 144 | je .hide 145 | cmp word [bx], '+h' 146 | je .hide 147 | cmp word [bx], '+S' 148 | je .system 149 | cmp word [bx], '+s' 150 | je .system 151 | cmp word [bx], '+R' 152 | je .rdonly 153 | cmp word [bx], '+r' 154 | je .rdonly 155 | cmp word [bx], '-A' 156 | je .clrarc 157 | cmp word [bx], '-a' 158 | je .clrarc 159 | cmp word [bx], '-H' 160 | je .clrhid 161 | cmp word [bx], '-h' 162 | je .clrhid 163 | cmp word [bx], '-S' 164 | je .clrsys 165 | cmp word [bx], '-s' 166 | je .clrsys 167 | cmp word [bx], '-R' 168 | je .clrro 169 | cmp word [bx], '-r' 170 | je .clrro 171 | cmp word [bx], '/X' 172 | je .reset 173 | cmp word [bx], '/x' 174 | je .reset 175 | cmp word [bx], '/?' 176 | je .help 177 | cmp byte [bx], ' ' 178 | je .skip1 179 | ret 180 | .archiv:or word [set], 0x0020 181 | jmp .skip2 182 | .hide: or word [set], 0x0002 183 | jmp .skip2 184 | .system:or word [set], 0x0004 185 | jmp .skip2 186 | .rdonly:or word [set], 0x0001 187 | jmp .skip2 188 | .clrarc:and word [mask], ~0x0020 189 | jmp .skip2 190 | .clrhid:and word [mask], ~0x0002 191 | jmp .skip2 192 | .clrsys:and word [mask], ~0x0004 193 | jmp .skip2 194 | .clrro: and word [mask], ~0x0001 195 | jmp .skip2 196 | .reset: mov word [mask], 0x0000 197 | mov word [set], 0x20 198 | jmp .skip2 199 | .help: mov ah, SSTROUT 200 | mov dx, mhelp 201 | int DOSINT 202 | int XITINT 203 | .skip2: mov byte [mflag], 1 204 | inc bx 205 | .skip1: inc bx 206 | jmp .loop 207 | 208 | mhelp: db CR, LF 209 | db "Usage: ATTRIB +-AHRS FILE", CR, LF 210 | db " ATTRIB /X FILE", CR, LF 211 | db " ATTRIB PATTERN", CR, LF 212 | db LF 213 | db "Attributes:", CR, LF, LF 214 | db " A Archive", CR, LF 215 | db " H Hidden", CR, LF 216 | db " R Read-only", CR, LF 217 | db " S System", CR, LF 218 | db LF 219 | db "Command-line switches:", CR, LF, LF 220 | db " /X Reset to default attributes", CR, LF 221 | db LF 222 | db "A single file must be specified", CR, LF 223 | db "when updating attributes.", CR, LF 224 | db "$" 225 | 226 | mask: dw 0xffff 227 | set: dw 0x0000 228 | mflag: db 0 229 | 230 | nammask:dw 0x82 231 | allfil: db "*.*", 0 232 | 233 | mnofil: db "Invalid path or file not found", 13, 10, "$" 234 | mcrlf: db 13, 10, "$" 235 | mattr: db "RHSLDA67" 236 | 237 | section .bss 238 | 239 | dta: resb 128 240 | curattr:db ? 241 | -------------------------------------------------------------------------------- /util/chkver.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "bios/version.asm" 28 | %include "util/oemdefs.asm" 29 | 30 | chkver: mov ax, OGETVER 31 | int DOSINT 32 | cmp al, 0x20 33 | jne .badver 34 | cmp cx, ver0 35 | jne .badver 36 | cmp dx, ver1 37 | jne .badver 38 | ret 39 | .badver mov dx, .msg 40 | mov ah, SSTROUT 41 | int DOSINT 42 | int XITINT 43 | .fini: ret 44 | .msg db "Incorrect DOS version", 10, 13, "$" 45 | -------------------------------------------------------------------------------- /util/clrbss.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | clrbss: mov cx, ebss - sbss 28 | mov di, sbss 29 | xor al, al 30 | cld 31 | rep stosb 32 | ret 33 | -------------------------------------------------------------------------------- /util/colorbar.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | %include "util/chkver.asm" 29 | 30 | main: call chkver 31 | 32 | mov ax, 0x0003 33 | int 0x10 34 | 35 | ; XXX Not available on CGA 36 | 37 | mov ax, 0x1003 38 | mov bl, 0x00 39 | int 0x10 40 | 41 | mov ah, SSTROUT 42 | mov dx, header 43 | int DOSINT 44 | call barset 45 | mov ah, SSTROUT 46 | mov dx, middle 47 | int DOSINT 48 | mov byte [offset], 8 49 | call barset 50 | mov ah, SSTROUT 51 | mov dx, footer 52 | int DOSINT 53 | call fillbg 54 | 55 | mov ah, 0x02 56 | mov dx, 0x2000 57 | xor bh, bh 58 | int 0x10 59 | 60 | loop: xor ax, ax 61 | int 0x16 62 | cmp al, ' ' 63 | je nextbg 64 | cmp al, 0x1b 65 | jne loop 66 | mov ax, 0x0003 67 | int 0x10 68 | mov ax, OCLRSCR 69 | int DOSINT 70 | ret 71 | nextbg: add word [bgptr], 2 72 | cmp word [bgptr], endlst 73 | je resetbg 74 | call fillbg 75 | jmp loop 76 | resetbg:mov word [bgptr], bglst 77 | call fillbg 78 | jmp loop 79 | 80 | barset: mov cx, 6 81 | .loop: push cx 82 | call prline 83 | pop cx 84 | loop .loop 85 | call newln 86 | ret 87 | 88 | prline: mov al, [offset] 89 | mov [color], al 90 | .loop: call colorbar 91 | mov al, [offset] 92 | add al, 8 93 | inc byte [color] 94 | cmp byte [color], al 95 | jne .loop 96 | ret 97 | 98 | colorbar: 99 | mov ax, 0x0e20 100 | int 0x10 101 | mov bl, [color] 102 | xor bh, bh 103 | mov cx, 8 104 | .loop: mov ax, 0x09db 105 | int 0x10 106 | mov ax, 0x0edb 107 | int 0x10 108 | loop .loop 109 | mov ax, 0x0e20 110 | int 0x10 111 | ret 112 | 113 | newln: mov ax, 0x0e0d 114 | mov bx, 0x0007 115 | int 0x10 116 | mov ax, 0x0e0a 117 | int 0x10 118 | ret 119 | 120 | fillbg: mov word bx, [bgptr] 121 | mov word bx, [bx] 122 | mov dx, [bg] 123 | 124 | mov ax, 0xb800 125 | mov ds, ax 126 | mov es, ax 127 | 128 | mov cx, 2000 129 | xor si, si 130 | cld 131 | .loop: lodsw 132 | cmp ax, dx 133 | jne .next 134 | mov [si - 2], bx 135 | .next: loop .loop 136 | 137 | .fini: mov ax, cs 138 | mov ds, ax 139 | mov es, ax 140 | mov [bg], bx 141 | ret 142 | 143 | offset: db 0 144 | color: db 0 145 | bg: dw 0x0720 146 | bgptr: dw bglst 147 | 148 | bglst: dw 0x0020, 0x1120, 0x2220, 0x3320, 0x4420, 0x5520, 0x6620, 0x7720 149 | dw 0x8820, 0x9920, 0xaa20, 0xbb20, 0xcc20, 0xdd20, 0xee20, 0xff20 150 | dw 0x1fb0, 0x1fb1, 0x1fb2, 0x1f03, 0x1ffe 151 | dw 0x2fb0, 0x2fb1, 0x2fb2, 0x2f03, 0x2ffe 152 | dw 0x4fb0, 0x4fb1, 0x4fb2, 0x4f03, 0x4ffe 153 | endlst: 154 | 155 | header: db 10 156 | db " Color", 255, "Bar", 255, "Test", 13, 10, 10, "$" 157 | middle: db " Black Blue Green Cyan Red Magenta Brown Gray", 13, 10, 10, "$" 158 | footer: db " Dark Light Light Light Light Light Yellow White", 13, 10 159 | db " Gray Blue Green Cyan Red Magenta", 13, 10 160 | db 10, 10 161 | db " Press", 255, "SPACE", 255, "to", 255, "change", 255, "background", 255, "or", 255, "press", 255, "ESC", 255, "to", 255, "exit$" 162 | -------------------------------------------------------------------------------- /util/dosdefs.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | DIVINT equ 0x00 28 | 29 | XITINT equ 0x20 30 | DOSINT equ 0x21 31 | XRTINT equ 0x22 32 | BRKINT equ 0x23 33 | ERRINT equ 0x24 34 | DKRINT equ 0x25 35 | DKWINT equ 0x26 36 | TSRINT equ 0x27 37 | EXTINT equ 0x2b 38 | 39 | CR equ 13 40 | LF equ 10 41 | BS equ 8 42 | ESC equ 27 43 | EOF equ 26 44 | INTR equ 3 45 | 46 | FCB1 equ 0x5c 47 | FCB2 equ 0x6c 48 | 49 | SCHRINE equ 0x01 50 | SCHROUT equ 0x02 51 | SDCHRIN equ 0x06 52 | SCHRINN equ 0x08 53 | SSTROUT equ 0x09 54 | SSTRIN equ 0x0a 55 | SDSKRST equ 0x0d 56 | SSDRIVE equ 0x0e 57 | SOPEN equ 0x0f 58 | SCLOSE equ 0x10 59 | SFINDF equ 0x11 60 | SFINDN equ 0x12 61 | SDELETE equ 0x13 62 | SREAD equ 0x14 63 | SWRITE equ 0x15 64 | SCREAT equ 0x16 65 | SRENAME equ 0x17 66 | SGDRIVE equ 0x19 67 | SSETDTA equ 0x1a 68 | SGETALLOC equ 0x1b 69 | SGETALLOC2 equ 0x1c 70 | SGETDPB equ 0x1f 71 | SGDATE equ 0x2a 72 | SSDATE equ 0x2b 73 | SGTIME equ 0x2c 74 | SSTIME equ 0x2d 75 | SSINTV equ 0x25 76 | SNEWPSP equ 0x26 77 | SPARSEN equ 0x29 78 | 79 | DPB_OFFSET equ 0x0b ; DPB offset within bootsector 80 | DPB_SIZE equ 0x11 ; DPB size 81 | 82 | DPB_BPS equ 0x00 83 | DPB_CLUSTER_SZ equ 0x02 84 | DPB_RSVD_SECTS equ 0x03 85 | DPB_NFATS equ 0x05 86 | DPB_NDIRENT equ 0x06 87 | DPB_TOT_SECTORS equ 0x08 88 | DPB_MEDIA_DESCR equ 0x0a 89 | DPB_FAT_SIZE equ 0x0b 90 | DPB_NSECT equ 0x0d 91 | DPB_NHEAD equ 0x0f 92 | 93 | SECT_SIZE equ 0x200 94 | -------------------------------------------------------------------------------- /util/dosutil.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "bios/config.asm" 28 | %include "util/dosdefs.asm" 29 | 30 | org 0x100 31 | jmp main 32 | -------------------------------------------------------------------------------- /util/egamode.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | %include "util/chkver.asm" 29 | 30 | main: call chkver 31 | 32 | cmp byte [0x80], 3 33 | jne fail 34 | 35 | mov ax, [0x82] 36 | cmp ax, '/?' 37 | je help 38 | 39 | call cgamode 40 | call detect 41 | call findmod 42 | call setmode 43 | 44 | int XITINT 45 | 46 | cgamode:mov ax, [0x82] 47 | cmp ax, '40' 48 | je mode40 49 | cmp ax, '80' 50 | je mode80 51 | ret 52 | 53 | findmod:mov ax, [0x82] 54 | mov di, namtab 55 | mov cx, (namend - namtab) / 2 56 | cld 57 | repne 58 | scasw 59 | jne fail 60 | sub di, namtab + 2 61 | shl di, 1 62 | shl di, 1 63 | ret 64 | 65 | setmode:add di, [modetab] 66 | mov bx, [di] 67 | cmp bx, -1 68 | je nomode 69 | 70 | mov ax, [di + 4] 71 | test ax, ax 72 | jz .skip 73 | mov bl, 0x30 74 | int 0x10 75 | 76 | .skip: mov ax, [di] 77 | int 0x10 78 | 79 | mov bx, [di + 2] 80 | mov ax, bx 81 | xor bx, bx 82 | int 0x10 83 | 84 | mov ah, 0x01 85 | mov cx, [di + 6] 86 | int 0x10 87 | 88 | fini: mov ax, OCLRSCR 89 | int DOSINT 90 | ret 91 | 92 | mode40: mov ax, 0x0001 93 | int 0x10 94 | call fini 95 | int XITINT 96 | 97 | mode80: mov ax, 0x0003 98 | int 0x10 99 | call fini 100 | int XITINT 101 | 102 | help: mov dx, .msg 103 | mov ah, SSTROUT 104 | int DOSINT 105 | int XITINT 106 | .msg: db CR, LF 107 | db "Usage: EGAMODE 12|14|21|25|28|43|50", CR, LF 108 | db " EGAMODE 40|80", CR, LF 109 | db "$" 110 | 111 | detect: mov ax, 0x1a00 112 | int 0x10 113 | cmp al, 0x1a 114 | jne .notvga 115 | mov [modetab], word vgatab 116 | ret 117 | .notvga:mov ah, 0x12 118 | mov bl, 0x10 119 | int 0x10 120 | cmp bl, 0x10 121 | je noega 122 | ret 123 | 124 | chkega: mov ah, 0x12 125 | mov bl, 0x10 126 | int 0x10 127 | cmp bl, 0x10 128 | je noega 129 | ret 130 | 131 | noega: mov ah, SSTROUT 132 | mov dx, .msg 133 | int DOSINT 134 | int XITINT 135 | .msg: db "Not an EGA/VGA card", CR, LF, "$" 136 | 137 | nomode: mov ah, SSTROUT 138 | mov dx, .msg 139 | int DOSINT 140 | int XITINT 141 | .msg: db "Mode not available", CR, LF, "$" 142 | 143 | fail: mov ah, SSTROUT 144 | mov dx, .msg 145 | int DOSINT 146 | int XITINT 147 | .msg: db "Bad or missing parameter", CR, LF, "$" 148 | 149 | namtab: dw '25', '28', '43', '50', '12', '14', '21' 150 | namend: 151 | 152 | egatab: dw 0x0003, 0x1114, 0, 0x0006 ; 80x25 153 | dw -1, 0, 0, 0x0007 ; 80x28 154 | dw 0x0003, 0x1112, 0, 0x0007 ; 80x43 155 | dw -1, 0, 0, 0x0007 ; 80x50 156 | dw -1, 0, 0, 0x0007 ; 40x12 157 | dw -1, 0, 0, 0x0007 ; 40x14 158 | dw -1, 0, 0, 0x0007 ; 80x21 159 | 160 | vgatab: dw 0x0003, 0x1114, 0x1202, 0x0006 ; 80x25 161 | dw 0x0003, 0x1111, 0x1202, 0x0007 ; 80x28 162 | dw 0x0003, 0x1112, 0x1201, 0x0007 ; 80x43 163 | dw 0x0003, 0x1112, 0x1202, 0x0007 ; 80x50 164 | dw 0x0001, 0x1114, 0x1200, 0x0007 ; 40x12 165 | dw 0x0001, 0x1111, 0x1200, 0x0007 ; 40x14 166 | dw 0x0003, 0x1114, 0x1201, 0x0007 ; 80x21 167 | 168 | modetab:dw egatab 169 | -------------------------------------------------------------------------------- /util/fdisk.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | %include "util/clrbss.asm" 29 | %include "util/chkver.asm" 30 | 31 | main: call chkver 32 | call clrbss 33 | jmp start 34 | 35 | MAXSECT equ 0xa000 36 | 37 | mbootsz equ (mbootend - mboot) 38 | part equ buf + 0x1be 39 | 40 | start: mov ax, 0x0201 41 | mov cx, 0x0001 42 | mov dx, 0x0080 43 | mov bx, buf 44 | int 0x13 45 | jc fail 46 | 47 | root: call banner 48 | mov dx, moptions 49 | mov ah, SSTROUT 50 | int DOSINT 51 | call getkey 52 | cmp al, 'Q' 53 | je exit 54 | cmp al, 'q' 55 | je exit 56 | cmp al, 27 57 | je exit 58 | cmp al, '1' 59 | je create 60 | cmp al, '2' 61 | je change 62 | cmp al, '3' 63 | je delete 64 | cmp al, '4' 65 | je show 66 | call beep 67 | jmp root 68 | 69 | exit: mov ax, 0x0301 70 | mov cx, 0x0001 71 | mov dx, 0x0080 72 | mov bx, buf 73 | int 0x13 74 | mov dx, mexit 75 | mov ah, SSTROUT 76 | int DOSINT 77 | test [reboot], byte 0xff 78 | jnz .reboot 79 | int XITINT 80 | .reboot:call banner 81 | mov dx, mreboot 82 | mov ah, SSTROUT 83 | int DOSINT 84 | call anykey 85 | mov dx, mexit 86 | mov ah, SSTROUT 87 | int DOSINT 88 | int 0x19 89 | 90 | banner: mov dx, mbanner 91 | mov ah, SSTROUT 92 | int DOSINT 93 | ret 94 | 95 | gettype: 96 | cmp [si + 4], byte PARTID 97 | je .dos 98 | cmp [si + 4], byte PARTID2 99 | je .dos 100 | cmp [si + 4], byte 192 101 | je .xenus 102 | mov dx, mtother 103 | ret 104 | .dos: mov dx, mtdos 105 | ret 106 | .xenus: mov dx, mtxenus 107 | ret 108 | 109 | prnum: push ax 110 | push bx 111 | push cx 112 | push dx 113 | push si 114 | push di 115 | 116 | mov di, .buf + 3 117 | mov cx, 4 118 | std 119 | 120 | .loop: xor dx, dx 121 | mov bx, 10 122 | div bx 123 | push ax 124 | mov ax, '0' 125 | add ax, dx 126 | stosb 127 | pop ax 128 | loop .loop 129 | cld 130 | 131 | mov si, .buf 132 | mov cx, 3 133 | .nzero: cmp [si], byte '0' 134 | jne .print 135 | mov [si], byte ' ' 136 | inc si 137 | loop .nzero 138 | 139 | .print: mov dx, .buf 140 | mov ah, SSTROUT 141 | int DOSINT 142 | 143 | pop di 144 | pop si 145 | pop dx 146 | pop cx 147 | pop bx 148 | pop ax 149 | ret 150 | .buf: db "xxxx$" 151 | 152 | prpart1:push bx 153 | 154 | test [si + 4], byte 0xff 155 | jz .fini 156 | 157 | mov cx, 4 158 | call space 159 | mov dl, bl 160 | mov ah, SCHROUT 161 | int DOSINT 162 | mov cx, 9 163 | call space 164 | 165 | test [si], byte 0x80 166 | jz .notact 167 | mov dl, 'A' 168 | jmp .pstat 169 | .notact:mov dl, ' ' 170 | .pstat: mov ah, SCHROUT 171 | int DOSINT 172 | 173 | mov cx, 3 174 | call space 175 | 176 | call gettype 177 | mov ah, SSTROUT 178 | int DOSINT 179 | 180 | mov cx, 2 181 | call space 182 | 183 | mov al, [si + 3] 184 | mov ah, [si + 2] 185 | rol ah, 1 186 | rol ah, 1 187 | and ah, 3 188 | push ax 189 | call prnum 190 | 191 | mov cx, 1 192 | call space 193 | 194 | mov ax, [si + 7] 195 | mov ah, [si + 6] 196 | rol ah, 1 197 | rol ah, 1 198 | and ah, 3 199 | push ax 200 | call prnum 201 | 202 | mov cx, 1 203 | call space 204 | 205 | pop ax 206 | pop bx 207 | sub ax, bx 208 | inc ax 209 | call prnum 210 | 211 | call crlf 212 | 213 | .fini: pop bx 214 | ret 215 | 216 | prpart: mov dx, mheader 217 | mov ah, SSTROUT 218 | int DOSINT 219 | mov si, buf + 0x1be 220 | mov bl, '1' 221 | call prpart1 222 | mov si, buf + 0x1ce 223 | inc bl 224 | call prpart1 225 | mov si, buf + 0x1de 226 | inc bl 227 | call prpart1 228 | mov si, buf + 0x1ee 229 | inc bl 230 | call prpart1 231 | call crlf 232 | ret 233 | 234 | getdp: mov ah, 0x08 235 | mov dl, 0x80 236 | int 0x13 237 | jc fail 238 | ret 239 | 240 | create: call banner 241 | call prpart 242 | mov si, buf + 0x1be 243 | mov cx, 4 244 | .loop: mov al, [si + 4] 245 | test al, al 246 | jz .skip 247 | jmp fndpart 248 | .skip: add si, 0x10 249 | loop .loop 250 | 251 | mov si, mboot 252 | mov di, buf 253 | mov cx, mbootsz 254 | cld 255 | rep movsb 256 | 257 | mov cx, 510 - mbootsz 258 | xor al, al 259 | rep stosb 260 | mov ax, 0xaa55 261 | stosw 262 | 263 | call getdp 264 | 265 | mov word [part ], 0x0180 266 | mov word [part + 2], 0x0001 267 | mov word [part + 4], PARTID 268 | mov byte [part + 5], dh 269 | mov word [part + 6], cx 270 | 271 | inc dh 272 | 273 | mov al, cl 274 | xor ah, ah 275 | shl ax, 1 276 | shl ax, 1 277 | mov al, ch 278 | inc ax 279 | 280 | and cx, 0x3f 281 | 282 | mov dl, dh 283 | xor dh, dh 284 | 285 | mov [ncyl], ax 286 | mov [head], dx 287 | mov [sect], cx 288 | 289 | mul dx 290 | jc .oflow 291 | mul cx 292 | jc .oflow 293 | sub ax, cx 294 | cmp ax, 0xa000 295 | jae .oflow 296 | 297 | .gotsz: mov word [part + 0x08], cx 298 | mov word [part + 0x0c], ax 299 | 300 | call banner 301 | call prpart 302 | mov [reboot], byte 1 303 | mov dx, mdone 304 | mov ah, SSTROUT 305 | int DOSINT 306 | call anykey 307 | jmp root 308 | .oflow: push cx 309 | mov ax, MAXSECT - 1 310 | xor dx, dx 311 | div word [sect] 312 | xor dx, dx 313 | div word [head] 314 | mov cl, 6 315 | shl ah, cl 316 | mov [part + 7], al 317 | and [part + 6], byte 0x3f 318 | or [part + 6], ah 319 | mov ax, MAXSECT 320 | pop cx 321 | jmp .gotsz 322 | 323 | fndpart:mov dx, mexist 324 | mov ah, 0x09 325 | int 0x21 326 | call waitkey 327 | jmp root 328 | 329 | fail: mov dx, .msg 330 | mov ah, 0x09 331 | int 0x21 332 | int 0x20 333 | .msg: db "I/O Error", 13, 10, "$" 334 | 335 | getkey: 336 | mov ah, SCHRINN 337 | int DOSINT 338 | cmp al, 27 339 | je .fini 340 | cmp al, 32 341 | jb .bad 342 | cmp al, 127 343 | ja .bad 344 | .fini: ret 345 | .bad: call beep 346 | jmp getkey 347 | 348 | waitkey: 349 | mov ah, SCHRINN 350 | int DOSINT 351 | ret 352 | 353 | anykey: 354 | mov dx, manykey 355 | mov ah, SSTROUT 356 | int DOSINT 357 | jmp waitkey 358 | 359 | space: 360 | mov ah, SCHROUT 361 | mov dl, ' ' 362 | .loop: int DOSINT 363 | loop .loop 364 | ret 365 | 366 | crlf: 367 | mov dx, mcrlf 368 | mov ah, 0x09 369 | int 0x21 370 | ret 371 | 372 | beep: 373 | mov dl, 7 374 | mov ah, SCHROUT 375 | int DOSINT 376 | ret 377 | 378 | getpartn: 379 | call getkey 380 | cmp al, 'Q' 381 | je .cancel 382 | cmp al, 'q' 383 | je .cancel 384 | cmp al, 27 385 | je .cancel 386 | cmp al, '1' 387 | jb .bad 388 | cmp al, '4' 389 | ja .bad 390 | sub al, '1' 391 | xor ah, ah 392 | mov bx, ax 393 | shl bx, 1 394 | shl bx, 1 395 | shl bx, 1 396 | shl bx, 1 397 | test [bx + part + 4], byte 0xff 398 | jz .bad 399 | clc 400 | ret 401 | .cancel:stc 402 | ret 403 | .bad: mov dx, mbadpar 404 | mov ah, SSTROUT 405 | int DOSINT 406 | call anykey 407 | stc 408 | ret 409 | 410 | wantpart: 411 | mov si, part 412 | mov cx, 4 413 | .loop: test [si + 4], byte 0xff 414 | jnz .found 415 | add si, 16 416 | loop .loop 417 | mov dx, mnopart 418 | mov ah, SSTROUT 419 | int DOSINT 420 | call anykey 421 | stc 422 | ret 423 | .found: clc 424 | ret 425 | 426 | change: call banner 427 | call prpart 428 | call wantpart 429 | jc root 430 | mov dx, mactpar 431 | mov ah, SSTROUT 432 | int DOSINT 433 | call getpartn 434 | jc root 435 | 436 | mov di, part 437 | mov cx, 4 438 | .clear: mov [di], byte 0 439 | add di, 16 440 | loop .clear 441 | 442 | mov bx, ax 443 | shl bx, 1 444 | shl bx, 1 445 | shl bx, 1 446 | shl bx, 1 447 | mov [bx + part], byte 0x80 448 | 449 | call banner 450 | call prpart 451 | call anykey 452 | jmp root 453 | 454 | delete: call banner 455 | call prpart 456 | call wantpart 457 | jc root 458 | mov dx, mdelpar 459 | mov ah, SSTROUT 460 | int DOSINT 461 | call getpartn 462 | jc root 463 | 464 | mov di, ax 465 | shl di, 1 466 | shl di, 1 467 | shl di, 1 468 | shl di, 1 469 | add di, part 470 | mov cx, 8 471 | xor ax, ax 472 | rep stosw 473 | 474 | mov [reboot], byte 1 475 | call banner 476 | call prpart 477 | call anykey 478 | jmp root 479 | 480 | show: 481 | call banner 482 | call prpart 483 | call anykey 484 | jmp root 485 | 486 | mbanner:db 27, "[2J" 487 | db "Fixed Disk Setup Program Version 1.01", 13, 10 488 | db "(C) Piotr Durlej", 13, 10, 10, "$" 489 | moptions: 490 | db "Options:", 13, 10, 10 491 | db " 1. Create DOS partition", 13, 10 492 | db " 2. Change active partition", 13, 10 493 | db " 3. Delete partition", 13, 10 494 | db " 4. Display partition information", 13, 10, 10 495 | db "Enter choice: $" 496 | mexist: db "Partitions already exist", 13, 10, "$" 497 | mheader:db "Partition Status Type Start End Size", 13, 10, "$" 498 | mdone: db "MBR initialization successful", 13, 10, "$" 499 | mnopart:db "No partitions defined", 13, 10, "$" 500 | manykey:db "Press any key to continue", 13, 10, "$" 501 | mactpar:db "New active partition: $" 502 | mdelpar:db "Delete partition: $" 503 | mbadpar:db 13, 10, 10, "Invalid partition specification", 13, 10, "$" 504 | mreboot:db "The system will now reboot", 13, 10, "$" 505 | mexit: db 27, "[2J$" 506 | mtdos: db "DOS $" 507 | mtxenus:db "XENUS$" 508 | mtother:db "Other$" 509 | mcrlf: db 13, 10, "$" 510 | 511 | reboot: db 0 512 | 513 | ncyl: dw 0 514 | head: dw 0 515 | sect: dw 0 516 | 517 | mboot incbin "boot/mboot.bin" 518 | mbootend: 519 | 520 | section .bss 521 | sbss: 522 | buf: resb 512 523 | ebss: 524 | -------------------------------------------------------------------------------- /util/format.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | 29 | bpb equ bootsec + DPB_OFFSET 30 | clusz equ bpb + DPB_CLUSTER_SZ 31 | nsect equ bpb + DPB_NSECT 32 | nhead equ bpb + DPB_NHEAD 33 | nfats equ bpb + DPB_NFATS 34 | fatsz equ bpb + DPB_FAT_SIZE 35 | ndire equ bpb + DPB_NDIRENT 36 | rsvds equ bpb + DPB_RSVD_SECTS 37 | totsec equ bpb + DPB_TOT_SECTORS 38 | 39 | main: call chkdrv 40 | call chkver 41 | call clrbss 42 | call getsw 43 | call getdrv 44 | call loadsys 45 | call modmsg 46 | call modpath 47 | loop: call asknew 48 | call diskrst 49 | call getdprm 50 | call smtype 51 | call format 52 | call initfs 53 | call savesys 54 | call setlabel 55 | call asknxt 56 | jmp loop 57 | 58 | %include "util/loadfile.asm" 59 | %include "util/savefile.asm" 60 | %include "util/clrbss.asm" 61 | %include "util/chkver.asm" 62 | 63 | chkdrv: test al, al 64 | jnz baddrv 65 | ret 66 | 67 | getsw: mov cl, [0x80] 68 | xor ch, ch 69 | mov di, 0x81 70 | mov al, '/' 71 | cld 72 | .getsw: repne scasb 73 | cmp cx, 0 74 | jne .gotsw 75 | ret 76 | .gotsw: mov bl, [di] 77 | cmp bl, '?' 78 | je help 79 | cmp bl, 's' 80 | je .sflag 81 | cmp bl, 'S' 82 | je .sflag 83 | cmp bl, 'q' 84 | je .qflag 85 | cmp bl, 'Q' 86 | je .qflag 87 | cmp bl, 'a' 88 | je .aflag 89 | cmp bl, 'A' 90 | je .aflag 91 | cmp bl, 'm' 92 | je .mflag 93 | cmp bl, 'M' 94 | je .mflag 95 | cmp bl, 'e' 96 | je .eflag 97 | cmp bl, 'E' 98 | je .eflag 99 | cmp bl, 'v' 100 | je .vflag 101 | cmp bl, 'V' 102 | je .vflag 103 | jmp .badsw 104 | .sflag: mov byte [sflag], 1 105 | jmp .getsw 106 | .qflag: mov byte [qflag], 1 107 | jmp .getsw 108 | .aflag: mov byte [aflag], 1 109 | jmp .getsw 110 | .mflag: mov byte [mflag], 1 111 | jmp .sflag 112 | .vflag: mov byte [sysattr], 0x20 113 | jmp .sflag 114 | .eflag: mov byte [ndire], 16 115 | jmp .getsw 116 | .badsw: mov dx, mbadsw 117 | mov ah, SSTROUT 118 | int DOSINT 119 | mov ah, SCHROUT 120 | mov dl, bl 121 | int DOSINT 122 | call crlf 123 | int XITINT 124 | 125 | getdrv: mov al, [FCB1] 126 | test al, al 127 | jnz .gotdrv 128 | mov ah, SGDRIVE 129 | int DOSINT 130 | inc al 131 | .gotdrv:dec al 132 | mov [biosdrv], al ; XXX assumes DOS drive numbers correspond directly to BIOS drive numbers 133 | mov [drive], al 134 | cmp al, 2 135 | jl .floppy 136 | add byte [biosdrv], 126 137 | mov byte [qflag], 1 138 | .floppy:ret 139 | 140 | modmsg: mov al, [drive] 141 | add al, 'A' 142 | mov [minsnew + 33], al 143 | mov [mconfm + 16], al 144 | mov [label ], al 145 | ret 146 | 147 | asknew: test byte [aflag], 0xff 148 | jnz .nwait 149 | mov dx, minsnew 150 | test byte [biosdrv], 0x80 151 | jz .nhard 152 | mov dx, mconfm 153 | .nhard: mov ah, SSTROUT 154 | int DOSINT 155 | 156 | call waitkey 157 | .nwait: mov ah, SCHROUT 158 | mov dl, LF 159 | int DOSINT 160 | ret 161 | 162 | asknxt: test byte [biosdrv], 0x80 163 | jnz .xit 164 | test byte [aflag], 0xff 165 | jnz .xit 166 | call crlf 167 | .loop: mov dx, mnext 168 | mov ah, SSTROUT 169 | int DOSINT 170 | mov ah, SCHRINE 171 | int DOSINT 172 | call crlf 173 | cmp al, 'Y' 174 | je .fini 175 | cmp al, 'y' 176 | je .fini 177 | cmp al, 'N' 178 | je .fini 179 | cmp al, 'n' 180 | jne .loop 181 | .xit: int XITINT 182 | .fini: ret 183 | 184 | help: mov dx, mhelp 185 | mov ah, SSTROUT 186 | int DOSINT 187 | int XITINT 188 | 189 | diskrst:mov ah, SDSKRST 190 | int DOSINT 191 | ret 192 | 193 | ; get drive parameters 194 | getdprm:mov dl, [biosdrv] 195 | mov ah, 0x08 196 | int 0x13 197 | mov ax, cs 198 | mov es, ax 199 | mov ds, ax 200 | jc fail 201 | inc ch 202 | inc dh 203 | mov dl, cl 204 | rol dl, 1 205 | rol dl, 1 206 | and dl, 3 207 | mov byte [ncyl + 1], dl 208 | mov byte [ncyl], ch 209 | and cl, 0x3f 210 | mov [nsect], cl 211 | mov [nhead], dh 212 | ret 213 | 214 | ; set media type 215 | 216 | smtype: mov dl, [biosdrv] 217 | test dl, 0x80 218 | jnz .skip 219 | mov ch, byte [ncyl] 220 | mov cl, [nsect] 221 | dec ch 222 | mov ah, 0x18 223 | int 0x13 224 | .skip: ret 225 | 226 | format: cmp byte [qflag], 0 227 | je .dofmt 228 | ret 229 | 230 | .dofmt: mov byte [mwork + 18], '0' 231 | mov byte [mwork + 19], '0' 232 | mov byte [mwork + 27], '1' 233 | 234 | mov byte [curhead], 0 235 | mov word [curcyl ], 0 236 | 237 | .next: mov ah, SSTROUT 238 | mov dx, mwork 239 | int DOSINT 240 | 241 | mov ax, cs 242 | mov es, ax 243 | 244 | ; fill AFB 245 | 246 | mov dl, 1 247 | mov di, buf 248 | mov cl, [nsect] 249 | xor ch, ch 250 | .fafb: mov al, [curcyl] 251 | stosb 252 | 253 | mov al, [curhead] 254 | stosb 255 | 256 | mov al, dl 257 | inc dl 258 | stosb 259 | 260 | mov al, 2 261 | stosb 262 | loop .fafb 263 | 264 | ; format track 265 | 266 | call fmttrk 267 | jc .fail 268 | 269 | ; advance to the next track 270 | 271 | mov al, [nhead] 272 | add al, '1' 273 | inc byte [mwork + 27] 274 | cmp byte [mwork + 27], al 275 | jne .incch 276 | mov byte [mwork + 27], '1' 277 | inc byte [mwork + 19] 278 | cmp byte [mwork + 19], 58 279 | jne .incch 280 | mov byte [mwork + 19], '0' 281 | inc byte [mwork + 18] 282 | 283 | .incch: mov al, [nhead] 284 | mov bl, byte [ncyl] 285 | inc byte [curhead] 286 | cmp byte [curhead], al 287 | jb .next 288 | mov byte [curhead], 0 289 | inc word [curcyl] 290 | cmp byte [curcyl], bl ; XXX 291 | jb .next 292 | call clrlin 293 | ret 294 | .fail: call clrlin 295 | jmp fail 296 | 297 | initfs: mov dx, mwork2 298 | mov ah, SSTROUT 299 | int DOSINT 300 | 301 | mov ax, word [nsect] 302 | mov cx, word [nhead] 303 | mul cl 304 | mov cx, word [ncyl] 305 | mul cx 306 | mov word [totsec], ax 307 | 308 | mov cx, ax 309 | shl cx, 1 310 | add cx, ax 311 | 312 | add cx, 1023 313 | shr cx, 1 314 | shr cx, 1 315 | mov cl, ch 316 | xor ch, ch 317 | 318 | mov word [fatsz], cx 319 | 320 | ; XXX DOSBIOS uses a hardcoded BPB and ignores on-disk BPB 321 | ; update BPB and partition offset 322 | 323 | mov ah, 0x32 324 | mov dl, [drive] 325 | inc dl 326 | int DOSINT 327 | test al, al 328 | jnz .fail 329 | 330 | mov cl, [ds:bx + 0x04] ; Cluster size 331 | inc cl 332 | mov ax, [ds:bx + 0x06] ; Reserved sectors 333 | mov dl, [ds:bx + 0x08] ; Number of FATs 334 | mov si, [ds:bx + 0x09] ; Number of root dir entries 335 | mov dh, [ds:bx + 0x0f] ; Sectors per FAT 336 | 337 | push cs 338 | pop ds 339 | 340 | mov word [rsvds], ax 341 | mov byte [nfats], dl 342 | mov word [ndire], si 343 | mov byte [fatsz], dh 344 | mov byte [clusz], cl 345 | 346 | ; write the boot sector to disk 347 | 348 | call writeboot 349 | jc .fail 350 | 351 | mov cx, word [ndire] 352 | add cx, 15 353 | shr cx, 1 354 | shr cx, 1 355 | shr cx, 1 356 | shr cx, 1 357 | 358 | mov ax, word [fatsz] 359 | mov bl, byte [nfats] 360 | xor bh, bh 361 | mul bx 362 | add cx, ax 363 | 364 | add cx, word [rsvds] 365 | 366 | dec cx 367 | mov [sresid], cx 368 | mov byte [cursec], 1 369 | 370 | mov cx, SECT_SIZE 371 | mov di, buf 372 | xor al, al 373 | rep stosb 374 | 375 | mov word [buf ], 0xfff8 376 | mov byte [buf + 2], 0xff 377 | 378 | .clear: mov al, [drive] 379 | mov cx, 1 380 | mov dx, [cursec] 381 | mov bx, buf 382 | call dkwrite 383 | jc .fail 384 | 385 | mov word [buf ], 0 386 | mov byte [buf + 2], 0 387 | 388 | inc byte [cursec] 389 | dec word [sresid] 390 | cmp word [sresid], 0 391 | jne .clear 392 | 393 | mov ah, SSTROUT 394 | mov dx, mdone 395 | int DOSINT 396 | clc 397 | ret 398 | .fail: call clrlin 399 | jmp fail 400 | 401 | fail: mov ah, SSTROUT 402 | mov dx, mfail 403 | int DOSINT 404 | mov sp, 0x100 405 | jmp loop 406 | 407 | fmttrk1:mov al, [nsect] 408 | mov ch, [curcyl] 409 | mov dh, [curhead] 410 | mov dl, [biosdrv] 411 | mov bx, buf 412 | mov ah, 0x05 413 | int 0x13 414 | ret 415 | 416 | fmttrk: call fmttrk1 417 | jnc .fini 418 | call fmttrk1 419 | jnc .fini 420 | call fmttrk1 421 | jnc .fini 422 | cmp ah, 3 423 | je .wprot 424 | .fini: ret 425 | .wprot: call clrlin 426 | mov ah, SSTROUT 427 | mov dx, mwprot 428 | int DOSINT 429 | stc 430 | ret 431 | 432 | clrlin: mov ah, SCHROUT 433 | mov dl, CR 434 | int DOSINT 435 | mov dl, ' ' 436 | mov cx, 39 437 | .loop: int DOSINT 438 | loop .loop 439 | mov dl, CR 440 | int DOSINT 441 | ret 442 | 443 | dkwrite:push ax 444 | push bx 445 | push cx 446 | push dx 447 | push si 448 | push di 449 | push bp 450 | mov [dkwsp], sp 451 | int DKWINT 452 | mov sp, [dkwsp] 453 | pop bp 454 | pop di 455 | pop si 456 | pop dx 457 | pop cx 458 | pop bx 459 | pop ax 460 | ret 461 | 462 | writeboot: 463 | mov bx, bootsec 464 | mov al, [drive] 465 | mov cx, 1 466 | xor dx, dx 467 | jmp dkwrite 468 | 469 | modpath:mov al, [drive] 470 | add al, 'A' 471 | mov [biosnam], al 472 | mov [dosnam], al 473 | mov [comnam], al 474 | mov [chknam], al 475 | mov [edlnam], al 476 | mov [fxdnam], al 477 | mov [fmtnam], al 478 | mov [licnam], al 479 | mov [autnam], al 480 | mov [auto + 18], al 481 | ret 482 | 483 | loadsys:cmp byte [sflag], 0 484 | je .fini 485 | 486 | mov ax, 0x3305 487 | int DOSINT 488 | add dl, '@' 489 | mov [biosnam], dl 490 | mov [dosnam], dl 491 | mov [comnam], dl 492 | mov [chknam], dl 493 | mov [edlnam], dl 494 | mov [fxdnam], dl 495 | mov [fmtnam], dl 496 | mov [licnam], dl 497 | mov [autnam], dl 498 | mov [auto + 18], dl 499 | 500 | mov dx, biosnam 501 | mov di, ebss 502 | call loadfile 503 | mov [bioptr], di 504 | mov [biosiz], cx 505 | add di, cx 506 | 507 | mov dx, dosnam 508 | call loadfile 509 | mov [dosptr], di 510 | mov [dossiz], cx 511 | add di, cx 512 | 513 | mov dx, comnam 514 | call loadfile 515 | mov [comptr], di 516 | mov [comsiz], cx 517 | add di, cx 518 | 519 | cmp byte [mflag], 0 520 | je .fini 521 | 522 | mov dx, chknam 523 | call loadfile 524 | mov [chkptr], di 525 | mov [chksiz], cx 526 | add di, cx 527 | 528 | mov dx, edlnam 529 | call loadfile 530 | mov [edlptr], di 531 | mov [edlsiz], cx 532 | add di, cx 533 | 534 | mov dx, fxdnam 535 | call loadfile 536 | mov [fxdptr], di 537 | mov [fxdsiz], cx 538 | add di, cx 539 | 540 | mov dx, fmtnam 541 | call loadfile 542 | mov [fmtptr], di 543 | mov [fmtsiz], cx 544 | add di, cx 545 | 546 | mov dx, licnam 547 | call loadfile 548 | mov [licptr], di 549 | mov [licsiz], cx 550 | add di, cx 551 | 552 | .fini: ret 553 | 554 | savesys:cmp byte [sflag], 0 555 | je .fini 556 | 557 | mov dx, biosnam 558 | mov di, [bioptr] 559 | mov bl, [sysattr] 560 | mov cx, [biosiz] 561 | call savefile 562 | 563 | mov dx, dosnam 564 | mov di, [dosptr] 565 | mov bl, [sysattr] 566 | mov cx, [dossiz] 567 | call savefile 568 | 569 | mov dx, comnam 570 | mov di, [comptr] 571 | mov bl, 0x20 572 | mov cx, [comsiz] 573 | call savefile 574 | 575 | cmp byte [mflag], 0 576 | je .fini 577 | 578 | mov dx, chknam 579 | mov di, [chkptr] 580 | mov bl, 0x20 581 | mov cx, [chksiz] 582 | call savefile 583 | 584 | mov dx, edlnam 585 | mov di, [edlptr] 586 | mov bl, 0x20 587 | mov cx, [edlsiz] 588 | call savefile 589 | 590 | mov dx, fxdnam 591 | mov di, [fxdptr] 592 | mov bl, 0x20 593 | mov cx, [fxdsiz] 594 | call savefile 595 | 596 | mov dx, fmtnam 597 | mov di, [fmtptr] 598 | mov bl, 0x20 599 | mov cx, [fmtsiz] 600 | call savefile 601 | 602 | mov dx, licnam 603 | mov di, [licptr] 604 | mov bl, 0x20 605 | mov cx, [licsiz] 606 | call savefile 607 | 608 | mov dx, autnam 609 | mov di, auto 610 | mov bl, 0x20 611 | mov cx, endauto - auto 612 | call savefile 613 | 614 | .fini: ret 615 | 616 | waitkey:mov dx, manykey 617 | mov ah, SSTROUT 618 | int DOSINT 619 | mov ah, SCHRINN 620 | int DOSINT 621 | call crlf 622 | .fini: ret 623 | 624 | setlabel: 625 | test [aflag], byte 1 626 | jnz .fini 627 | 628 | ; prompt the user and input the label 629 | 630 | .again: mov dx, mlabel 631 | mov ah, SSTROUT 632 | int DOSINT 633 | mov ah, SSTRIN 634 | mov dx, .buf 635 | int DOSINT 636 | call crlf 637 | 638 | mov cl, [.len] 639 | xor ch, ch 640 | test cx, cx 641 | jz .fini 642 | mov di, label + 3 643 | mov si, .buf + 2 644 | cmp cx, 8 645 | jg .long 646 | rep movsb 647 | .nterm: xor al, al 648 | stosb 649 | 650 | ; XXX probably should use the FCB API 651 | ; create the label 652 | 653 | mov dx, label 654 | mov cx, 8 655 | mov ah, 0x3c 656 | int DOSINT 657 | jnc .fini 658 | cmp ax, 2 659 | jne .badlab 660 | .fini: ret 661 | .long: mov bx, cx 662 | mov cx, 8 663 | rep movsb 664 | mov al, '.' 665 | stosb 666 | mov cx, bx 667 | sub cx, 8 668 | rep movsb 669 | jmp .nterm 670 | .badlab:mov dx, mbadlab 671 | mov ah, SSTROUT 672 | int DOSINT 673 | jmp .again 674 | .buf: db 12 675 | .len: db 0 676 | resb 12 677 | 678 | label: db "A:\" 679 | resb 13 680 | 681 | baddrv: mov dx, mbaddrv 682 | mov ah, SSTROUT 683 | int DOSINT 684 | int XITINT 685 | 686 | crlf: push ax 687 | push dx 688 | mov ah, SCHROUT 689 | mov dl, CR 690 | int DOSINT 691 | mov ah, SCHROUT 692 | mov dl, LF 693 | int DOSINT 694 | pop dx 695 | pop ax 696 | ret 697 | 698 | mhelp db CR, LF 699 | db "System disk options:", CR, LF, LF 700 | db " /V Make IO.SYS and MSDOS.SYS visible", CR, LF 701 | db " /M Create an extended system disk", CR, LF 702 | db " /S Create a system disk", CR, LF 703 | db LF 704 | db "Format options:", CR, LF, LF 705 | db " /A Automatic mode (no prompts)", CR, LF 706 | db " /Q Quick format", CR, LF 707 | db "$" 708 | 709 | minsnew db CR, LF, "Insert NEW diskette into drive A", CR, LF, "$" 710 | mconfm db CR, LF, "Data in drive A will be lost!", CR, LF, "$" 711 | mwprot db "Disk write-protected", CR, LF, "$" 712 | mnext db CR, "Format another disk (Y/N)? $" 713 | mwork db CR, "Formatting track XX, side X ... $" 714 | mwork2 db CR, "Formatting ... $" 715 | mdone db CR, "Format complete", CR, LF, "$" 716 | mfail db CR, "Format failed", CR, LF, "$" 717 | msys db "Transferring DOS ... $" 718 | msdone db CR, "DOS transferred ", CR, LF, "$" 719 | manykey db "Strike any key when ready ... $" 720 | mbaddrv db "Invalid drive specification", CR, LF, "$" 721 | mbadsw db "Invalid switch: /$", CR, LF, "$" 722 | mbadlab db "Invalid label", CR, LF, "$" 723 | mlabel db "Volume label: $" 724 | mcrlf db CR, LF, "$" 725 | 726 | bootsec incbin "boot/boot.com" 727 | 728 | auto db "PROMPT $P$G", CR, LF 729 | db "PATH A:\", CR, LF 730 | endauto: 731 | 732 | sysattr db 0x07 733 | ncyl dw 80 734 | 735 | biosnam:db "A:\IO.SYS", 0 736 | dosnam: db "A:\MSDOS.SYS", 0 737 | comnam: db "A:\COMMAND.COM", 0 738 | chknam: db "A:\CHKDSK.COM", 0 739 | edlnam: db "A:\EDLIN.COM", 0 740 | fxdnam: db "A:\FDISK.COM", 0 741 | fmtnam: db "A:\FORMAT.COM", 0 742 | licnam: db "A:\LICENSE.COM", 0 743 | autnam: db "A:\AUTOEXEC.BAT", 0 744 | edata: 745 | 746 | section .bss 747 | sbss: 748 | 749 | bioptr resw 1 750 | dosptr resw 1 751 | comptr resw 1 752 | chkptr resw 1 753 | edlptr resw 1 754 | fxdptr resw 1 755 | fmtptr resw 1 756 | licptr resw 1 757 | 758 | biosiz resw 1 759 | dossiz resw 1 760 | comsiz resw 1 761 | chksiz resw 1 762 | edlsiz resw 1 763 | fxdsiz resw 1 764 | fmtsiz resw 1 765 | licsiz resw 1 766 | 767 | dkwsp resw 1 768 | 769 | drive resb 1 770 | biosdrv resb 1 771 | 772 | curcyl resb 1 773 | curhead resb 1 774 | 775 | cursec resw 1 776 | sresid resw 1 777 | 778 | sflag resb 1 779 | qflag resb 1 780 | aflag resb 1 781 | mflag resb 1 782 | 783 | buf: resb 512 784 | 785 | ebss: 786 | -------------------------------------------------------------------------------- /util/license.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | %include "util/chkver.asm" 29 | 30 | main: mov dx, menu 31 | mov ah, SSTROUT 32 | int DOSINT 33 | 34 | mov ah, SCHRINE 35 | int DOSINT 36 | 37 | cmp al, '1' 38 | je showdos 39 | cmp al, '2' 40 | je showbio 41 | cmp al, '3' 42 | je showfil 43 | cmp al, 'q' 44 | je exit 45 | cmp al, 27 46 | je exit 47 | 48 | mov ah, SCHROUT 49 | mov dl, 7 50 | jmp main 51 | 52 | exit: mov ah, SCHROUT 53 | mov dl, LF 54 | int DOSINT 55 | 56 | mov ah, SSTROUT 57 | mov dx, mexit 58 | int DOSINT 59 | int XITINT 60 | 61 | showdos:mov dx, mit 62 | jmp show 63 | 64 | showbio:mov dx, bsd 65 | jmp show 66 | 67 | showfil:mov dx, fil 68 | jmp show 69 | 70 | show: mov ah, SSTROUT 71 | int DOSINT 72 | 73 | mov ah, SCHRINN 74 | int DOSINT 75 | 76 | jmp main 77 | 78 | mit: db 0x1b, "[2J" 79 | incbin "dostxt/license.dos" 80 | db "$" 81 | 82 | bsd: db 0x1b, "[2J" 83 | incbin "dostxt/license.bio" 84 | db "$" 85 | 86 | fil: db 0x1b, "[2J" 87 | db "File information", CR, LF 88 | db "================", CR, LF, LF 89 | 90 | db " The following files contain Microsoft code:", CR, LF, LF 91 | db " IO SYS MSDOS SYS", CR, LF, LF 92 | db " COMMAND COM COMMAND OLD CHKDSK COM DEBUG COM DISKCOPY COM", CR, LF 93 | db " EDLIN COM FC EXE MODE COM MORE COM PRINT COM", CR, LF 94 | db " RECOVER COM CREF EXE EXE2BIN EXE LINK EXE MASM EXE", CR, LF 95 | db " SETUP COM", CR, LF, LF 96 | 97 | db " The following files contain DOSBIOS code:", CR, LF, LF 98 | db " IO SYS ATTRIB COM COMMAND COM EGAMODE COM FORMAT COM", CR, LF 99 | db " FDISK COM COLORBAR COM LICENSE COM MEM COM REBOOT COM", CR, LF 100 | db " REVEAL COM SETCOLOR COM SETMEM COM SETUP COM", CR, LF, LF 101 | 102 | db " The following files contain both Microsoft and DOSBIOS code:", CR, LF, LF 103 | db " IO SYS COMMAND COM FORMAT COM SETUP COM", CR, LF, LF 104 | 105 | db "Strike any key to return to the main menu ... $" 106 | end: 107 | 108 | menu: db 0x1b, "[2J" 109 | db "Licensing information", CR, LF 110 | db "=====================", CR, LF, LF 111 | db " 1. MS-DOS license", CR, LF 112 | db " 2. DOSBIOS license", CR, LF 113 | db " 3. File information", CR, LF, LF 114 | db "Enter choice or press ESC to exit: $" 115 | 116 | mexit: db 0x1b, "[2J$" 117 | -------------------------------------------------------------------------------- /util/loadfile.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | loadfile: 28 | mov ax, 0x3d00 29 | mov cx, bx 30 | int DOSINT 31 | jc .error 32 | mov bx, ax 33 | 34 | mov ah, 0x3f 35 | mov cx, 0xffff 36 | mov dx, di 37 | int DOSINT 38 | jc .error 39 | mov cx, ax 40 | 41 | mov ah, 0x3e 42 | int DOSINT 43 | jc .error 44 | 45 | ret 46 | 47 | .error mov dx, .errmsg 48 | mov ah, SSTROUT 49 | int DOSINT 50 | int XITINT ; XXX 51 | 52 | .errmsg db 0x0d, "Cannot transfer operating system", 0x0d, 0x0a, "$" 53 | -------------------------------------------------------------------------------- /util/mem.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | %include "bios/prhex.asm" 29 | 30 | main: call getsw 31 | 32 | mov ax, [2] 33 | mov bx, cs 34 | sub ax, bx 35 | mov cl, 6 36 | shr ax, cl 37 | 38 | mov dl, 100 39 | div dl 40 | 41 | mov [mfree1 + 0], al 42 | mov al, ah 43 | xor ah, ah 44 | mov dl, 10 45 | div dl 46 | mov [mfree1 + 1], al 47 | mov [mfree1 + 2], ah 48 | 49 | add byte [mfree1 + 0], '0' 50 | add byte [mfree1 + 1], '0' 51 | add byte [mfree1 + 2], '0' 52 | 53 | mov si, mfree1 54 | call clrlz 55 | 56 | mov dx, mfree1 57 | mov ah, SSTROUT 58 | int DOSINT 59 | 60 | ret 61 | 62 | clrlz: cld 63 | lodsb 64 | cmp al, '0' 65 | jne .fini 66 | mov byte [si - 1], ' ' 67 | jmp clrlz 68 | .fini: ret 69 | 70 | getsw: mov cl, [0x80] 71 | xor ch, ch 72 | mov di, 0x81 73 | mov al, '/' 74 | cld 75 | .getsw: repne scasb 76 | cmp cx, 0 77 | jne .gotsw 78 | ret 79 | .gotsw: mov bl, [di] 80 | cmp bl, '?' 81 | je help 82 | cmp bl, 'd' 83 | je mcbdump 84 | cmp bl, 'D' 85 | je mcbdump 86 | 87 | mov dx, mbadsw 88 | mov ah, SSTROUT 89 | int DOSINT 90 | mov ah, SCHROUT 91 | mov dl, bl 92 | int DOSINT 93 | mov dx, mcrlf 94 | mov ah, SSTROUT 95 | int DOSINT 96 | int XITINT 97 | 98 | mcbdump:mov dx, header 99 | mov ah, 0x09 100 | int 0x21 101 | 102 | mov ah, 0x52 103 | int 0x21 104 | 105 | mov bx, [es:bx - 2] 106 | mov ds, bx 107 | 108 | next: mov ax, ds 109 | inc ax 110 | call phex 111 | mov al, 32 112 | call chrout 113 | 114 | mov ax, [0x01] 115 | test ax, ax 116 | jnz powner 117 | 118 | mov dx, mfree 119 | mov ah, 0x09 120 | int 0x21 121 | jmp psize 122 | 123 | powner: call phex 124 | mov al, 32 125 | call chrout 126 | 127 | psize: mov ax, [0x03] 128 | call phex 129 | 130 | mov al, 13 131 | call chrout 132 | mov al, 10 133 | call chrout 134 | 135 | cmp byte [0x00], 'Z' 136 | jz fini 137 | 138 | add bx, [0x03] 139 | inc bx 140 | mov ds, bx 141 | jmp next 142 | fini: int XITINT 143 | 144 | chrout: push ax 145 | push dx 146 | mov ah, 0x02 147 | mov dl, al 148 | int 0x21 149 | pop dx 150 | pop ax 151 | ret 152 | 153 | help: mov dx, mhelp 154 | mov ah, SSTROUT 155 | int DOSINT 156 | int XITINT 157 | 158 | header: db 13, 10 159 | db "MCB chain dump", 13, 10, 10 160 | db "BASE OWNR SIZE ", 13, 10 161 | db "---- ---- ---- ", 13, 10, "$" 162 | 163 | mbadsw db "Invalid switch: /$", CR, LF, "$" 164 | mfree: db " $" 165 | mcrlf: db CR, LF, "$" 166 | mfree1: db "000K bytes free", CR, LF, "$" 167 | 168 | mhelp: db CR, LF 169 | db "Command-line switches:", CR, LF, LF 170 | db " /D Produce MCB chain dump", CR, LF 171 | db "$" 172 | -------------------------------------------------------------------------------- /util/oemdefs.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | OGETVER equ 0xffff 28 | OGETSCRATTR equ 0xff00 29 | OCLRSCR equ 0xff01 30 | -------------------------------------------------------------------------------- /util/reboot.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | 29 | main: int 0x19 30 | -------------------------------------------------------------------------------- /util/reveal.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | 29 | main: ; NUL-terminate the command line tail 30 | 31 | call getsw 32 | mov dx, bx 33 | 34 | ; get current attributes 35 | 36 | mov ax, 0x4300 37 | int DOSINT 38 | jc fail 39 | 40 | ; set new attibutes 41 | 42 | mov ax, 0x4301 43 | and cx, [mask] 44 | or cx, [set] 45 | int DOSINT 46 | jc fail 47 | int XITINT 48 | 49 | fail: mov ah, SSTROUT 50 | mov dx, .msg 51 | int DOSINT 52 | int XITINT 53 | .msg: db "Invalid path or file not found", 13, 10, "$" 54 | 55 | getsw: mov bl, [0x80] 56 | xor bh, bh 57 | add bx, 0x81 58 | xor al, al 59 | mov [bx], al 60 | mov bx, 0x81 61 | .loop: cmp word [bx], '/H' 62 | je .hide 63 | cmp word [bx], '/h' 64 | je .hide 65 | cmp word [bx], '/S' 66 | je .system 67 | cmp word [bx], '/s' 68 | je .system 69 | cmp word [bx], '/R' 70 | je .rdonly 71 | cmp word [bx], '/r' 72 | je .rdonly 73 | cmp word [bx], '/?' 74 | je .help 75 | cmp byte [bx], ' ' 76 | je .skip1 77 | ret 78 | .hide: mov word [mask], 0xffff 79 | mov word [set ], 0x0002 80 | jmp .skip2 81 | .system:mov word [mask], 0xffff 82 | mov word [set ], 0x0007 83 | jmp .skip2 84 | .rdonly:mov word [mask], 0xffff 85 | mov word [set ], 0x0001 86 | jmp .skip2 87 | .help: mov ah, SSTROUT 88 | mov dx, mhelp 89 | int DOSINT 90 | int XITINT 91 | .skip2: inc bx 92 | .skip1: inc bx 93 | jmp .loop 94 | 95 | mhelp: db CR, LF 96 | db "Command-line options:", CR, LF, LF 97 | db " /H Hide the file instead of revealing", CR, LF 98 | db " /S Set the system file attribs (RHS)", CR, LF 99 | db " /R Set the file read-only", CR, LF 100 | db "$" 101 | 102 | mask: dw 0x0020 103 | set: dw 0x0000 104 | -------------------------------------------------------------------------------- /util/savefile.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | savefile: 28 | push cx 29 | mov ah, 0x3c 30 | mov cx, bx 31 | int DOSINT 32 | jc .error 33 | mov bx, ax 34 | pop cx 35 | 36 | mov ah, 0x40 37 | mov dx, di 38 | int DOSINT 39 | jc .error 40 | mov cx, ax 41 | 42 | push cx 43 | push dx 44 | mov ax, 0x5701 45 | mov cx, RELTIME 46 | mov dx, RELDATE 47 | int DOSINT 48 | jc .error 49 | pop dx 50 | pop cx 51 | 52 | mov ah, 0x3e 53 | int DOSINT 54 | jc .error 55 | 56 | ret 57 | 58 | .error mov dx, .errmsg 59 | mov ah, SSTROUT 60 | int DOSINT 61 | int XITINT ; XXX 62 | 63 | .errmsg db 0x0d, "Cannot transfer operating system", 0x0d, 0x0a, "$" 64 | -------------------------------------------------------------------------------- /util/setcolor.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | %include "util/chkver.asm" 29 | 30 | main: call chkver 31 | call chkmode 32 | 33 | cmp byte [0x80], 0 34 | je defclr 35 | 36 | cmp byte [0x80], 3 37 | jne fail 38 | 39 | cmp word [0x82], '/?' 40 | je help 41 | 42 | mov si, 0x82 43 | cld 44 | call digit 45 | call digit 46 | 47 | test bl, bl 48 | jz fail 49 | 50 | set: call updscr 51 | call updtab 52 | int XITINT 53 | 54 | defclr: mov bl, 0x1f 55 | jmp set 56 | 57 | updtab: mov ax, OGETSCRATTR 58 | int DOSINT 59 | int3 60 | mov ds, ax 61 | mov es, ax 62 | mov si, dx 63 | .loop: lodsb 64 | test al, al 65 | jz .next 66 | mov [si - 1], bl 67 | .next: loop .loop 68 | ret 69 | 70 | updscr: mov ax, 0xb800 ; XXX hardcoded segment 71 | mov cx, 0x1000 72 | mov ds, ax 73 | mov es, ax 74 | xor si, si 75 | xor di, di 76 | loop: lodsw 77 | mov ah, bl 78 | stosw 79 | loop loop 80 | ret 81 | 82 | digit: lodsb 83 | cmp al, '0' 84 | jl fail 85 | cmp al, 'a' 86 | jge .lower 87 | cmp al, 'A' 88 | jge .upper 89 | cmp al, '9' 90 | jg fail 91 | sub al, '0' 92 | .fini: mov cl, 4 93 | shl bl, cl 94 | or bl, al 95 | ret 96 | .lower: cmp al, 'f' 97 | jg fail 98 | sub al, 'a' - 10 99 | jmp .fini 100 | .upper: cmp al, 'F' 101 | jg fail 102 | sub al, 'A' - 10 103 | jmp .fini 104 | 105 | chkmode:mov ah, 0x0f 106 | int 0x10 107 | cmp al, 0x07 108 | jne .fini 109 | mov ah, SSTROUT 110 | mov dx, .msg 111 | int DOSINT 112 | int XITINT 113 | .fini: ret 114 | .msg: db "Invalid display mode", CR, LF, "$" 115 | 116 | fail: mov ah, SSTROUT 117 | mov dx, .msg 118 | int DOSINT 119 | int XITINT 120 | .msg: db "Bad or missing parameter", CR, LF, "$" 121 | 122 | help: mov ah, SSTROUT 123 | mov dx, .msg 124 | int DOSINT 125 | int XITINT 126 | .msg: db CR, LF 127 | db "Usage: SETCOLOR [BF]", CR, LF, LF 128 | db " B Background color (0-7)", CR, LF 129 | db " F Foreground color (0-F)", CR, LF 130 | db "$" 131 | -------------------------------------------------------------------------------- /util/setmem.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | 29 | main: mov cl, [0x80] 30 | xor ch, ch 31 | mov si, 0x81 32 | cld 33 | loop: lodsb 34 | cmp al, '0' 35 | jl next 36 | cmp al, '9' 37 | jg next 38 | sub al, '0' 39 | mov bl, al 40 | 41 | mov ax, [memsz] 42 | mov dx, 10 43 | mul dx 44 | xor bh, bh 45 | add ax, bx 46 | mov [memsz], ax 47 | 48 | next: loopnz loop 49 | 50 | mov bx, [memsz] 51 | cmp bx, 32 52 | jl badsz 53 | 54 | xor ax, ax 55 | mov ds, ax 56 | mov word [0x413], bx 57 | int 0x19 58 | 59 | badsz: mov ah, SSTROUT 60 | mov dx, mbadsz 61 | int DOSINT 62 | int XITINT 63 | 64 | memsz: dw 0 65 | 66 | mbadsz: db "Invalid memory size specification", CR, LF, "$" 67 | -------------------------------------------------------------------------------- /util/setup.asm: -------------------------------------------------------------------------------- 1 | ; Copyright (c) Piotr Durlej 2 | ; All rights reserved. 3 | ; 4 | ; Redistribution and use in source and binary forms, with or without 5 | ; modification, are permitted provided that the following conditions are met: 6 | ; 7 | ; 1. Redistributions of source code must retain the above copyright notice, 8 | ; this list of conditions and the following disclaimer. 9 | ; 10 | ; 2. Redistributions in binary form must reproduce the above copyright 11 | ; notice, this list of conditions and the following disclaimer in the 12 | ; documentation and/or other materials provided with the distribution. 13 | ; 14 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | ; POSSIBILITY OF SUCH DAMAGE. 25 | ; 26 | 27 | %include "util/dosutil.asm" 28 | 29 | main: mov [fmtpb + 4], cs 30 | mov [fmtpb + 8], cs 31 | mov [fmtpb + 12], cs 32 | 33 | call chkver 34 | call chkpart 35 | 36 | mov ah, 0x4a 37 | mov bx, 0x1000 38 | int DOSINT 39 | 40 | mov ax, 0x4b00 41 | mov dx, fmtnam 42 | mov bx, fmtpb 43 | int DOSINT 44 | jc nofmt 45 | 46 | mov ah, 0x4d 47 | int DOSINT 48 | test ax, ax 49 | jnz xit 50 | 51 | mov ax, cs 52 | mov ds, ax 53 | mov es, ax 54 | mov ss, ax 55 | mov sp, 0x100 56 | 57 | mov ah, 0x41 58 | mov dx, auto 59 | int DOSINT 60 | 61 | mov dx, dirnam 62 | mov ah, 0x39 63 | int DOSINT 64 | 65 | mov dx, mcopy 66 | mov ah, SSTROUT 67 | int DOSINT 68 | 69 | mov si, f0 70 | 71 | next: cmp byte [si], 0 72 | jz endcp 73 | 74 | cld 75 | mov dx, si 76 | xor al, al 77 | mov di, si 78 | mov cx, -1 79 | repne scasb 80 | mov si, di 81 | lodsw 82 | mov cx, ax 83 | mov bl, 0x20 84 | mov di, si 85 | call savefile 86 | 87 | add si, cx 88 | jmp next 89 | 90 | endcp: mov dx, setnam 91 | mov di, 0x100 92 | mov bl, 0x20 93 | mov cx, end - 0x100 94 | call savefile 95 | 96 | mov dx, mdone 97 | mov ah, SSTROUT 98 | int DOSINT 99 | 100 | xit: int XITINT 101 | 102 | nofmt: mov dx, mnofmt 103 | mov ah, SSTROUT 104 | int DOSINT 105 | int XITINT 106 | 107 | chkpart:mov al, 2 108 | mov cx, 1 109 | mov dx, 1 110 | mov bx, end 111 | int 0x25 112 | jc .fail 113 | popf 114 | ret 115 | .fail: mov dx, mnopart 116 | mov ah, SSTROUT 117 | int DOSINT 118 | int XITINT 119 | 120 | %include "util/savefile.asm" 121 | %include "util/chkver.asm" 122 | 123 | f0: db "C:\DOS\ATTRIB.COM", 0 124 | dw f1 - $ - 2 125 | incbin "util/attrib.com" 126 | 127 | f1: db "C:\DOS\CHKDSK.COM", 0 128 | dw f2 - $ - 2 129 | incbin "msdos/chkdsk.com" 130 | 131 | f2: db "C:\DOS\COLORBAR.COM", 0 132 | dw f3 - $ - 2 133 | incbin "util/colorbar.com" 134 | 135 | f3: db "C:\DOS\DEBUG.COM", 0 136 | dw f4 - $ - 2 137 | incbin "msdos/debug.com" 138 | 139 | f4: db "C:\DOS\DISKCOPY.COM", 0 140 | dw f5 - $ - 2 141 | incbin "msdos/diskcopy.com" 142 | 143 | f5: db "C:\DOS\EDLIN.COM", 0 144 | dw f6 - $ - 2 145 | incbin "msdos/edlin.com" 146 | 147 | f6: db "C:\DOS\EGAMODE.COM", 0 148 | dw f7 - $ - 2 149 | incbin "util/egamode.com" 150 | 151 | f7: db "C:\DOS\FC.EXE", 0 152 | dw f8 - $ - 2 153 | incbin "msdos/fc.exe" 154 | 155 | f8: db "C:\DOS\FDISK.COM", 0 156 | dw f9 - $ - 2 157 | incbin "util/fdisk.com" 158 | 159 | f9: db "C:\DOS\FORMAT.COM", 0 160 | dw f10 - $ - 2 161 | incbin "util/format.com" 162 | 163 | f10: db "C:\DOS\FIND.EXE", 0 164 | dw f11 - $ - 2 165 | incbin "msdos/find.exe" 166 | 167 | f11: db "C:\DOS\MEM.COM", 0 168 | dw f12 - $ - 2 169 | incbin "util/mem.com" 170 | 171 | f12: db "C:\DOS\MODE.COM", 0 172 | dw f13 - $ - 2 173 | incbin "msdos1/mode.com" 174 | 175 | f13: db "C:\DOS\MORE.COM", 0 176 | dw f14 - $ - 2 177 | incbin "msdos/more.com" 178 | 179 | f14: db "C:\DOS\PRINT.COM", 0 180 | dw f15 - $ - 2 181 | incbin "msdos/print.com" 182 | 183 | f15: db "C:\DOS\RECOVER.COM", 0 184 | dw f16 - $ - 2 185 | incbin "msdos/recover.com" 186 | 187 | f16: db "C:\DOS\REVEAL.COM", 0 188 | dw f17 - $ - 2 189 | incbin "util/reveal.com" 190 | 191 | f17: db "C:\DOS\SETCOLOR.COM", 0 192 | dw f18 - $ - 2 193 | incbin "util/setcolor.com" 194 | 195 | f18: db "C:\DOS\LICENSE.COM", 0 196 | dw f19 - $ - 2 197 | incbin "util/license.com" 198 | 199 | auto: 200 | f19: db "C:\AUTOEXEC.BAT", 0 201 | dw f20 - $ - 2 202 | db "PATH C:\DOS", CR, LF 203 | db "PROMPT $P$G", CR, LF 204 | 205 | f20: db 0 206 | 207 | dirnam: db "C:\DOS", 0 208 | setnam: db "C:\DOS\SETUP.COM", 0 209 | 210 | mcopy: db "Copying files ... $" 211 | mdone: db "done", CR, LF, "$" 212 | mnofmt: db "Missing FORMAT.COM in current directory", CR, LF, "$" 213 | mnopart:db "Missing DOS partition", CR, LF, "$" 214 | 215 | fmtnam: db "FORMAT.COM", 0 216 | fmtpb: dw 0 ; environ seg 217 | dw fmtarg, 0 ; command tail 218 | dw fmtfcb, 0 ; first fcb 219 | dw fmtfcb, 0 ; second fcb 220 | fmtarg: db 6, " /M", CR 221 | fmtfcb: db 3 ; drive number - C: 222 | db "12345678ABC" 223 | resb 24 224 | 225 | end: 226 | --------------------------------------------------------------------------------