'trap': (0x8a, OPERAND_TYPE_NONE),
}
+# these opcodes can be automatically generated by an OPERAND_TYPE_AUTO
+op_to_mnemonic = {
+ 0x23: 'offpc.i8',
+ 0x24: 'offpc.i16',
+ 0x25: 'offpc.i32',
+ 0x26: 'adjpc.i8',
+ 0x27: 'adjpc.i16',
+ 0x28: 'adjpc.i32',
+ 0x2b: 'offsp.i8',
+ 0x2c: 'offsp.i16',
+ 0x2d: 'offsp.i32',
+ 0x2e: 'adjsp.i8',
+ 0x2f: 'adjsp.i16',
+ 0x30: 'adjsp.i32',
+ 0x33: 'offix.i8',
+ 0x34: 'offix.i16',
+ 0x35: 'offix.i32',
+ 0x36: 'adjix.i8',
+ 0x37: 'adjix.i16',
+ 0x38: 'adjix.i32',
+ 0x3b: 'offiy.i8',
+ 0x3c: 'offiy.i16',
+ 0x3d: 'offiy.i32',
+ 0x3e: 'adjiy.i8',
+ 0x3f: 'adjiy.i16',
+ 0x40: 'adjiy.i32',
+ 0x7f: 'adjpc.f.i8',
+ 0x80: 'adjpc.f.i16',
+ 0x81: 'adjpc.f.i32',
+ 0x82: 'adjpc.t.i8',
+ 0x83: 'adjpc.t.i16',
+ 0x84: 'adjpc.t.i32',
+ 0x86: 'call.i8',
+ 0x87: 'call.i16',
+ 0x88: 'call.i32',
+}
+
# for auto operands
size_to_operand_type = {
1: OPERAND_TYPE_I8,
operand_type = size_to_operand_type[size]
op += operand_type - OPERAND_TYPE_I8
+ mnemonic = op_to_mnemonic[op]
if pc_rel:
next_pc = pc
main: ; stack alignment 0x10
; printing test
- imm.i32 hello_world
+ offpc hello_world@
call print_str@
adjsp -0xc
cvt.i32
push
- imm.i32 print_hex_table
+ offpc print_hex_table@
add
ld.i8
push
print_dec_pos:
- imm.i32 print_dec_buf_end
+ offpc print_dec_buf_end@
setix
pop.i128
adjix 1
getix
push
- imm.i32 print_dec_buf_end
+ offpc print_dec_buf_end@
lt.u
adjpc.t print_dec_loop1@
; entry is struct with threshold value (> 1) then scaling value (< 1)
; when multiplying it up:
; entry is struct with scaling value (> 1) then threshold value (< 1)
- imm.i32 print_sci_table
+ offpc print_sci_table@
setix
; if number is >= 1, exponent is positive and we'll divide it down
adjix 0x20
getix
push
- imm.i32 print_sci_table_end
+ offpc print_sci_table_end@
lt.u
adjpc.t print_sci_loop0@
adjix 0x20
getix
push
- imm.i32 print_sci_table_end
+ offpc print_sci_table_end@
lt.u
adjpc.t print_sci_loop1@
print_sci_no_overflow:
; render all 37 digits backwards into buffer
- imm.i32 print_sci_buf_end
+ offpc print_sci_buf_end@
setix
print_sci_loop2:
getix
push
- imm.i32 print_sci_buf
+ offpc print_sci_buf@
gt.u
adjpc.t print_sci_loop2@
adjix 1
getix
push
- imm.i32 print_sci_buf_end
+ offpc print_sci_buf_end@
lt.u
adjpc.t print_sci_loop3@