1
1
"""
2
2
REG-COMP 2.0
3
3
Interface:
4
- py regcomp2.py {input} {output} --target={pASM/pASM.c/x86-64} --target-operant -size={} --target-memory-size={} --logging-mode={DEBUG/INFO/WARN/ERROR}
4
+ py regcomp2.py {input} {output} --target={pASM/pASM.c/x86-64} --target-operand -size={} --target-memory-size={} --logging-mode={DEBUG/INFO/WARN/ERROR}
5
5
"""
6
6
from collections import defaultdict , deque
7
7
from traceback import format_exc
@@ -371,7 +371,7 @@ def main(input: str, output: str, target: _ty.Literal["pASM", "pASM.c", "x86-64"
371
371
logging .error (f"Read memory size { memory_size } is larger than chosen memory size { chosen_memory_size } " )
372
372
sys .exit (1 )
373
373
elif operand_size > target_operant_size :
374
- logging .error (f"Read operant size { operand_size } is larger than target operant size { target_operant_size } " )
374
+ logging .error (f"Read operand size { operand_size } is larger than target operand size { target_operant_size } " )
375
375
sys .exit (1 )
376
376
logging .info (f"Reset chosen memory size to { memory_size } to match read memory size" )
377
377
chosen_memory_size = memory_size
@@ -387,7 +387,7 @@ def main(input: str, output: str, target: _ty.Literal["pASM", "pASM.c", "x86-64"
387
387
if opcode in INSTRUCTION_SET : # Recognized opcode
388
388
instruction = INSTRUCTION_SET [opcode ]
389
389
if "STP" == instruction : # No operand
390
- f .read (operand_size ) # Need to discard the operant bits
390
+ f .read (operand_size ) # Need to discard the operand bits
391
391
pasm_lines .append (f"{ address :02} { instruction } " )
392
392
else :
393
393
operand_bytes = f .read (operand_size )
@@ -751,10 +751,10 @@ def main(input: str, output: str, target: _ty.Literal["pASM", "pASM.c", "x86-64"
751
751
else :
752
752
logging .debug (f"Skipped placeholder replacement and rel-jump resolution" )
753
753
if (int (cell .op1 .strip ("#()" ) or "0" ).bit_length () + 7 ) // 8 > target_operant_size :
754
- logging .error (f"Op1 of '{ cell } ' is larger than the target operant size" )
754
+ logging .error (f"Op1 of '{ cell } ' is larger than the target operand size" )
755
755
sys .exit (1 )
756
756
elif (int (cell .op2 .strip ("#()" ) or "0" ).bit_length () + 7 ) // 8 > target_operant_size :
757
- logging .error (f"Op2 of '{ cell } ' is larger than the target operant size" )
757
+ logging .error (f"Op2 of '{ cell } ' is larger than the target operand size" )
758
758
sys .exit (1 )
759
759
file_list .append (f"{ idx } { cell } \n " )
760
760
n += 1
@@ -933,8 +933,8 @@ def positive_nonzero_int(value):
933
933
parser .add_argument ("-o" , nargs = "?" , default = "" , help = "Path to the output file" )
934
934
parser .add_argument ("--target" , choices = ["pASM" , "pASM.c" , "x86-64" ], required = True ,
935
935
help = "Compilation target: pASM, pASM.c or x86-64" )
936
- parser .add_argument ("--target-operant -size" , type = positive_nonzero_int , default = 2 ,
937
- help = "A positive integer specifying the target operant size in bytes" )
936
+ parser .add_argument ("--target-operand -size" , type = positive_nonzero_int , default = 2 ,
937
+ help = "A positive integer specifying the target operand size in bytes" )
938
938
parser .add_argument ("--target-memory-size" , type = positive_nonzero_int , default = 0 ,
939
939
help = "A positive integer specifying the target memory size in bytes" )
940
940
parser .add_argument ("--logging-mode" , choices = ["DEBUG" , "INFO" , "WARN" , "ERROR" ], default = "INFO" ,
@@ -958,7 +958,7 @@ def positive_nonzero_int(value):
958
958
logging .error (f"The input file ({ input } ) needs to exist" )
959
959
sys .exit (1 )
960
960
elif args .target_operant_size > 4 :
961
- logging .error (f"The target operant size ({ args .target_operant_size } ) is bigger than the maximum allowed of 4" )
961
+ logging .error (f"The target operand size ({ args .target_operant_size } ) is bigger than the maximum allowed of 4" )
962
962
sys .exit (1 )
963
963
logging .info (f"Reading { input } , writing { output } " )
964
964
0 commit comments