use STH for right shift

This commit is contained in:
~d6 2021-12-28 15:25:26 -05:00
parent 524fec6ed1
commit 28bcf6d413
1 changed files with 15 additions and 19 deletions

View File

@ -133,36 +133,32 @@
STHk SFT ;sh/z3 STA ( write z3 )
#00 STHkr SFT2 #00 ;sh/z3 LDA ORA2 ;sh/z2 STA2 ( write z2,z3 )
#00 STHkr SFT2 #00 ;sh/z2 LDA ORA2 ;sh/z1 STA2 ( write z1,z2 )
#00 STHr SFT2 #00 ;sh/z1 LDA ORA2 ;sh/z0 STA2 ( write z0,z1 )
;sh/z0 LDA2 ;sh/z2 LDA2
#00 STHr SFT2 #00 ;sh/z1 LDA ORA2 ( compute z0,z1 )
;sh/z2 LDA2
RTN
( shift right by 8-15 bits )
@right-shift1 ( x** n^ -> x<<n )
#00 ;sh/z1 STA #0000 ;sh/z2 STA2
#08 SUB ;sh/r STA ( n -> r )
POP
;sh/r LDA SFT ;sh/z3 STA ( write z3 )
#00 ;sh/r LDA SFT2 ;sh/z2 LDA2 ORA2 ;sh/z2 STA2 ( write z2,z3 )
#00 ;sh/r LDA SFT2 ;sh/z1 LDA2 ORA2 ;sh/z1 STA2 ( write z1,z2 )
#00 ;sh/z1 LDA ;sh/z2 LDA2
#08 SUB STH POP
STHkr SFT ;sh/z3 STA ( write z3 )
#00 STHkr SFT2 #00 ;sh/z3 LDA ORA2 ;sh/z2 STA2 ( write z2,z3 )
#00 STHr SFT2 #00 ;sh/z2 LDA ORA2 ( compute z1,z2 )
#00 TOR ;sh/z3 LDA
RTN
( shift right by 16-23 bits )
@right-shift2 ( x** n^ -> x<<n )
#0000 ;sh/z2 STA2
#10 SUB ;sh/r STA ( n -> r )
POP2
;sh/r LDA SFT ;sh/z3 STA ( write z3 )
#00 ;sh/r LDA SFT2 ;sh/z2 LDA2 ORA2 ;sh/z2 STA2 ( write z2,z3 )
#0000 ;sh/z2 LDA2
#10 SUB STH POP2
STHkr SFT ;sh/z3 STA ( write z3 )
#00 STHr SFT2 #00 ;sh/z3 LDA ORA2 ( compute z2,z3 )
#0000 SWP2
RTN
( shift right by 16-23 bits )
@right-shift3 ( x** n^ -> x<<n )
#18 SUB ;sh/r STA ( n -> r )
POP2 POP #00 SWP #0000 SWP2 ( 00 00 00 x0 )
;sh/r LDA SFT
#18 SUB STH POP2 POP ( x0 )
#00 SWP #0000 SWP2 ( 00 00 00 x0 )
STHr SFT
RTN
( shift left, i.e. << )