clean up
This commit is contained in:
parent
a8364516b3
commit
e8b6990a9d
28
math32.tal
28
math32.tal
|
@ -5,7 +5,6 @@
|
|||
|
||||
%DEBUG { #ff #0e DEO }
|
||||
%RTN { JMP2r }
|
||||
|
||||
%TOR { ROT ROT } ( a b c -> c a b )
|
||||
%TOR2 { ROT2 ROT2 }
|
||||
%POP4 { POP2 POP2 }
|
||||
|
@ -51,21 +50,17 @@ RTN
|
|||
|
||||
@eq32 ( xhi* xlo* yhi* ylo* -> bool^ )
|
||||
ROT2 EQU2 #00 TOR2
|
||||
EQU2 SWP POP AND
|
||||
RTN
|
||||
EQU2 SWP POP AND RTN
|
||||
|
||||
@is-zero32 ( x** -> bool^ )
|
||||
ORA2 #0000 EQU2
|
||||
RTN
|
||||
ORA2 #0000 EQU2 RTN
|
||||
|
||||
@ne32 ( xhi* xlo* yhi* ylo* -> bool^ )
|
||||
ROT2 NEQ2 #00 TOR2
|
||||
NEQ2 SWP POP ORA
|
||||
RTN
|
||||
NEQ2 SWP POP ORA RTN
|
||||
|
||||
@non-zero32 ( x** -> bool^ )
|
||||
ORA2 #0000 NEQ2
|
||||
RTN
|
||||
ORA2 #0000 NEQ2 RTN
|
||||
|
||||
( comparisons )
|
||||
|
||||
|
@ -104,20 +99,16 @@ RTN
|
|||
( bitwise operations )
|
||||
|
||||
@and32 ( xhi* xlo* yhi* ylo* -> xhi|yhi* xlo|ylo* )
|
||||
ROT2 AND2 TOR2 AND2 SWP2
|
||||
RTN
|
||||
ROT2 AND2 TOR2 AND2 SWP2 RTN
|
||||
|
||||
@or32 ( xhi* xlo* yhi* ylo* -> xhi|yhi* xlo|ylo* )
|
||||
ROT2 ORA2 TOR2 ORA2 SWP2
|
||||
RTN
|
||||
ROT2 ORA2 TOR2 ORA2 SWP2 RTN
|
||||
|
||||
@xor32 ( xhi* xlo* yhi* ylo* -> xhi|yhi* xlo|ylo* )
|
||||
ROT2 EOR2 TOR2 EOR2 SWP2
|
||||
RTN
|
||||
ROT2 EOR2 TOR2 EOR2 SWP2 RTN
|
||||
|
||||
@complement32 ( x** -> ~x** )
|
||||
COMPLEMENT32
|
||||
RTN
|
||||
COMPLEMENT32 RTN
|
||||
|
||||
( bit shifting )
|
||||
|
||||
|
@ -279,8 +270,7 @@ RTN
|
|||
RTN
|
||||
|
||||
@sub32 ( x** y** -> z** )
|
||||
;negate32 JSR2 ;add32 JSR2
|
||||
RTN
|
||||
;negate32 JSR2 ;add32 JSR2 RTN
|
||||
|
||||
@mul16 ( x* y* -> z** )
|
||||
,&y1 STR ,&y0 STR ( save ylo, yhi )
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
from math import floor, log
|
||||
from os import environ
|
||||
from random import randint
|
||||
from subprocess import Popen, PIPE
|
||||
from subprocess import Popen, PIPE, run
|
||||
|
||||
u3 = {'sz': 1 << 3, 'fmt': b'%02x'}
|
||||
u5 = {'sz': 1 << 5, 'fmt': b'%02x'}
|
||||
|
@ -50,14 +50,14 @@ def test(p, trials, sym, args, out, f):
|
|||
print('%s failed %d/%d trials (%r)' % (name, fails, trials, cases))
|
||||
|
||||
def pipe():
|
||||
cli = environ['HOME'] + '/w/uxn/bin/uxncli'
|
||||
return Popen([cli, 'run.rom'], stdin=PIPE, stdout=PIPE)
|
||||
return Popen(['uxncli', 'run.rom'], stdin=PIPE, stdout=PIPE)
|
||||
|
||||
def bitcount(x):
|
||||
return floor(log(x, 2)) + 1
|
||||
|
||||
def main():
|
||||
trials = 1000
|
||||
run(['uxnasm', 'test-math32.tal', 'run.rom'])
|
||||
p = pipe()
|
||||
test(p, trials, b'+', [('x', u32), ('y', u32)], u32, lambda x, y: x + y)
|
||||
test(p, trials, b'-', [('x', u32), ('y', u32)], u32, lambda x, y: x - y)
|
||||
|
|
Loading…
Reference in New Issue