75 lines
3.1 KiB
Python
75 lines
3.1 KiB
Python
from z80shortcuts import *
|
|
|
|
instructions = [None] * 256
|
|
|
|
for y in range(8):
|
|
for z in range(8):
|
|
if y == r.index("(HL)") or z == r.index("(HL)"):
|
|
continue
|
|
instructions[int(f"0b01{y:03b}{z:03b}", 2)] = {
|
|
"name": f"LD {r[y]}, {r[z]}",
|
|
"subins": [
|
|
mr_read(z) | mr_write(y) | c_qw["reset_m_state"] | c_qw["reset_context"]
|
|
]
|
|
}
|
|
|
|
y = 6
|
|
for z in range(8):
|
|
instructions[int(f"0b01{y:03b}{z:03b}", 2)] = {
|
|
"name": f"LD (HL), {r[z]}",
|
|
"subins": [
|
|
exec_if_context | sr_read(sr.index("PC")) | mem_read | c_qw["ACU_write_en"] | c_qw["TMP_write_en"] | sr_write(sr.index("Z")),
|
|
exec_if_context | sr_read(sr.index("PC")) | c_qw["addr_inc_en"] | sr_write(sr.index("PC")),
|
|
|
|
#sign extend
|
|
exec_if_context | alu_op(alu.index("ADD")),
|
|
exec_if_context | alu_op(alu.index("SBC")) | sr_write(sr.index("W")),
|
|
|
|
exec_if_context | mr_read(r.index("L")) | c_qw["ACU_write_en"],
|
|
exec_if_context | sr_read(sr.index("Z")) | c_qw["TMP_write_en"],
|
|
exec_if_context | alu_op(alu.index("ADD")) | sr_write(sr.index("Z")),
|
|
exec_if_context | mr_read(r.index("H")) | c_qw["ACU_write_en"],
|
|
exec_if_context | sr_read(sr.index("W")) | c_qw["TMP_write_en"],
|
|
exec_if_context | alu_op(alu.index("ADC")) | sr_write(sr.index("W")),
|
|
|
|
mr_read(r.index("(HL)")) | sr_write(sr.index("WZ")),
|
|
c_qw["reset_context"],
|
|
mr_read(z) | c_qw["TMP_write_en"],
|
|
sr_read(sr.index("WZ")) | tmp_to_db | mem_write | c_qw["reset_m_state"] | c_qw["reset_context"]
|
|
]
|
|
}
|
|
|
|
z = 6
|
|
for y in range(8):
|
|
instructions[int(f"0b01{y:03b}{z:03b}", 2)] = {
|
|
"name": f"LD {r[y]}, (HL)",
|
|
"subins": [
|
|
exec_if_context | sr_read(sr.index("PC")) | mem_read | c_qw["ACU_write_en"] | c_qw["TMP_write_en"] | sr_write(sr.index("Z")),
|
|
exec_if_context | sr_read(sr.index("PC")) | c_qw["addr_inc_en"] | sr_write(sr.index("PC")),
|
|
|
|
#sign extend
|
|
exec_if_context | alu_op(alu.index("ADD")),
|
|
exec_if_context | alu_op(alu.index("SBC")) | sr_write(sr.index("W")),
|
|
|
|
exec_if_context | mr_read(r.index("L")) | c_qw["ACU_write_en"],
|
|
exec_if_context | sr_read(sr.index("Z")) | c_qw["TMP_write_en"],
|
|
exec_if_context | alu_op(alu.index("ADD")) | sr_write(sr.index("Z")),
|
|
exec_if_context | mr_read(r.index("H")) | c_qw["ACU_write_en"],
|
|
exec_if_context | sr_read(sr.index("W")) | c_qw["TMP_write_en"],
|
|
exec_if_context | alu_op(alu.index("ADC")) | sr_write(sr.index("W")),
|
|
|
|
mr_read(r.index("(HL)")) | mem_read | c_qw["TMP_write_en"],
|
|
c_qw["reset_context"],
|
|
tmp_to_db | mr_write(y) | c_qw["reset_m_state"] | c_qw["reset_context"]
|
|
]
|
|
}
|
|
|
|
|
|
y = 6
|
|
z = 6
|
|
instructions[int(f"0b01{y:03b}{z:03b}", 2)] = {
|
|
"name": "HALT",
|
|
"subins": [
|
|
c_qw["HALT+"]
|
|
]
|
|
} |