summaryrefslogtreecommitdiff
path: root/nandgame/assembler/createbin.py
blob: 23f9979c6eda7b68b9b57464762765f13a9e1ab8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3

"""
Basically, iterate all 16-bit numbers,
or rather, 15-bit, to have valid
nandgame instructions, skip reserved bits.
"""

#ENDIANNESS = 'big'
ENDIANNESS = 'little'

with open("allins.bin", "wb") as f:
    ins=0x0000
    # ldi A, 0
    f.write(ins.to_bytes(2, byteorder = ENDIANNESS))

    ins=0x00ff
    # ldi A, 255
    f.write(ins.to_bytes(2, byteorder = ENDIANNESS))

    for ins in range(0x8000, 0xffff + 1):
        # unused bytes, force 1
        if (ins & 0x6800) != 0x6800:
            continue

        f.write(ins.to_bytes(2, byteorder = ENDIANNESS))