GithubHelp home page GithubHelp logo

Comments (4)

outofmbufs avatar outofmbufs commented on June 13, 2024

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.

outofmbufs avatar outofmbufs commented on June 13, 2024

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.

folkertvanheusden avatar folkertvanheusden commented on June 13, 2024

from python-pdp11-emulator.

outofmbufs avatar outofmbufs commented on June 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.