code = bytearray([ 0xa9, 0x42, 0x8d, 0x00, 0x40, 0xdb ]) rom = code + bytearray([0xEA] * (1024 * 32 - len(code))) rom[0x7FFC] = 0x00 rom[0x7FFD] = 0x80 with open("rom.bin", "wb") as bin_file: bin_file.write(rom)