Skip to content

Commit fa071af

Browse files
committed
update: get command line from DOS Console
1 parent 2f161c2 commit fa071af

File tree

10 files changed

+323
-31
lines changed

10 files changed

+323
-31
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,9 @@ packed.zip
104104
nasm.exe
105105
upx.exe
106106
src/_internal/shared/dosupx.exe
107+
src/_internal/shared/KERNEL.BIN
108+
src/_internal/shared/KERNEL.BIN
109+
src/_internal/shared/start.exe
110+
src/_internal/shared/start.bin
111+
src/_internal/shared/ne.exe
112+
src/_internal/shared/dos.exe

src/_internal/shared/KERNEL.BIN

68 Bytes
Binary file not shown.

src/_internal/shared/bss16.asm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ bss16_start:
1111
; -----------------------------------------------------------------------------
1212
; \brief hold DOS command line argument information's ...
1313
; -----------------------------------------------------------------------------
14-
struc COMMAND_LINE
14+
%define MAX_ARGS 7
15+
struc _cA_COMMAND_LINE
1516
.arg_count resb 1 ; max. 255 arguments
1617
.arg_str resb 64 ; max. length = 64 bytes
1718
endstruc
18-
command_args: resb COMMAND_LINE_size * 7
19+
_cA_command_args: resb 64 * MAX_ARGS
20+
_cA_command_arglen: resb 64
21+
arg_total: resb 1
1922

20-
_cA_cmd_buf: resb 130 ; max. 127 + '$' + Reserve
23+
_cA_cmd_buf: resb 256 ; CMD string
2124
_cA_cmd_buffer: resb 130
2225

2326
fdescbuf: resb 4096

src/_internal/shared/code16.asm

Lines changed: 77 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
; \desc Create a dBASE MS-Windows 11 64-bit Pro EXE.
77
; -----------------------------------------------------------------------------
88
%define DOS_SHELL 1
9-
9+
%define MAX_ARGS 7
10+
%macro CMD_LINE 1-*
11+
;COMMAND_LINE_%1
12+
%endmacro
1013
bits 16
1114
code16_start:
15+
xor ax, ax
1216
mov si, 81h ; SI -> Beginn der Kommandozeile im PSP
1317
mov cl, [80h] ; CL = Länge
1418
xor ch, ch ; CX = Länge
@@ -18,12 +22,15 @@ code16_start:
1822
mov di, PTR16(_cA_cmd_buf) ; DI -> Ziel
1923
.copy:
2024
lodsb ; AL = [DS:SI], SI++
21-
cmp al, 0Dh ; CR markiert das Ende (Sicherheit)
25+
cmp al, 0x0D ; CR markiert das Ende (Sicherheit)
2226
je .done_copy
2327
stosb ; [ES:DI]=AL (ES=DS in .COM), DI++
2428
loop .copy
2529

2630
.done_copy:
31+
mov al, 0
32+
stosb
33+
2734
; Trim: nachlaufende Spaces entfernen
2835
.trim:
2936
cmp di, PTR16(_cA_cmd_buf)
@@ -34,7 +41,7 @@ code16_start:
3441
inc di
3542

3643
.make_dos_str:
37-
mov byte [di], 0x00 ; für DOS-Funktion 09h Stringabschluss
44+
mov byte [di], 0 ; für DOS-Funktion 09h Stringabschluss
3845
jmp .next
3946
4047
.no_args:
@@ -45,8 +52,6 @@ code16_start:
4552
DOS_Exit 0 ; exit - no args.
4653
4754
.next:
48-
STRLEN cmd_buf
49-
5055
READL_CON_A dos_buffer
5156
5257
SCREEN_CLEAR
@@ -68,7 +73,7 @@ code16_start:
6873
6974
SET_CURSOR 20, 7
7075
PUTS_COLOR DBFNAME, 0x0E
71-
;DOS_Exit 0
76+
; DOS_Exit 0
7277

