Pysix python module
From Just in Time
The pysix python module allows a developer to create a python script that runs an sx lst file, sets breakpoints and manipulates the state of the emulator. This can be used to simulate inputs or to log outputs of the SX while it is running its program.
Trivial example
Pysix classes and functions
ParseListingFile
listing ParseListingFile( fileName)
This function opens a listing (.lst) file and parses it. The results will be returned in the form of a listing object.
Listing
This object has no attributes that are visible to python.
SxState
This class represents the state of the simulator. It currently exposes the following attributes:
- w
- the w register.
- m
- the m register
- pc
- the program counter (all 12 bits)
- in_interrupt
- a boolean that indicates whether the SX is currently handling an interrupt
- ram
- the ram contents. Access values--both reading and writing--by using sx.state.ram(<address>).
important
There is currently an issue that prevents scripts from directly changing the state. This is caused by the fact that sx.state does not return the SX's state itself, but instead returns a copy. So code like the following:
sx.state.w = 0
does not change the value of w on the emulator. What does work (but is cumbersome) is the following
state_copy = sx.state state_copy.w = 42 sx.state = state_copy
Simulator
The simulator is the central class of the pysix module. It offers the following attributes and functions:
- state
- SxState. This is the state of the simulator at any given point in time. See #SxState
- load_rom( Listing)
- boolean. Load the rom with the program bytes specified by the #Listing object. See also ParseListingFile
- run( integer)
- integer. Will run for the given amount of clock-cycles or until a breakpoint is hit. Will return the amount of cycles left in this run (i.e. it will return zero if no breakpoint was hit and will return n - i if a breakpoint was hit after i cycles).
- set_breakpoint( integer)
- Sets a breakpoint at the given address. You can reset breakpoints by calling this function with an extra argument:
sx.set_breakpoint( some_address, False)