From 8bbd29d37d247bd38d1f78c12cc4a4efff9cf329 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 19 May 2020 10:19:37 -0400 Subject: [PATCH] avra: add SKIP, .. AT, Will change to IF, .. THEN, but I need a way to easily reverse a BR op. But from this commit, the translation of sms/kbd/ps2ctl.asm is complete! perfect binary match! --- blk/671 | 13 +++++++------ recipes/sms/kbd/ps2ctl.fs | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/blk/671 b/blk/671 index 95bf3c5..4dfafb4 100644 --- a/blk/671 +++ b/blk/671 @@ -1,13 +1,14 @@ ( L1 LBL! .. L1 ' RJMP LBL, ) : LBL! ( l -- ) PC SWAP ! ; : LBL, ( l op -- ) SWAP @ 1- SWAP EXECUTE A,, ; -( L1 FLBL, .. L1 ' RJMP FLBL! ) -: FLBL, ( l -- ) LBL! 0 A,, ; -: FLBL! ( l opw -- ) - ( warning: l is a PC offset, not a mem addr! ) - SWAP @ 2 * ORG @ + PC 1- H@ ( opw addr tgt hbkp ) +: SKIP, PC 0 A,, ; +: AT, ( opw pc ) + ( warning: pc is a PC offset, not a mem addr! ) + 2 * ORG @ + PC 1- H@ ( opw addr tgt hbkp ) ROT HERE ! ( opw tgt hbkp ) SWAP ROT EXECUTE H@ ! ( hbkp ) HERE ! ; +( L1 FLBL, .. L1 ' RJMP FLBL! ) +: FLBL, ( l -- ) LBL! 0 A,, ; +: FLBL! ( l opw -- ) SWAP @ AT, ; : BEGIN, PC ; : AGAIN, ( op ) SWAP 1- SWAP EXECUTE A,, ; - diff --git a/recipes/sms/kbd/ps2ctl.fs b/recipes/sms/kbd/ps2ctl.fs index 68fb006..a256a47 100644 --- a/recipes/sms/kbd/ps2ctl.fs +++ b/recipes/sms/kbd/ps2ctl.fs @@ -297,3 +297,29 @@ RET, L8 ' RCALL FLBL! ( checkBoundsY ) ( Check that Y is within bounds, reset to SRAM_START if not. ) 28 ( YL ) TST, +' BREQ SKIP, RET, ( not zero, nothing to do ) AT, +( YL is zero. Reset Z ) +29 ( YH ) CLR, +28 ( YL ) SRAM_START 0xff AND LDI, +RET, + +L3 ' RCALL FLBL! ( checkBoundsZ ) +( Check that Z is within bounds, reset to SRAM_START if not. ) +30 ( ZL ) TST, +' BREQ SKIP, RET, ( not zero, nothing to do ) AT, +( ZL is zero. Reset Z ) +31 ( ZH ) CLR, +30 ( ZL ) SRAM_START 0xff AND LDI, +RET, + +L5 ' RCALL FLBL! L6 ' RCALL FLBL! ( checkParity ) +( Counts the number of 1s in r19 and set r16 to 1 if there's an + even number of 1s, 0 if they're odd. ) +16 1 LDI, +BEGIN, + 19 LSR, + ' BRCC SKIP, 16 INC, ( carry set? we had a 1 ) AT, + 19 TST, ( is r19 zero yet? ) +' BRNE AGAIN, ( no? loop ) +16 0x1 ANDI, +RET,