7378
; -----------------------------------------------------------------------------
7479
; dbfmake.asm - Create/Append field into dBASE III/IV DBF by INT 21h
@@ -83,12 +88,6 @@ code16_start:
8388
; Feldname: max 10 Zeichen (dBASE-Beschränkung, 11. Byte = 0)
8489
; Feldlaenge: Dezimal (z.B. 20)
8590
; -----------------------------------------------------------------------------
86-
;call next_token
87-
;mov ah, 09h
88-
;int 21h
89-
;lea dx, [PTR16(cmd_buf)]
90-
;mov ah, 09h
91-
;int 21h
9291
9392
SET_CURSOR 40, 7
9493
PUTS_COLOR cmd_buf, 0x0E | 0x10
@@ -99,27 +98,44 @@ code16_start:
9998
; C:\start.exe 123 abc
10099
; --------------------------------------
101100
lea si, [PTR16(_cA_cmd_buf)]
102-
lea bx, [PTR16(_cA_cmd_buffer)]
101+
lea bx, [PTR16(_cA_command_args)+1]
102+
xor cx, cx ; reset counter
103103
.next_input:
104104
lodsb
105-
cmp al, ' '
106-
je .next_input
107-
cmp al, 0x00
108-
je .end_input
109-
mov [bx], byte al
110-
inc bx
111-
jmp .next_input
105+
cmp al, ' ' ; whitespace ?
106+
je .end_input ; yes, next argument
107+
108+
cmp al, 0x0d ; read line DOS end ?
109+
je .end_input ; yes, exit loop
110+
cmp al, 0x00 ; sanity check EOL ?
111+
je .end_input ; yes, exit loop
112+
113+
.check_arg_len:
114+
cmp cx, 32 ; max. arg len reached ?
115+
je .end_input ; yes, then exit loop
116+
inc cx ; else, increment arg num.
117+
118+
mov [bx], byte al ; append readed char to bx
119+
inc bx ; increment array
120+
jmp .next_input ; get next character
112121
113122
.end_input:
123+
mov [bx], byte 0 ; 0 string terminator
124+
cmp al, ' ' ; yes, argument ?
125+
je .next_input
126+
127+
dec cx ; == args - 1
128+
cmp cx, 0 ; no arguments ?
129+
je .no_args ; yes, exit loop/application
114130
115131
SET_CURSOR 40, 5
116-
PUTS_COLOR cmd_buffer, 0x0E | 0x10
132+
PUTS_COLOR command_args, 0x0E | 0x10
133+
DOS_Exit cx
117134
118-
DOS_Exit 0
119135

120136
; -----------------------------------------------------------------
121137
; BX = Basis of Array
122-
mov bx, command_args
138+
mov bx, _cA_command_args
123139

124140
; size in powers of 2 (4,8,16) -> shift
125141
; e.g.: COMMAND_LINE_size = 65 -> *6 = << 6
@@ -139,8 +155,9 @@ mov bx, command_args
139155
mov si, cx
140156
shl si, 6
141157
add si, cx
142-
mov byte [bx + si + COMMAND_LINE.arg_str], 'A'
158+
mov byte [bx + si + _cA_COMMAND_LINE.arg_str], 'A'
143159

160+
DOS_Exit 0
144161
; -----------------------------------------------------------------
145162
jmp .token_done
146163
@@ -1494,6 +1511,42 @@ dos_screen_clear:
14941511
14951512
ret
14961513

1514+
; ------------------------------------------------------------
1515+
; Hilfsroutine: ein Zeichen an aktuelles arg_str anhängen,
1516+
; maximal 63 Nutzzeichen. Bei Overflow werden
1517+
; zusätzliche Zeichen bis zum nächsten Separator
1518+
; verworfen (wir schreiben einfach nicht mehr).
1519+
; IN:
1520+
; AL = Zeichen
1521+
; DI = Schreibzeiger (zeigt immer auf nächste freie Stelle)
1522+
; CX = aktuelle Länge (0..63)
1523+
; OUT:
1524+
; DI/CX aktualisiert
1525+
; Zerstört: nichts weiter (AX benutzt)
1526+
; ------------------------------------------------------------
1527+
put_char_maybe:
1528+
cmp cx, 63
1529+
jae .skip_write
1530+
stosb ; [DI] = AL, DI++
1531+
inc cx
1532+
ret
1533+
.skip_write:
1534+
; Zeichen verwerfen (nichts schreiben)
1535+
ret
1536+
1537+
; DS:SI -> ASCIIZ
1538+
print_z0:
1539+
.loop:
1540+
lodsb
1541+
test al, al
1542+
jz .done
1543+
mov dl, al
1544+
mov ah, 02h
1545+
int 21h
1546+
jmp .loop
1547+
.done:
1548+
ret
1549+
14971550
; -----------------------------------------------------------------------------
14981551
; \brief include DOS 16-bit stdlib function's ...
14991552
; -----------------------------------------------------------------------------

src/_internal/shared/dos.exe

0 Bytes
Binary file not shown.

src/_internal/shared/doshdr.inc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ end_dos_header equ ($ - dos_start)
3636

3737
; Reloc-Tabelle (leer), aber im Headerbereich!
3838
mz_reloc: ; == 0x40
39-
39+
40+
;---------------------------------------------------
41+
; DOS 16 bit stub
42+
;---------------------------------------------------
4043
align 16 ; <-- sicherstellen, dass mz_image auf Absatzgrenze startet
4144
mz_image:
4245

4346
; ---- 16-bit Stub-Entry bei e_cs:e_ip = 0:0 (ab mz_image)
4447
stub_entry:
4548
incbin 'kernel.bin'
4649

47-
align 16
50+
;---------------------------------------------------
51+
; Windows 3.1 16 bit stub
52+
;---------------------------------------------------
53+
;align 16
54+
;%include 'win16NEhdr.inc'
55+
4856
stub_end:

src/_internal/shared/start.bin

0 Bytes
Binary file not shown.

src/_internal/shared/start.exe

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)