# # Ace opcode reference # # The following is an assembly language which maps to Ace VM opcodes. # # Instruction names are usually followed by one of several letters: # # r double (64-bit floating point number, stored in two 32-bit slots) # i int (32-bit) # s string (variable-length array of char) # # Descriptions use the following letters: # # a The top slot of the stack. # b The second stack slot. # c The third stack slot. # d The fourth stack slot. # # Many instructions take no arguments. In these cases the information # is on the stack, or in local variables implied by the instruction name. # # Some instructions take arguments. This will always be a 24-bit integer. # Hex Name Arguments Description 00 nop do nothing # Loading constants 11 push_i x push literal 24-bit int n 12 const_i n push constant int 13 const_r n push constant real 14 const_s n push constant string # Loading variable 15 load_i n push local int variable n 18 load_r n push local real variable n 19 load_s n push local string variable n # Storing variables 36 store_i n store a in local int variable n 39 store_r n store ab in local real variable n 3A store_s n store a in local string variable n # Stack manipulation 57 pop remove a 59 dup duplicate a 5F swap swap a and b # Arithmetic 60 add_i add int (a+b) 62 add_r add real (a+b) 63 add_s append string (a+b) 64 sub_i subtract int (a-b) 66 sub_r subtract real (a-b) 67 sub_s substring of a from int [b:c] 68 mul_i multiply int (a*b) 6A mul_r multply real (a*b) 6B mul_s multiply string a by int b times 6C div_i divide int (a/b) 6E div_r divide real (a/b) 70 rem_i remainder int (a%b) 72 rem_r remainder real (a%b) 74 neg_i negate int (-a) 76 neg_r negate real (-a) 78 shl_i shift int left (a << b) 79 shl_s shift string left (a[b:]) 7A shr_i shift int right (a >> b) 7B shr_s shift string right (a[:-b]) 7C ushr_i unsigned shift int right (a >>> b) 7E and_i bitwise int and (a & b) 80 or_i bitwise int or (a | b) 82 xor_i bitwise int xor (a ^ b) 83 in_s string a within string b? 84 inc_i n increment local variable n by 1 # Conversion 87 i_to_r convert int a to real 88 i_to_s convert int a to string 8E r_to_i convert real a to int 8F r_to_s convert real a to string 90 s_to_i read int from string a 91 s_to_r read real from string a # Comparison 94 cmp_i compare int a and b (a-b) 95 cmp_r compare real a and b (a-b) 96 cmp_s compare string a and b (a= 0 9D if_gt label branch if int a > 0 9E if_le label branch if int a <= 0 9F if_cmpeq label branch if int a == b A0 if_cmpne label branch if int a != b A1 if_cmplt label branch if int a < b A2 if_cmpge label branch if int a >= b A3 if_cmpgt label branch if int a > b A4 if_cmple label branch if int a <= b A5 if_cmpeq label branch if reference a == b A6 if_cmpne label branch if reference a != b A7 goto label branch always to label A8 jsr label branch to label; push return location A9 ret n branch to location in variable n AC i_return return int from method AF d_return return double from method B0 r_return return reference from method B1 return return from method # Access B4 getfield class/field desc push object field B5 putfield class/field desc store a in object field B6 invokevirtual class/method desc invoke method virtually # Objects BB new class create new object of class BC newarray type create array of type, length a BD a_newarray class create array of class, length a BE arraylength push length of array BF throw throw exception a C0 checktype class throw exception if a is not an instance of class C1 instanceof class push 1 if a is class, 0 otherwise # Extras C5 multinewarray class n create multidimensional array with first n dimensions initialized to lengths a, b, c...