Skip to content

Commit 7b51f4c

Browse files
Save a few bytes
1 parent 5861713 commit 7b51f4c

3 files changed

Lines changed: 33 additions & 36 deletions

File tree

list.s

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,13 @@ list_statement:
103103
bne @try_unary_operator
104104
jsr decode_byte ; Get the function number
105105
tay
106-
bmi @ex_function ; It's an extension function
107-
ldax #function_name_table
108-
bne @got_func_table
109-
@ex_function:
110-
tya
106+
bpl @not_ex_function ; Standard function
111107
and #$7F
112108
tay
113109
ldax #ex_function_name_table
110+
bne @got_func_table ; Unconditional
111+
@not_ex_function:
112+
ldax #function_name_table
114113
@got_func_table:
115114
jsr expand_tokenized_name ; Call directly becuase we don't want to add whitespace after
116115
jmp @next

parser.s

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,17 @@ return_carry:
270270
pla
271271
rts
272272

273+
; ARGSEP: skip over argument separator ','
274+
275+
op_argsep:
276+
ldy buffer_pos
277+
jsr read_argument_separator
278+
bcs op_fail
279+
sty buffer_pos
280+
lda #','
281+
jsr write_to_line_buffer
282+
jmp next_pvm
283+
273284
; WS: skip over whitespace
274285

275286
op_ws:
@@ -306,19 +317,6 @@ compose_with_last_byte:
306317
sta line_buffer-1,x
307318
rts
308319

309-
; ARGSEP: skip over argument separator ','
310-
311-
op_argsep:
312-
ldy buffer_pos
313-
jsr read_argument_separator
314-
bcc @found
315-
jmp op_fail
316-
@found:
317-
sty buffer_pos
318-
lda #','
319-
jsr write_to_line_buffer
320-
jmp next_pvm
321-
322320
; Write a single byte to line_buffer, checking for the maximum line length.
323321
; X SAFE, BC SAFE, DE SAFE
324322

program.s

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ reset_data_2:
6060
mva #.sizeof(Line) + 2, data_line_pos ; Skip 1 for DATA, 1 for next statement offset
6161
rts
6262

63+
; Advances next_line_ptr to the next line.
64+
; next_line_ptr = current next line (updated)
65+
; X SAFE, BC SAFE, DE SAFE
66+
67+
advance_next_line_ptr:
68+
ldy #Line::next_line_offset
69+
lda (next_line_ptr),y ; Get next line offset into A
70+
clc
71+
adc next_line_ptr ; Add line length to low byte of next_line_ptr
72+
sta next_line_ptr ; Save back
73+
bcc set_next_line_pos ; Don't need to change the high byte
74+
inc next_line_ptr+1 ; Increment the high byte
75+
76+
set_next_line_pos:
77+
mvy #.sizeof(Line), next_line_pos
78+
rts
79+
6380
; Sets next_line_ptr to program_ptr. Does not change the run state.
6481
; Returns next_line_ptr in AX.
6582
; BC SAFE, DE SAFE
@@ -68,8 +85,7 @@ reset_next_line_ptr:
6885
ldax program_ptr
6986
reset_next_line_ptr_2:
7087
stax next_line_ptr
71-
mvy #.sizeof(Line), next_line_pos
72-
rts
88+
bne set_next_line_pos ; Unconditional: stax doesn't affect flags, ldax sets Z from high byte
7389

7490
; Builds a null line at the location passed in AX. The null line has line number -1 and a length of zero.
7591
; The zero length prevents advance_next_line_ptr from advancing past the line.
@@ -131,22 +147,6 @@ compare_next_line_to_target:
131147
@done:
132148
rts
133149

134-
; Advances next_line_ptr to the next line.
135-
; next_line_ptr = current next line (updated)
136-
; X SAFE, BC SAFE, DE SAFE
137-
138-
advance_next_line_ptr:
139-
ldy #Line::next_line_offset
140-
lda (next_line_ptr),y ; Get next line offset into A
141-
clc
142-
adc next_line_ptr ; Add line length to low byte of next_line_ptr
143-
sta next_line_ptr ; Save back
144-
bcc @skip ; Don't need to change the high byte
145-
inc next_line_ptr+1 ; Increment the high byte
146-
@skip:
147-
mvy #.sizeof(Line), next_line_pos
148-
rts
149-
150150
; Updates the program based on the information in line_buffer.
151151
; If the line number in line_buffer is in the program, remove it.
152152
; If line_buffer contains a new line, then insert it into the program.

0 commit comments

Comments
 (0)