Spaces:
Sleeping
Sleeping
| OPCODES = { | |
| "HALT": 0x00, | |
| "LOAD_IMM": 0x01, | |
| "LOAD_MEM": 0x02, | |
| "STORE": 0x03, | |
| "ADD": 0x04, | |
| "CMP": 0x08, | |
| "JZ": 0x0A, | |
| "HASH": 0x0C, | |
| "COMMIT": 0x0F, | |
| "EMIT": 0x11, | |
| } | |
| def compile_codexbyte(lines): | |
| bytecode = [] | |
| for line in lines: | |
| line = line.strip() | |
| if not line or line.startswith(";"): | |
| continue | |
| parts = line.split() | |
| opcode = OPCODES[parts[0]] | |
| bytecode.append(opcode) | |
| for arg in parts[1:]: | |
| bytecode.append(int(arg, 0)) | |
| return bytecode |