Stephen D 8 months ago
parent
commit
e990193e06
3 changed files with 115 additions and 18 deletions
  1. 40 17
      boot.asm
  2. 25 0
      print.asm
  3. 50 1
      string.asm

+ 40 - 17
boot.asm

@ -70,6 +70,22 @@ loop:
70 70
	%include "print.asm"
71 71
	%include "disk.asm"
72 72
	
73
;//CMD_BUFFER:	times 64 db 0 		;63 char buffer for command
74
CMD_BUFFER_POS:	dw 0
75
CURSOR_H:	db 0				;Not used for now
76
CURSOR_W:	db 0
77
	
78
STARTUP:	db "Starting Steve16...", 0xA, 0xD,
79
	db "READY.", 0xA, 0xD, 0
80
81
	times 510-($-$$) db 0
82
	dw 0xaa55
83
84
	;; SECTOR 2 & 3
85
	%include "string.asm"
86
	%include "textedit.asm"
87
	%include "memtest.asm"
88
73 89
kb_bs:
74 90
	cmp [CMD_BUFFER_POS], byte 0 ;Ignore the backspace if CMD_BUFFER is empty
75 91
	je loop
@ -164,6 +180,11 @@ cmd:
164 180
	cmp cl, 1
165 181
	je cmd_memtest
166 182
183
	mov dx, CMD_STRSPLIT_STR
184
	call strcmp
185
	cmp cl, 1
186
	je cmd_strsplit
187
167 188
	;; don't print unknown command message if cmd is empty
168 189
	cmp [CMD_BUFFER_POS], byte 0
169 190
	je clear_cmd_buffer
@ -179,23 +200,6 @@ cmd_memtest:
179 200
	call memtest_init
180 201
	popa
181 202
	jmp clear_cmd_buffer
182
	
183
	
184
;//CMD_BUFFER:	times 64 db 0 		;63 char buffer for command
185
CMD_BUFFER_POS:	dw 0
186
CURSOR_H:	db 0				;Not used for now
187
CURSOR_W:	db 0
188
	
189
STARTUP:	db "Starting Steve16...", 0xA, 0xD,
190
	db "READY.", 0xA, 0xD, 0
191
192
	times 510-($-$$) db 0
193
	dw 0xaa55
194
195
	;; SECTOR 2 & 3
196
	%include "string.asm"
197
	%include "textedit.asm"
198
	%include "memtest.asm"
199 203
200 204
clear_cmd_buffer:	
201 205
	mov [CMD_BUFFER_POS], byte 0
@ -215,10 +219,29 @@ cmd_clear:
215 219
	int 0x10
216 220
	jmp clear_cmd_buffer
217 221
222
cmd_strsplit:
223
	mov bx, STRSPLIT_TEST_STR
224
	call print					;print starting string
225
	
226
	mov al, ' '
227
	mov dx, STRSPLIT_TEST_OUTPUT
228
	call strsplit
229
230
	;; print out the new strings
231
	mov bx, STRSPLIT_TEST_OUTPUT
232
	mov al, ','
233
	call print_array
234
	
235
	jmp clear_cmd_buffer
236
218 237
CMD_MEMTEST_STR:	 db "MEMTEST", 0
219 238
CMD_SEDIT_STR: db "SEDIT", 0
220 239
CMD_HELP_STR:  db "HELP", 0
221 240
CMD_CLEAR_STR: db "CLEAR", 0
241
CMD_STRSPLIT_STR:	db "STRSP", 0
242
243
STRSPLIT_TEST_STR:	db "this is a test string", 0
244
STRSPLIT_TEST_OUTPUT:	times 16 dw 0 ;16 element 2-byte array
222 245
	
223 246
RTN_HELP_STR:
224 247
	db "Steve16 v0.1", 0xA, 0xD

+ 25 - 0
print.asm

@ -78,3 +78,28 @@ print_char:
78 78
	int 0x10
79 79
	popa
80 80
	ret
81
82
	;; Prints an array of strings
83
	;; bx - array of pointers to strings
84
	;; al - char to print out between strings
85
print_array:
86
	pusha
87
print_array_cont:
88
	cmp [bx], word 0
89
	je print_array_done
90
91
	push bx
92
	mov bx, [bx]
93
	call print
94
	pop bx
95
	
96
	;; al is already set
97
	call print_char
98
99
	add bx, 2
100
	jmp print_array_cont
101
	
102
103
print_array_done:
104
	popa
105
	ret

+ 50 - 1
string.asm

@ -22,8 +22,57 @@ strdif:							;strings are different
22 22
	mov cl, 0
23 23
	ret
24 24
25
26 25
strsame:
27 26
	popa
28 27
	mov cl, 1
29 28
	ret
29
30
31
32
	;; input(string pointer) in bx
33
	;; input(delimeter) in al
34
	;; input(points to array of pointers) in dx (output)
35
strsplit:
36
	pusha
37
38
	;; put start of string in dx array
39
	mov cx, bx
40
	mov bx, dx
41
	mov [bx], cx
42
	mov bx, cx
43
	add dx, 2
44
	inc bx
45
	
46
	mov cx, bx					;points to beginning of next "section"
47
strsplit_loop:
48
	cmp [bx], byte 0
49
	je strsplit_done
50
51
	cmp [bx], al
52
	je strsplit_match
53
54
	add bx, 1					;inc pointer
55
	jmp strsplit_loop
56
57
strsplit_match:					;delimeter found
58
	mov [bx], byte 0					;replaces delimeter w/ null char
59
	
60
	push bx
61
	mov cx, bx
62
	
63
	mov bx, dx
64
65
	inc cx
66
	mov [bx], cx 
67
68
	pop bx
69
70
	inc bx
71
	add dx, 2
72
73
	jmp strsplit_loop
74
	
75
76
strsplit_done:
77
	popa
78
	ret