aboutsummaryrefslogtreecommitdiffstats
path: root/asm
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2023-02-12 20:37:45 +0000
committerGravatar Peter McGoron 2023-02-12 20:37:45 +0000
commit304e5d63c57512cfa32de26fcf4915b45e7c5b0a (patch)
tree8fe934df3e6a6e7768c2607681ab786b5347f242 /asm
parentmore loop tests (diff)
syscall test
Diffstat (limited to '')
-rw-r--r--asm/ffi.py13
-rw-r--r--asm/test.py17
2 files changed, 28 insertions, 2 deletions
diff --git a/asm/ffi.py b/asm/ffi.py
index 3442171..54a47dc 100644
--- a/asm/ffi.py
+++ b/asm/ffi.py
@@ -89,7 +89,7 @@ class Environment:
return creole.from_2c(self.cenv.reg[reg])
else:
return self.cenv.reg[reg]
- def getstk(self, stk):
+ def getstk(self, stk, signed=False):
""" Get the value at the stack position.
:param reg: Register number.
@@ -98,7 +98,16 @@ class Environment:
"""
if stk >= self.cenv.stklen or stk < 0:
raise StackOverflowError(r)
- return creole.from_2c(self.cenv.stk[stk])
+ if signed:
+ return creole.from_2c(self.cenv.stk[stk])
+ else:
+ return self.cenv.stk[stk]
+
+ def pop(self):
+ if stk == 0:
+ return None
+ stk = stk - 1
+ return self.cenv.stk[stk]
def __init__(self, prog=None, reglen=32, lablen=32, stklen=4096, prglen=4096):
cenv = CEnv()
diff --git a/asm/test.py b/asm/test.py
index 19778b5..d50b555 100644
--- a/asm/test.py
+++ b/asm/test.py
@@ -434,5 +434,22 @@ class ProgramTest(unittest.TestCase):
self.range_test(0x7FFFF00, 0x8000000, sgn=True)
self.range_test(-100, 0, sgn=True)
+class SCEnv(ffi.Environment):
+ def syscall(self, s):
+ self.s = s.value
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+
+class ProgramTest(unittest.TestCase):
+ def range_test(self, st, en, sgn=False):
+ for i in range(st, en):
+ p = Program()
+ p.parse_asm_line(f"sys {i}")
+ ex = SCEnv(p())
+ self.assertEqual(ex(), ffi.RunRet.STOP)
+ self.assertEqual(ex.s, i)
+ def test_syscall_imm(self):
+ self.range_test(0, 1000)
+
if __name__ == "__main__":
unittest.main()
c0b79aa3b4bb804ae965ab6416&follow=1'>add libtoolize to bootstrapGravatar ddennedy 1-1/+10 2003-04-21added Dan Maas' rawiso docsGravatar ddennedy 1-32/+295 2003-04-07new_handle_on_port() error path fix from Jim RadfordGravatar dmaas 1-1/+3 2003-03-26add raw1394_new_handle_on_port() convenience functionGravatar dmaas 2-1/+41 2003-02-22Updates for new rawiso ioctl interface.Gravatar bencollins 3-37/+125 2003-01-15add iso_xmit_sync() and iso_xmit_write(); clean up iso handling a bitGravatar dmaas 5-39/+161 2003-01-15implement tag matching for rawiso receptionGravatar dmaas 3-4/+12 2003-01-06back out previous commit - don't drop the legacy API just yetGravatar dmaas 6-173/+130 2003-01-05emulate legacy ISO reception API on top of new rawiso APIGravatar dmaas 7-131/+174 2002-12-24update iso API for multi-channel reception and new packet buffer layoutGravatar dmaas 4-123/+236 2002-12-20oops, irq_interval needs to be signedGravatar anonymous 1-1/+1 2002-12-20dmaas - renamed exported arm definitions into the raw1394_ namespace; brought...Gravatar anonymous 3-124/+48 2002-12-16rawiso updates:Gravatar dmaas 3-18/+25 2002-11-18fix cplusplus extern C blockGravatar ddennedy 1-4/+4 2002-11-18merged rawiso branchGravatar ddennedy 7-6/+488