diff --git a/compiler/res/prog8lib/prog8lib.asm b/compiler/res/prog8lib/prog8lib.asm index f69e10787..d3ce14af5 100644 --- a/compiler/res/prog8lib/prog8lib.asm +++ b/compiler/res/prog8lib/prog8lib.asm @@ -1810,19 +1810,81 @@ lsl_array_w .proc .pend lsr_array_ub .proc - .warn "lsr_array_ub" ; TODO + ; -- lsr a ubyte in an array (index and array address on stack) + inx + ldy c64.ESTACK_LO,x + inx + lda c64.ESTACK_LO,x + sta c64.SCRATCH_ZPWORD1 + lda c64.ESTACK_HI,x + sta c64.SCRATCH_ZPWORD1+1 + lda (c64.SCRATCH_ZPWORD1),y + lsr a + sta (c64.SCRATCH_ZPWORD1),y + rts .pend lsr_array_b .proc - .warn "lsr_array_b" ; TODO + ; -- lsr a byte in an array (index and array address on stack) + inx + ldy c64.ESTACK_LO,x + inx + lda c64.ESTACK_LO,x + sta c64.SCRATCH_ZPWORD1 + lda c64.ESTACK_HI,x + sta c64.SCRATCH_ZPWORD1+1 + lda (c64.SCRATCH_ZPWORD1),y + asl a + lda (c64.SCRATCH_ZPWORD1),y + ror a + sta (c64.SCRATCH_ZPWORD1),y + rts .pend lsr_array_uw .proc - .warn "lsr_array_uw" ; TODO + ; -- lsr a uword in an array (index and array address on stack) + inx + lda c64.ESTACK_LO,x + asl a + tay + inx + lda c64.ESTACK_LO,x + sta c64.SCRATCH_ZPWORD1 + lda c64.ESTACK_HI,x + sta c64.SCRATCH_ZPWORD1+1 + iny + lda (c64.SCRATCH_ZPWORD1),y + lsr a + sta (c64.SCRATCH_ZPWORD1),y + dey + lda (c64.SCRATCH_ZPWORD1),y + ror a + sta (c64.SCRATCH_ZPWORD1),y + rts .pend lsr_array_w .proc - .warn "lsr_array_w" ; TODO + ; -- lsr a uword in an array (index and array address on stack) + inx + lda c64.ESTACK_LO,x + asl a + tay + inx + lda c64.ESTACK_LO,x + sta c64.SCRATCH_ZPWORD1 + lda c64.ESTACK_HI,x + sta c64.SCRATCH_ZPWORD1+1 + iny + lda (c64.SCRATCH_ZPWORD1),y + asl a + lda (c64.SCRATCH_ZPWORD1),y + ror a + sta (c64.SCRATCH_ZPWORD1),y + dey + lda (c64.SCRATCH_ZPWORD1),y + ror a + sta (c64.SCRATCH_ZPWORD1),y + rts .pend rol_array_ub .proc diff --git a/examples/arithmetic/bitshift.p8 b/examples/arithmetic/bitshift.p8 index 0194cb1fd..81f445d8f 100644 --- a/examples/arithmetic/bitshift.p8 +++ b/examples/arithmetic/bitshift.p8 @@ -9,35 +9,118 @@ main { uword uw &ubyte membyte=9999 &uword memword=9999 - ubyte[] ubarray = [8,8,8] - uword[] uwarray = [8200, 8200, 8200] - byte[] bbarray = [8,8,8] - word[] wwarray = [8200, 8200, 8200] + ubyte[] ubarray = [8,%10011100,8] + uword[] uwarray = [8200, %1001110011110001, 8200] + byte[] bbarray = [8,-%01011100,8] + word[] wwarray = [8200, -%0101110011110001, 8200] sub unimplemented() { - ; TODO implement these asm routines + c64scr.print_ubbin(ubarray[1], false) + c64.CHROUT('\n') lsr(ubarray[1]) - lsl(ubarray[1]) - ror(ubarray[1]) - rol(ubarray[1]) - ror2(ubarray[1]) - rol2(ubarray[1]) - lsr(bbarray[1]) - lsl(bbarray[1]) + c64scr.print_ubbin(ubarray[1], false) + c64.CHROUT('\n') + lsr(ubarray[1]) + c64scr.print_ubbin(ubarray[1], false) + c64.CHROUT('\n') + lsr(ubarray[1]) + c64scr.print_ubbin(ubarray[1], false) + c64.CHROUT('\n') + lsr(ubarray[1]) + c64scr.print_ubbin(ubarray[1], false) + c64.CHROUT('\n') + lsr(ubarray[1]) + c64scr.print_ubbin(ubarray[1], false) + c64.CHROUT('\n') + lsr(ubarray[1]) + c64scr.print_ubbin(ubarray[1], false) + c64.CHROUT('\n') + c64.CHROUT('\n') + c64scr.print_ubbin(bbarray[1] as ubyte, false) + c64.CHROUT('\n') + lsr(bbarray[1]) + c64scr.print_ubbin(bbarray[1] as ubyte, false) + c64.CHROUT('\n') + lsr(bbarray[1]) + c64scr.print_ubbin(bbarray[1] as ubyte, false) + c64.CHROUT('\n') + lsr(bbarray[1]) + c64scr.print_ubbin(bbarray[1] as ubyte, false) + c64.CHROUT('\n') + lsr(bbarray[1]) + c64scr.print_ubbin(bbarray[1] as ubyte, false) + c64.CHROUT('\n') + lsr(bbarray[1]) + c64scr.print_ubbin(bbarray[1] as ubyte, false) + c64.CHROUT('\n') + lsr(bbarray[1]) + c64scr.print_ubbin(bbarray[1] as ubyte, false) + c64.CHROUT('\n') + c64.CHROUT('\n') + + c64scr.print_uwbin(uwarray[1] as uword, false) + c64.CHROUT('\n') lsr(uwarray[1]) - lsl(uwarray[1]) - ror(uwarray[1]) - rol(uwarray[1]) - ror2(uwarray[1]) - rol2(uwarray[1]) + c64scr.print_uwbin(uwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(uwarray[1]) + c64scr.print_uwbin(uwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(uwarray[1]) + c64scr.print_uwbin(uwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(uwarray[1]) + c64scr.print_uwbin(uwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(uwarray[1]) + c64scr.print_uwbin(uwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(uwarray[1]) + c64scr.print_uwbin(uwarray[1] as uword, false) + c64.CHROUT('\n') + c64.CHROUT('\n') + + c64scr.print_uwbin(wwarray[1] as uword, false) + c64.CHROUT('\n') lsr(wwarray[1]) - lsl(wwarray[1]) + c64scr.print_uwbin(wwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(wwarray[1]) + c64scr.print_uwbin(wwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(wwarray[1]) + c64scr.print_uwbin(wwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(wwarray[1]) + c64scr.print_uwbin(wwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(wwarray[1]) + c64scr.print_uwbin(wwarray[1] as uword, false) + c64.CHROUT('\n') + lsr(wwarray[1]) + c64scr.print_uwbin(wwarray[1] as uword, false) + c64.CHROUT('\n') + c64.CHROUT('\n') + +; lsl(ubarray[1]) +; ror(ubarray[1]) +; rol(ubarray[1]) +; ror2(ubarray[1]) +; rol2(ubarray[1]) +; lsl(bbarray[1]) +; +; lsl(uwarray[1]) +; ror(uwarray[1]) +; rol(uwarray[1]) +; ror2(uwarray[1]) +; rol2(uwarray[1]) +; lsr(wwarray[1]) +; lsl(wwarray[1]) } sub start() { - ; TODO call this once implemented: - ; unimplemented() + unimplemented() lsr(A) lsl(A)