diff --git a/src/aliases/,aliases_ram_lowmem.s b/src/aliases/,aliases_ram_lowmem.s index 5cdbda36..d673f7bc 100644 --- a/src/aliases/,aliases_ram_lowmem.s +++ b/src/aliases/,aliases_ram_lowmem.s @@ -47,7 +47,7 @@ .label DATPTR = $41 // $41-$42 pointer for READ/DATA copmmands .label INPPTR = $43 // $43-$44 -- NOT IMPLEMENTED -- .label VARNAM = $45 // $45-$46 current variable name - .label VARPNT = $47 // $47-$48 -- NOT IMPLEMENTED -- + .label VARPNT = $47 // $47-$48 current variable/descriptor pointer .label FORPNT = $49 // $49-$4A -- NOT IMPLEMENTED -- .label OPPTR = $4B // $4B-$4C helper variable for expression computation, [!] our usage details are different .label OPMASK = $4D // -- NOT IMPLEMENTED -- diff --git a/src/basic/basic_commands/cmd_let.s b/src/basic/basic_commands/cmd_let.s index 7150e9af..2482dfdb 100644 --- a/src/basic/basic_commands/cmd_let.s +++ b/src/basic/basic_commands/cmd_let.s @@ -12,6 +12,73 @@ cmd_let: jsr injest_assign bcs_16 do_SYNTAX_error + // Determine variable type and push it to the stack + + lda #$00 + clc + bit VARNAM+0 + bpl !+ + adc #$01 +!: + bit VARNAM+1 + bpl !+ + adc #$80 +!: + pha + + // Push the VARPNT to the stack - it might get overridden + + lda VARPNT+0 + pha + lda VARPNT+1 + pha + + // Evaluate the expression + + jsr FRMEVL + + // Restore VARPNT + + pla + sta VARPNT+1 + pla + sta VARPNT+0 + + // Determine what to assign + + pla + bmi cmd_let_assign_string + beq cmd_let_assign_float + + // FALLTROUGH + + // XXX integer and float probably have much in common + +cmd_let_assign_integer: + + lda VALTYP + bmi_16 do_TYPE_MISMATCH_error + + // XXX finish the implementation + + jmp do_NOT_IMPLEMENTED_error + +cmd_let_assign_float: + + lda VALTYP + bmi_16 do_TYPE_MISMATCH_error + + // XXX finish the implementation + + jmp do_NOT_IMPLEMENTED_error + +cmd_let_assign_string: + + // Check if value type matches + + lda VALTYP + bpl_16 do_TYPE_MISMATCH_error + // XXX finish the implementation jmp do_NOT_IMPLEMENTED_error diff --git a/src/basic/engine/fetch_variable.s b/src/basic/engine/fetch_variable.s index ce3e2430..9397711d 100644 --- a/src/basic/engine/fetch_variable.s +++ b/src/basic/engine/fetch_variable.s @@ -77,8 +77,135 @@ fetch_variable_type_string: fetch_variable_find_addr: - // Now try to find variable address + // Now try to find variable address between VARTAB and ARYTAB, see + // - https://www.c64-wiki.com/wiki/Memory_(BASIC) + + lda VARTAB+0 + sta VARPNT+0 + lda VARTAB+1 + sta VARPNT+1 + + // FALLTROUGH + +fetch_variable_find_addr_loop: + + // Check if end of search loop + + lda VARPNT+1 + cmp ARYTAB+1 + bne !+ + lda VARPNT+0 + cmp VARPNT+0 + beq fetch_variable_alocate +!: + // Compare current variable name with searched one + // XXX consider creating optimized version for 46K/50K memory models + + ldy #$00 + +#if CONFIG_MEMORY_MODEL_60K + ldx #