else:
tok = bytearray.fromhex(token_list[1])
num = struct.unpack(">H", tok)[0]
- return bytearray.fromhex("07") + struct.pack(">H", instr_offs[num])
+ val = bytearray(struct.pack(">H", instr_offs[num]))
+ val.reverse()
+ return bytearray.fromhex("07") + val
elif token_list[0] == "rewind":
return bytearray.fromhex("08")
elif token_list[0] == "and":
if s != 2:
syn_err("invalid number of arguments")
- return bytearray.fromhex("0F") + bytearray.fromhex(token_list[1])
+ val = bytearray.fromhex(token_list[1])
+ val.reverse()
+ return bytearray.fromhex("0F") + val
elif token_list[0] == "jmpeq":
if s != 2:
syn_err("invalid number of arguments")
else:
tok = bytearray.fromhex(token_list[1])
num = struct.unpack(">H", tok)[0]
- return bytearray.fromhex("17") + struct.pack(">H", instr_offs[num])
+ val = bytearray(struct.pack(">H", instr_offs[num]))
+ return bytearray.fromhex("17") + val
elif token_list[0] == "jmpne":
if s != 2:
syn_err("invalid number of arguments")
else:
tok = bytearray.fromhex(token_list[1])
num = struct.unpack(">H", tok)[0]
- return bytearray.fromhex("27") + struct.pack(">H", instr_offs[num])
+ val = bytearray(struct.pack(">H", instr_offs[num]))
+ return bytearray.fromhex("27") + val
elif token_list[0] == "jmplt":
if s != 2:
syn_err("invalid number of arguments")
else:
tok = bytearray.fromhex(token_list[1])
num = struct.unpack(">H", tok)[0]
- return bytearray.fromhex("37") + struct.pack(">H", instr_offs[num])
+ val = bytearray(struct.pack(">H", instr_offs[num]))
+ return bytearray.fromhex("37") + val
elif token_list[0] == "jmpgt":
if s != 2:
syn_err("invalid number of arguments")
else:
tok = bytearray.fromhex(token_list[1])
num = struct.unpack(">H", tok)[0]
- return bytearray.fromhex("47") + struct.pack(">H", instr_offs[num])
+ val = bytearray(struct.pack(">H", instr_offs[num]))
+ return bytearray.fromhex("47") + val
elif token_list[0] == "jmple":
if s != 2:
syn_err("invalid number of arguments")
else:
tok = bytearray.fromhex(token_list[1])
num = struct.unpack(">H", tok)[0]
- return bytearray.fromhex("57") + struct.pack(">H", instr_offs[num])
+ val = bytearray(struct.pack(">H", instr_offs[num]))
+ return bytearray.fromhex("57") + val
elif token_list[0] == "jmpge":
if s != 2:
syn_err("invalid number of arguments")
else:
tok = bytearray.fromhex(token_list[1])
num = struct.unpack(">H", tok)[0]
- return bytearray.fromhex("67") + struct.pack(">H", instr_offs[num])
+ val = bytearray(struct.pack(">H", instr_offs[num]))
+ return bytearray.fromhex("67") + val
def pad_zero_r(x, c):
while len(x) < c:
for line in ins:
lines += 1
tokens = re.split("\s+", line.strip("\n")) # Split by whitespace.
- try:
- bytes = parse_op(tokens, None) # Parse.
- except:
- print("Error on line " + str(lines))
- exit(1)
+ bytes = parse_op(tokens, None) # Parse.
if bytes:
offsets += [size]
size += len(bytes)
for line in ins:
lines += 1
tokens = re.split("\s+", line.strip("\n")) # Split by whitespace.
- try:
- bytes = parse_op(tokens, offsets) # Parse.
- except:
- print("Error on line " + str(lines))
- exit(1)
+ bytes = parse_op(tokens, offsets) # Parse.
if bytes:
bytecode += bytes
if (debug)
log("jmp\n");
code++;
- code = bytecode + code[1] + (code[0] << 8);
+ code = bytecode + (code[0] + (code[1] << 8));
break;
case OP_JMPEQ: // Jump to offset if equal
if (debug)
log("jmpeq\n");
code++;
if (eq)
- code = bytecode + code[1] + (code[0] << 8);
+ code = bytecode + (code[0] + (code[1] << 8));
else
code += 2;
break;
log("jmpne\n");
code++;
if (!eq)
- code = bytecode + code[1] + (code[0] << 8);
+ code = bytecode + (code[0] + (code[1] << 8));
else
code += 2;
break;
log("jmplt\n");
code++;
if (lt)
- code = bytecode + code[1] + (code[0] << 8);
+ code = bytecode + (code[0] + (code[1] << 8));
else
code += 2;
break;
log("jmpgt\n");
code++;
if (gt)
- code = bytecode + code[1] + (code[0] << 8);
+ code = bytecode + (code[0] + (code[1] << 8));
else
code += 2;
break;
log("jmple\n");
code++;
if (lt || eq)
- code = bytecode + code[1] + (code[0] << 8);
+ code = bytecode + (code[0] + (code[1] << 8));
else
code += 2;
break;
log("jmpge\n");
code++;
if (gt || eq)
- code = bytecode + code[1] + (code[0] << 8);
+ code = bytecode + (code[0] + (code[1] << 8));
else
code += 2;
break;
if (debug)
log("seek\n");
code++;
- offset = ( code[3] + (code[2] << 8) + (code[1] << 16) + (code[0] << 24));
- if (offset > current_mode->size) {
+ offset = code[0] + (code[1] << 8) + (code[2] << 16) + (code[3] << 24);
+ if (offset > current_mode->size) { // Went out of bounds. Error.
#ifndef LOADER
fprintf(stderr, "%x", offset);
#endif
- // Went out of bounds. Error.
abort("seeked out of bounds\n");
- }
- else
- code += 4;
+ }
+
+ code += 4;
break;
case OP_NEXT:
if (debug)
{ OPTION_OVERLY_VERBOSE, "Verbose", "Output more debug information than the average user needs.", boolean_val, 0, 0 },
{ OPTION_SAVE_LOGS, "Logging", "Save logs to the corbenik folder. Slows operation a bit.", boolean_val, 0, 0 },
- { OPTION_RECONFIGURED, "Reconfigured (DO NOT UNCHECK)", "If patches were reconfigured, this will be set. Do not untick this if ticked.", boolean_val, 0,
- 0 },
-
// { OPTION_ARM9THREAD, "ARM9 Thread", boolean_val, 0, 0 },
// { IGNORE_PATCH_DEPS, "Ignore dependencies", boolean_val, 0, 0 },
// { IGNORE_BROKEN_SHIT, "Allow unsafe options", boolean_val, 0, 0 },