fix mul16 bug

This commit is contained in:
~d6 2021-12-23 01:01:09 -05:00
parent a310addf5f
commit 1f2ee6cef4
1 changed files with 48 additions and 31 deletions

View File

@ -18,24 +18,53 @@
%Z { #fedc #ba98 }
|0100
#ffff #ffff ;mul16 JSR2 ;emit-long JSR2 NEWLINE
#ffff #ffff #ffff #ffff ;mul32 JSR2 ;emit-long JSR2 NEWLINE
#ffff #ffff #2a ;mul16 ;emit-short ;test16 JSR2
#0001 #ffff #2a ;mul16 ;emit-short ;test16 JSR2
#ffff #0001 #2a ;mul16 ;emit-short ;test16 JSR2
#00ff #0001 #2a ;mul16 ;emit-short ;test16 JSR2
NEWLINE
X Y #2b ;add32 ;emit-long ;test JSR2
Z Y #2b ;add32 ;emit-long ;test JSR2
#fedc #0000 #1234 #0000 #2b ;add32 ;emit-long ;test JSR2
#fedc #0000 #0000 #0000 #2b ;add32 ;emit-long ;test JSR2
#0000 #0000 #0000 #0000 #2b ;add32 ;emit-long ;test JSR2
X Y #26 ;and32 ;emit-long ;test JSR2
X Y #7c ;or32 ;emit-long ;test JSR2
X Y #5e ;xor32 ;emit-long ;test JSR2
X Y #3d ;eq32 ;emit-byte ;test JSR2
Y Y #3d ;eq32 ;emit-byte ;test JSR2
X Y #7e ;ne32 ;emit-byte ;test JSR2
X X #7e ;ne32 ;emit-byte ;test JSR2
#ffff #ffff #ffff #ffff #2a ;mul32 ;emit-long ;test32 JSR2
#0000 #0001 #ffff #ffff #2a ;mul32 ;emit-long ;test32 JSR2
#0000 #0002 #0000 #ffff #2a ;mul32 ;emit-long ;test32 JSR2
#0001 #2345 #0034 #5678 #2a ;mul32 ;emit-long ;test32 JSR2
NEWLINE
X Y #2b ;add32 ;emit-long ;test32 JSR2
Z Y #2b ;add32 ;emit-long ;test32 JSR2
#fedc #0000 #1234 #0000 #2b ;add32 ;emit-long ;test32 JSR2
#fedc #0000 #0000 #0000 #2b ;add32 ;emit-long ;test32 JSR2
#0000 #0000 #0000 #0000 #2b ;add32 ;emit-long ;test32 JSR2
NEWLINE
X Y #26 ;and32 ;emit-long ;test32 JSR2
X Y #7c ;or32 ;emit-long ;test32 JSR2
X Y #5e ;xor32 ;emit-long ;test32 JSR2
X Y #3d ;eq32 ;emit-byte ;test32 JSR2
Y Y #3d ;eq32 ;emit-byte ;test32 JSR2
X Y #7e ;ne32 ;emit-byte ;test32 JSR2
X X #7e ;ne32 ;emit-byte ;test32 JSR2
BRK
@test ( x** y** symbol^ test-addr* emit-addr* -> )
@test16 ( x* y* symbol^ test-addr* emit-addr* -> )
,&emitaddr STR2
,&testaddr STR2
,&testsym STR
,&y STR2
,&x STR2
,&x LDR2 ;emit-short JSR2
SPACE ,&testsym LDR EMIT SPACE
,&y LDR2 ;emit-short JSR2
SPACE #3d EMIT SPACE
,&x LDR2 ,&y LDR2
,&testaddr LDR2 JSR2
,&emitaddr LDR2 JSR2 NEWLINE
RTN
&testsym $1
&testaddr $2
&emitaddr $2
&x $2 &y $2
@test32 ( x** y** symbol^ test-addr* emit-addr* -> )
,&emitaddr STR2
,&testaddr STR2
,&testsym STR
@ -56,7 +85,6 @@ RTN
&xhi $2 &xlo $2
&yhi $2 &ylo $2
@eq32 ( xhi* xlo* yhi* ylo* -> bool^ )
ROT2 EQU2 ,&maybe JCN
POP4 #00 RTN
@ -81,22 +109,11 @@ RTN
ROT2 EOR2 TOR2 EOR2 SWP2
RTN
@left-by-8 ( x** -> x<<8** )
SWP2 ( x2 x3 x0 x1 )
SWP POP ( x2 x3 x1 )
ROT ROT #00 ( x1 x2 x3 00 )
RTN
@left-by-16 ( x** -> x<<16** )
SWP2 ( x2 x3 x0 x1 )
POP2 #0000 ( x2 x3 0000 )
RTN
@left-by-24 ( x** -> x<<24** )
SWP2 POP2 ( x2 x3 )
SWP POP #00 #0000 ( x3 00 0000 )
RTN
@add32 ( xhi* xlo* yhi* ylo* -> zhi* zlo* )
,&y2 STR2 ,&y0 STR2 ( save ylo, yhi )
,&x2 STR2 ,&x0 STR2 ( save xlo, xhi )
@ -144,15 +161,15 @@ RTN
( x0 * y0 => a0a1 )
#00 ,&x0 LDR #00 ,&y0 LDR MUL2 ,&a0 LDR2 ADD2 ,&a0 STR2
( load z and a )
( add z and a<<8 )
#00 ,&z0 LDR2 ,&z2 LDR
,&a0 LDR2 ,&z2 LDR #00
,&a0 LDR2 ,&a2 LDR #00
;add32 JSR2
RTN
[ &x0 $1 &x1 $1 ]
[ &y0 $1 &y1 $1 ]
[ &z0 $1 &z1 $1 &z2 $2 ]
[ &a0 $1 &a1 $1 &a2 $2 ]
[ &z0 $1 &z1 $1 &z2 $1 ]
[ &a0 $1 &a1 $1 &a2 $1 ]
@mul32 ( x** y** -> z** )
,&y1 STR2 ,&y0 STR2 ( save ylo, yhi )