Skip to content

Commit da3750f

Browse files
committed
Factor puts and putsn into their own files
1 parent d08ae29 commit da3750f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

text-io/put.dasm

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
;#include "text-io.dasm"
2+
3+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4+
;; puts (needs base screen routines)
5+
6+
; writes a null-terminated string to the current
7+
; position.
8+
:puts
9+
IFE [A], 0
10+
SET PC, POP
11+
SET PUSH, A
12+
SET A, [A]
13+
JSR putc
14+
SET A, POP
15+
ADD A, 1
16+
SET PC, puts ; tail call
17+
18+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19+
;; putsn (needs base screen routines)
20+
21+
;; void putsn(char *src, char len)
22+
; writes a string of length n to the current
23+
; position. It is useful for printing a prefix of
24+
; a string or for pascal strings.
25+
:putsn
26+
IFE B, 0
27+
SET PC, POP
28+
SET PUSH, J
29+
SET PUSH, I
30+
SET J, A
31+
SET I, A
32+
ADD I, B
33+
:putsn_loop
34+
SET A, [I]
35+
JSR putc
36+
ADD I, 1
37+
IFN I, J
38+
SET PC, putsn_loop
39+
SET I, POP
40+
SET J, POP
41+
SET PC, POP

0 commit comments

Comments
 (0)