This commit is contained in:
Neil Webber 2023-09-15 06:15:41 -04:00
parent d0b0c2f25a
commit ea0f383121

View file

@ -20,8 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE. # SOFTWARE.
# having this sort of table is useful in many places beyond instruction # These tables are helpful to have for assembler, disassembler, etc
# execution (assembler, disassembler, etc)
BRANCH_CODES = { BRANCH_CODES = {
'bne': 0o001000, 'bne': 0o001000,
@ -42,12 +41,12 @@ BRANCH_CODES = {
'blos': 0o101400 'blos': 0o101400
} }
# there are some duplicates and they are chosen arbitrarily by this: # There are some duplicates and they are chosen arbitrarily by this:
BRANCH_NAMES = {v: k for k, v in BRANCH_CODES.items()} BRANCH_NAMES = {v: k for k, v in BRANCH_CODES.items()}
# keyed by masked "base code" (upper byte), not shifted # keyed by masked "base code" (upper byte), not shifted
brconds = { _brconds = {
# NOTE: 000400 case is handled in op000 dispatch separately # NOTE: 000400 case is handled in op000 dispatch separately
# 0o000400: lambda n, z, v, c: True, # BR # 0o000400: lambda n, z, v, c: True, # BR
0o001000: lambda n, z, v, c: not z, # BNE 0o001000: lambda n, z, v, c: not z, # BNE
@ -76,7 +75,7 @@ brconds = {
def branches(cpu, inst): def branches(cpu, inst):
branch(cpu, inst, brconds[inst & 0o177400]) branch(cpu, inst, _brconds[inst & 0o177400])
def branch(cpu, inst, condition): def branch(cpu, inst, condition):