32 lines
705 B
Python
32 lines
705 B
Python
#!/usr/bin/env python
|
|
"""
|
|
Just some doc of GBC opcodes
|
|
"""
|
|
|
|
OP_CODES = {
|
|
'8-bit loads': [0x06, 0x0E, 0x16, 0x1E, 0x26, 0x2E, 0x36],
|
|
'reg-to-reg loads': list(range(0x40, 0x80)),
|
|
}
|
|
|
|
# for loads:
|
|
LD_REGS = ['B', 'C', 'D', 'E', 'H', 'L', '(HL)', 'A']
|
|
def load_source(op):
|
|
return LD_REGS[op & 0x7]
|
|
|
|
def load_dest(op):
|
|
return LD_REGS[(op >> 3) & 0x7]
|
|
|
|
def main():
|
|
for cat, ops in OP_CODES.items():
|
|
print("Category: {}".format(cat))
|
|
for op in ops:
|
|
print("{} - {} - LD {}, {}".format(
|
|
hex(op),
|
|
bin(op)[2:].zfill(8),
|
|
load_dest(op),
|
|
load_source(op)
|
|
))
|
|
|
|
if __name__ == '__main__':
|
|
main()
|