Comments (4)
Well, I'm not entirely sure why I wrote that code that way, it's certainly less-clear than it could be, but I think the two implementations are identical. Here's a test showing that -- unless you think I've overlooked something.
For the test code, I replaced "cpu.r[srcreg]" with just a function argument (see the code below) and have the functions return a tuple: True/False (branch taken or not) and the modified register value. They produce identical results for all inputs 0 .. 65535:
Put this in a file foo.py and "python3 foo.py" to run it.
def sobSIMH(srcreg):
r = (srcreg - 1) & 0xffff
if r != 0:
return r, True # branch
return r, False # no branch
def sobNW(srcreg):
r = srcreg
if r == 1:
r = 0
else:
if r > 0:
r -= 1
else:
r = 0o177777 # 0 means max, that's how SOB is defined
return r, True
return r, False
if name == "main":
import unittest
class TestMethods(unittest.TestCase):
def test_compare(self):
for srcreg in range(65536):
self.assertEqual(sobNW(srcreg), sobSIMH(srcreg))
unittest.main()
from python-pdp11-emulator.
ugh - code got hosed in cut/paste. Get it here for now:
https://www.dropbox.com/scl/fi/mfxyo2gqsv1e4fe5m2an8/sobx.py?rlkey=o41hjnaf389kdp1la5nng6rnh&dl=0
from python-pdp11-emulator.
from python-pdp11-emulator.
Took the pull even though old code worked. New code is simpler.
Never tried compiling. I did spend a little time trying to make the simplest instructions (register-to-register moves in particular) go fast, but at some point if performance is that important "use SIMH" becomes a better answer. I was just happy that it booted v7 (despite all the recently-found bugs! lol) and ran at a reasonable speed.
from python-pdp11-emulator.
Related Issues (6)
- BICB & v flag HOT 3
- addressing modes HOT 2
- python & signmask HOT 5
- problem with console i/o: "NoneType" written to it HOT 2
- typeerror HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-pdp11-emulator.