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
1013bits 16
1114code16_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
139155mov si , cx
140156shl si , 6
141157add 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; -----------------------------------------------------------------------------
0 commit comments