diff --git a/src/actions.asm b/src/actions.asm index 9f8785b..7253c40 100644 --- a/src/actions.asm +++ b/src/actions.asm @@ -41,7 +41,7 @@ .import alloc_laddr .importzp prog_ptr, laddr_ptr, laddr_buf, var_ptr, label_ptr ; From parser.asm - .import parser_error, parser_skipws + .import parser_error, parser_skipws, parser_emit_byte .importzp TOK_CSTRING ; From error.asm .importzp ERR_LOOP @@ -141,15 +141,10 @@ ok: rts ; ; Emits 16bit AX into codep .proc emit_AX - ldy opos -new_y: sta (prog_ptr),y - txa - iny - sta (prog_ptr),y - iny - sty opos clc - rts + jsr parser_emit_byte + txa + jmp parser_emit_byte .endproc ; Parser external subs @@ -286,9 +281,7 @@ nloop: ; Store store: inx inc bpos - ldy opos - sta (prog_ptr),y - inc opos + jsr parser_emit_byte bne nloop err: ; Restore opos and exit lda tmp1 @@ -379,9 +372,7 @@ exit: .proc emit_varn ; Store VARN txa - ldy opos - sta (prog_ptr),y - inc opos + jsr parser_emit_byte ; Fall through .endproc ; Advances variable name in source pointer diff --git a/src/errors.asm b/src/errors.asm index d48f002..47a5d0d 100644 --- a/src/errors.asm +++ b/src/errors.asm @@ -34,7 +34,8 @@ error_msg_list: .endrepeat .byte .strat(msg, .strlen(msg)-1) ^ $80 .endmacro - def_error ERR_LOOP, "bad loop error" + def_error ERR_TOO_LONG, "too long" + def_error ERR_LOOP, "bad loop" def_error ERR_PARSE, "parse error" def_error ERR_NO_ELOOP, "no end loop/proc/if" def_error ERR_LABEL, "undef label" diff --git a/src/parse.asm b/src/parse.asm index 5bf289f..cb415b2 100644 --- a/src/parse.asm +++ b/src/parse.asm @@ -19,7 +19,7 @@ ; Parser state machine interpreter ; -------------------------------- - .export parser_start, parser_error, parser_skipws + .export parser_start, parser_error, parser_skipws, parser_emit_byte ; Parser state .exportzp bptr, bpos, bmax, linenum, buf_ptr, end_ptr .exportzp loop_sp @@ -42,7 +42,7 @@ .importzp DEGFLAG, DEGFLAG_DEG, DEGFLAG_RAD ; From errors.asm .import error_msg_list - .importzp ERR_PARSE, ERR_NO_ELOOP, ERR_LABEL + .importzp ERR_PARSE, ERR_NO_ELOOP, ERR_LABEL, ERR_TOO_LONG .zeropage buf_ptr:.res 2 @@ -96,6 +96,17 @@ SM_EMIT= SM_EMIT_1 ; Now, the rest of the code .code +emit_sub: + jsr parser_fetch +emit_const: +parser_emit_byte: + ldy opos + sta (prog_ptr),y + inc opos + bne rts1 + lda #ERR_TOO_LONG + ; Fall through + .proc parser_error ; Prints error message tax @@ -116,7 +127,7 @@ skip: bpl ploop ::restore_stack: ldx #$ff txs - rts +::rts1: rts .endproc saved_stack = restore_stack + 1 @@ -393,12 +404,4 @@ set_parse_error: lda #ERR_PARSE jmp parser_error -emit_sub: - jsr parser_fetch -emit_const: - ldy opos - sta (prog_ptr),y - inc opos - rts - ; vi:syntax=asm_ca65