diff options
author | Jacques Comeaux <jacquesrcomeaux@gmail.com> | 2022-09-14 13:24:50 -0500 |
---|---|---|
committer | Jacques Comeaux <jacquesrcomeaux@gmail.com> | 2022-09-14 13:24:50 -0500 |
commit | 2b0ee06f48c923254e92d9418dafc466b6a5a197 (patch) | |
tree | 4445d06d40e60d53e4bbc645fffcfbe7b73f38c1 | |
parent | 52d8cf7782b1eb4ce07b5e7daa5bd4ca88b17f0e (diff) |
Fix print bugs
-rw-r--r-- | print.s | 67 |
1 files changed, 36 insertions, 31 deletions
@@ -1,51 +1,56 @@ print: 004000 012705 MOV #6000, R5 ; store print buffer address in R5 004002 006000 -004004 032700 BIT #1, R0 ; test if sexp is cons or atom +004004 032710 BIT #1, (R0) ; test if sexp is cons or atom 004006 000001 004010 001003 BNE 6 -004012 004727 JSR PC, #handle_cons -004014 004100 -004016 000402 BR 4 -004020 004727 JSR PC, #handle_atom -004022 004200 -004024 012725 MOV #"\n\0", (R5)+ ; move newline and null byte into print buffer -004026 000012 -004030 000127 JMP #print_buffer -004032 004300 +004012 112725 MOVB #"(", (R5)+ ; if cons output open paren +004014 000050 +004016 004737 JSR PC, #handle_cons +004020 004100 +004022 000402 BR 4 +004024 004737 JSR PC, #handle_atom +004026 004200 +004030 012725 MOV #"\n\0", (R5)+ ; move newline and null byte into print buffer +004032 000012 +004034 000137 JMP #print_buffer +004036 004300 handle_cons: 004100 016046 MOV 2(R0), -(SP) ; push cdr onto stack 004102 000002 004104 011000 MOV @R0, R0 ; traverse to car -004106 032700 BIT #1, R0 ; test if car is cons or atom +004106 032710 BIT #1, (R0) ; test if car is cons or atom 004110 000001 004112 001005 BNE 12 004114 112725 MOVB #"(", (R5)+ ; if cons output open paren 004116 000050 -004120 004727 JSR PC, #handle_cons ; recurse +004120 004737 JSR PC, #handle_cons ; recurse 004122 004100 004124 000402 BR 4 -004126 004727 JSR PC, #handle_atom ; if atom output atom +004126 004737 JSR PC, #handle_atom ; if atom output atom 004130 004200 004132 012600 MOV (SP)+, R0 ; pop cdr from stack -004134 032700 BIT #1, R0 ; test if cdr is cons or atom -004136 001005 BNE 12 -004140 112725 MOVB #" ", (R5)+ ; if cons output space -004142 000040 -004144 004727 JSR PC, #handle_cons ; recurse -004156 004100 -004150 000402 BR 4 -004152 112725 MOVB #")", (R5)+ ; if atom output close paren -004154 000051 -004156 000207 RTS PC +004134 032710 BIT #1, (R0) ; test if cdr is cons or atom +004136 000001 +004140 001005 BNE 12 +004142 112725 MOVB #" ", (R5)+ ; if cons output space +004144 000040 +004146 004737 JSR PC, #handle_cons ; recurse +004150 004100 +004152 000402 BR 4 +004154 112725 MOVB #")", (R5)+ ; if atom output close paren +004156 000051 +004160 000207 RTS PC handle_atom: -004200 000401 BR 2 ; -004202 110125 MOVB R1, (R5)+ ; move char to print buffer -004204 112001 MOVB (R0)+, R1 ; get next byte -004206 001372 BNE -6 ; if not null continue -004210 000207 RTS PC ; +004200 011000 MOV @R0, R0 ; +004202 005300 DEC R0 ; get string address +004204 000401 BR 2 ; +004206 110125 MOVB R1, (R5)+ ; move char to print buffer +004210 112001 MOVB (R0)+, R1 ; get next byte +004212 001375 BNE -6 ; if not null continue +004214 000207 RTS PC ; print_buffer: 004300 012705 MOV #6000, R5 ; restore print buffer pointer @@ -53,10 +58,10 @@ print_buffer: 004304 000404 BR 12 004306 105737 TSTB @#177564 ; test if console ready 004310 177564 -004312 001772 BEQ -6 ; loop while not ready +004312 001775 BEQ -6 ; loop while not ready 004314 110137 MOVB R1, @#177566 ; send char to console 004316 177566 004320 112501 MOVB (R5)+, R1 ; get next byte -004322 001362 BNE -16 ; if not null continue -004324 000127 JMP #read (002000) +004322 001371 BNE -14 ; if not null continue +004324 000137 JMP #read (002000) 004326 002000 |