Compare commits
2 Commits
0d73e80c59
...
2d64d09f24
Author | SHA1 | Date |
---|---|---|
stupidcomputer | 2d64d09f24 | |
stupidcomputer | ee93c4db4c |
|
@ -23,9 +23,9 @@ id testing : B = []
|
|||
: imul(a, b, t_o) = setlistval(t_o, omul(B[a], B[b]))
|
||||
|
||||
: icmp(a, b, z) = { \
|
||||
a = b : equals -> 1 , \
|
||||
a > b : greater -> 1 , \
|
||||
a < b : less -> 1 \
|
||||
B[a] = B[b] : equals -> 1 , \
|
||||
B[a] > B[b] : greater -> 1 , \
|
||||
B[a] < B[b] : less -> 1 \
|
||||
}
|
||||
: irst(a, b, c) = equals -> 0, greater -> 0, less -> 0
|
||||
: ield(addr, b) = setlistval(addr, equals)
|
||||
|
@ -40,7 +40,6 @@ id testing : B = []
|
|||
|
||||
: isto(v, addr) = setlistval(addr, v)
|
||||
: imov(from, target) = setlistval(target, B[from])
|
||||
: ipsto(value, ptr) = setlistval(B[ptr], value)
|
||||
|
||||
# registers
|
||||
# instruction pointer
|
||||
|
@ -70,7 +69,6 @@ id testing : B = []
|
|||
paramthree -> B[addr + 3]
|
||||
: exec = { \
|
||||
inst = sto : isto(paramone, paramtwo), \
|
||||
inst = psto : ipsto(paramone, paramtwo), \
|
||||
inst = mov : imov(paramone, paramtwo), \
|
||||
inst = add : iadd(paramone, paramtwo, paramthree), \
|
||||
inst = cmp : icmp(paramone, paramtwo, paramthree), \
|
||||
|
@ -97,7 +95,6 @@ id testing : B = []
|
|||
: main = loopaction, loop
|
||||
|
||||
: sto = 1
|
||||
: psto = 16
|
||||
: mov = 17
|
||||
: add = 2
|
||||
: cmp = 3
|
||||
|
@ -114,5 +111,5 @@ id testing : B = []
|
|||
: div = 14
|
||||
: rst = 15
|
||||
|
||||
: instwidth = [2,3,1,1,1,1,1,1,1,1,3,3,3,3,0,2,2]
|
||||
: instwidth = [2,3,2,1,1,1,1,1,1,1,3,3,3,3,0,2,2]
|
||||
"""
|
||||
|
|
|
@ -31,7 +31,6 @@ def instruction_test_helper(override_text, expected_output):
|
|||
})
|
||||
server.start()
|
||||
|
||||
time.sleep(1)
|
||||
return server.outputs[-1]["output"] == "true"
|
||||
|
||||
class ISATest(unittest.TestCase):
|
||||
|
@ -82,3 +81,77 @@ class ISATest(unittest.TestCase):
|
|||
[14, 1, 6, 5, 3.5, 4],
|
||||
)
|
||||
)
|
||||
|
||||
def test_jmp(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
[7, 10, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3], # jump to addr 10
|
||||
[7, 10, 3, 0, 0, 0, 0, 0, 0, 1, 3, 3]
|
||||
)
|
||||
)
|
||||
|
||||
def test_cmp_eq(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
# check if 3 is equal to 3. if so, store 3 into addr 3, otherwise store 1 into address 2
|
||||
[3, 1, 1, 8, 10, 1, 1, 2, 0, 1, 3, 3],
|
||||
[3, 1, 3, 8, 10, 1, 1, 2, 0, 1, 3, 3],
|
||||
)
|
||||
)
|
||||
|
||||
def test_cmp_neq(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
# check if 3 is equal to 1. if not, store 3 into addr 3, otherwise store 1 into address 2
|
||||
[3, 1, 2, 9, 10, 1, 1, 2, 0, 1, 3, 3],
|
||||
[3, 1, 3, 9, 10, 1, 1, 2, 0, 1, 3, 3],
|
||||
)
|
||||
)
|
||||
|
||||
def test_cmp_gt(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
[3, 1, 2, 10, 10, 1, 1, 2, 0, 1, 3, 3],
|
||||
[3, 1, 3, 10, 10, 1, 1, 2, 0, 1, 3, 3],
|
||||
)
|
||||
)
|
||||
|
||||
def test_cmp_lt(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
[3, 1, 4, 11, 10, 1, 1, 2, 0, 1, 3, 3],
|
||||
[3, 1, 4, 11, 10, 1, 1, 2, 0, 1, 3, 3],
|
||||
)
|
||||
)
|
||||
|
||||
def test_eld(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
[3, 1, 1, 4, 1],
|
||||
[1, 1, 1, 4, 1],
|
||||
)
|
||||
)
|
||||
|
||||
def test_gld(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
[3, 4, 1, 5, 1],
|
||||
[1, 4, 1, 5, 1],
|
||||
)
|
||||
)
|
||||
|
||||
def test_lld(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
[3, 1, 4, 6, 1],
|
||||
[1, 1, 4, 6, 1],
|
||||
)
|
||||
)
|
||||
|
||||
def test_mov(self):
|
||||
self.assertTrue(
|
||||
instruction_test_helper(
|
||||
[17, 1, 2],
|
||||
[17, 17, 2]
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[build-system]
|
||||
requires = ["setuptools"]
|
||||
build-backend = "setuptools.build_meta"
|
16
setup.py
16
setup.py
|
@ -1,16 +0,0 @@
|
|||
import setuptools
|
||||
setuptools.setup(
|
||||
name='desmos-sync',
|
||||
version='0.1',
|
||||
author='Ryan Marina',
|
||||
description='synchronize Desmos expressions between the local filesystem and the web calculator',
|
||||
packages=["desmossync"],
|
||||
entry_points = {
|
||||
"console-scripts": [ "desmos-sync=desmossync.cli.entry" ]
|
||||
},
|
||||
install_requires=[
|
||||
'setuptools',
|
||||
'websockets',
|
||||
'watchdog'
|
||||
]
|
||||
)
|
Loading…
Reference in New Issue