diff --git a/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt b/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt index 859e833b8..4f9f29b82 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen2/AsmGen2.kt @@ -1786,7 +1786,7 @@ $endLabel""") DataType.BYTE -> { when(expr.type) { DataType.UBYTE, DataType.BYTE -> {} - DataType.UWORD, DataType.WORD -> out(" lda $ESTACK_HI_PLUS1_HEX,x | ${signExtendAtoMsb("$ESTACK_HI_PLUS1_HEX,x")}") + DataType.UWORD, DataType.WORD -> out(" lda $ESTACK_LO_PLUS1_HEX,x | ${signExtendAtoMsb("$ESTACK_HI_PLUS1_HEX,x")}") DataType.FLOAT -> out(" jsr c64flt.stack_b2float") in PassByReferenceDatatypes -> throw AssemblyError("cannot cast to a pass-by-reference datatype") else -> throw AssemblyError("weird type") diff --git a/examples/test.p8 b/examples/test.p8 index faa00d46d..9790c8f10 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,43 +1,21 @@ -%import c64utils %import c64lib -%import c64flt -%zeropage dontuse - +%import c64utils main { sub start() { - word[] warr = [1111, 2222, 3333, 4444] - byte[] barr = [11, 22, 33, 44] + for ubyte ax in 0 to 255 { + word wcosa = cos8(ax) as word + word wsina = sin8(ax) as word - word ww = 9999 - byte bb = 99 - - c64scr.print_b(barr[2]) - c64.CHROUT('\n') - - barr[2] = 55 - c64scr.print_b(barr[2]) - c64.CHROUT('\n') - - barr[2] = bb - c64scr.print_b(barr[2]) - c64.CHROUT('\n') - - @($0400+72) = X - - c64scr.print_w(warr[2]) - c64.CHROUT('\n') - - warr[2] = 5555 - c64scr.print_w(warr[2]) - c64.CHROUT('\n') - - warr[2] = ww - c64scr.print_w(warr[2]) - c64.CHROUT('\n') - - @($0400+73) = X + c64scr.print_ub(ax) + c64.CHROUT(':') + c64.CHROUT(' ') + c64scr.print_w(wcosa) + c64.CHROUT(',') + c64scr.print_w(wsina) + c64.CHROUT('\n') + } } }