ft: add debug script
This commit is contained in:
43
gen.py
Normal file
43
gen.py
Normal file
@@ -0,0 +1,43 @@
|
||||
### Python script to generate specific instructions for testing
|
||||
import struct
|
||||
|
||||
output_file = "test.out"
|
||||
|
||||
machine_code = bytes([
|
||||
0xC5, 0x06, 0x34, 0x12, 0xFF, 0x1E, 0x34, 0x12, 0x9A, 0x78, 0x56, 0x34, 0x12, 0xEA, 0x78, 0x56, 0x34, 0x12, 0xFF, 0x1E, 0x34, 0x12, 0xFF, 0x2E, 0x34, 0x12
|
||||
])
|
||||
|
||||
magic = b'\x01\x03'
|
||||
flags = 0x20
|
||||
cpu = 0x0
|
||||
hdrlen = 0x20
|
||||
unused = 0x00
|
||||
version = 0
|
||||
text = len(machine_code)
|
||||
data = 0x00 # 4b
|
||||
bss = 0x00 # 4b
|
||||
entry = 0x00 # 4b
|
||||
total = text + data + bss + entry # 4b
|
||||
syms = 0x00 # 4b
|
||||
|
||||
# pack with LE
|
||||
header = struct.pack('<2sBBBBHLLLLLL',
|
||||
magic,
|
||||
flags,
|
||||
cpu,
|
||||
hdrlen,
|
||||
unused,
|
||||
version,
|
||||
text,
|
||||
data,
|
||||
bss,
|
||||
entry,
|
||||
total,
|
||||
syms
|
||||
)
|
||||
|
||||
with open(output_file, "wb") as f:
|
||||
f.write(header + machine_code)
|
||||
|
||||
print(f"a.out written to: {output_file}")
|
||||
|
||||
Reference in New Issue
Block a user