diff --git a/src/basic/engine_editor/tk_pack.s b/src/basic/engine_editor/tk_pack.s index 25c9cae9..56d3db31 100644 --- a/src/basic/engine_editor/tk_pack.s +++ b/src/basic/engine_editor/tk_pack.s @@ -144,7 +144,7 @@ tk_pack_loop_next: cmp #TK__MAX_KEYWORD_LEN beq !+ // if max length reached - quit - // Check for characters that can only end the token + // Check for characters that can only end the keyword lda BUF-1, x cmp #$41 diff --git a/src/basic/engine_runtime/injest_assign.s b/src/basic/engine_runtime/injest_assign.s index efc9bea0..56456299 100644 --- a/src/basic/engine_runtime/injest_assign.s +++ b/src/basic/engine_runtime/injest_assign.s @@ -3,7 +3,7 @@ // #LAYOUT# * * #IGNORE // -// Consummes assign operator in a BASIC code, Carry set if not found. Injests all spaces. +// Consummes assign operator in a BASIC code, triggers error if not found // @@ -11,19 +11,6 @@ injest_assign: jsr fetch_character_skip_spaces cmp #$B2 // assign operator character - beq injest_assign_found - - // Not found -#if !HAS_OPCODES_65CE02 - jsr unconsume_character -#else - dew TXTPTR -#endif + bne_16 do_SYNTAX_error - sec - rts - -injest_assign_found: - - clc rts diff --git a/src/basic/engine_variables/array_create.s b/src/basic/engine_variables/array_create.s index b8fc146a..15a0f982 100644 --- a/src/basic/engine_variables/array_create.s +++ b/src/basic/engine_variables/array_create.s @@ -47,15 +47,10 @@ array_create_fetch_dims_loop: inx - // Check if the stack has reasonable space free - - jsr check_stack_space - // Fetch the dimension, increment it by 1, and put it on the stack; // confirmed with original ROM, that it also stores dimensions in the reverse order - jsr fetch_uint16 - bcs_16 do_SYNTAX_error + jsr helper_fetch_arr_coord #if !HAS_OPCODES_65CE02 inc LINNUM+0 @@ -75,11 +70,8 @@ array_create_fetch_dims_loop: // Check if more dimensions are given - jsr fetch_character_skip_spaces - cmp #$2C // ',' + cpy #$00 beq array_create_fetch_dims_loop - cmp #$29 // ')' - bne_16 do_SYNTAX_error // FALLTROUGH diff --git a/src/basic/engine_variables/assign_variable.s b/src/basic/engine_variables/assign_variable.s index 0328ee66..fdf4fb72 100644 --- a/src/basic/engine_variables/assign_variable.s +++ b/src/basic/engine_variables/assign_variable.s @@ -5,26 +5,35 @@ assign_variable: - // Fetch variable name, should be followed by assign operator + // Fetch variable/array name jsr fetch_variable_name - -#if HAS_OPCODES_65CE02 - - bcs_16 do_SYNTAX_error - jsr injest_assign bcs_16 do_SYNTAX_error -#else - - bcs !+ jsr injest_assign - bcc !++ -!: - jmp do_SYNTAX_error -!: -#endif + // Check for array + + lda DIMFLG + bpl assign_variable_not_array + + // Retrieve all the dimensions + + // XXX implement this + + jmp do_NOT_IMPLEMENTED_error + + // Fetch assignment operator and continue + + jsr injest_assign + + jmp_8 assign_variable_common + +assign_variable_not_array: + + // Require assignment operator + + jsr injest_assign // Check for special variables @@ -37,8 +46,14 @@ assign_variable: jsr is_var_ST beq_16 do_SYNTAX_error - // Push the VARNAM to the stack - it might get overridden + // FALLTROUGH +assign_variable_common: + + // Push the DIMFLG and VARNAM to the stack - it might get overridden + + lda DIMFLG + pha lda VARNAM+0 pha lda VARNAM+1 @@ -48,15 +63,18 @@ assign_variable: jsr FRMEVL - // Restore VARNAM + // Restore VARNAM and DIMFLG pla sta VARNAM+1 pla sta VARNAM+0 + pla + sta DIMFLG // XXX is it needed? + + // XXX add array handling here // Retrieve the variable address - // XXX add support for arrays jsr fetch_variable_find_addr diff --git a/src/basic/engine_variables/fetch_variable_arr.s b/src/basic/engine_variables/fetch_variable_arr.s index 8c17b36e..32a2ae10 100644 --- a/src/basic/engine_variables/fetch_variable_arr.s +++ b/src/basic/engine_variables/fetch_variable_arr.s @@ -27,27 +27,19 @@ fetch_variable_arr_fetch_coords_loop: inx - // Check if the stack has reasonable space free + // Fetch the coordinate and put it on the stack - jsr check_stack_space - - // Fetch the dimension and put it on the stack - - jsr fetch_uint16 - bcs_16 do_SYNTAX_error + jsr helper_fetch_arr_coord lda LINNUM+0 pha lda LINNUM+1 pha - // Check if more dimensions are given + // If more coordinates given - next iteration - jsr fetch_character_skip_spaces - cmp #$2C // ',' + cpy #$00 beq fetch_variable_arr_fetch_coords_loop - cmp #$29 // ')' - bne_16 do_SYNTAX_error // FALLTROUGH diff --git a/src/basic/engine_variables/helper_fetch_arr_coord.s b/src/basic/engine_variables/helper_fetch_arr_coord.s new file mode 100644 index 00000000..6329fbde --- /dev/null +++ b/src/basic/engine_variables/helper_fetch_arr_coord.s @@ -0,0 +1,42 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// +// Helper routine for fetching array coordinates +// +// If this was last coordinate, set .Y to $FF, otherwise to $00 +// + +helper_fetch_arr_coord: + + // Check if the stack has reasonable space free + + jsr check_stack_space + + // Fetch the dimension + + jsr fetch_uint16 + bcs !+ + + jsr fetch_character_skip_spaces + cmp #$2C // ',' + beq helper_fetch_arr_more + cmp #$29 // ')' + beq helper_fetch_arr_last + + // FALLTROUGH + +!: + + jmp do_SYNTAX_error + +helper_fetch_arr_more: + + ldy #$00 + rts + +helper_fetch_arr_last: + + ldy #$FF + rts