The moxie instruction set and encoding is evolving. Here's the current list of instructions and encodings supported in by the moxie [[Toolchain|toolchain]].
All instructions are 16-bits long. Some 16-bit instructions are followed by a 32-bit immediate value. All of the opcode space not consumed by the encodings below is filled with the bad instruction (which will eventually cause an exception once [[Exceptions|exceptions]] have been implemented).
===and===
Logical and. Performs a logical and operation on the contents of registers $rA and $rB and stores the result in $rA.
00100110AAAABBBB
===add.l===
Add, long. Adds the contents of registers $rA and $rB and stores the result in $rA.
00000101AAAABBBB
===ashl===
Arithmetic shift left. Performs an arithmetic shift left of $rA byt $rB bits and stores the result in $rA.
00101000AAAABBBB
===ashr===
Arithmetic shift right. Performs an arithmetic shift right of $rA byt $rB bits and stores the result in $rA.
00101101AAAABBBB
===beq===
Branch if equal. If the results of the last cmp demonstrated that $rA is equal to $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
110000vvvvvvvvvv
===bge===
Branch if greater than or equal. If the results of the last cmp demonstrated that the signed 32-bit value in $rA is greater than or equal to the signed 32-bit value in $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
110110vvvvvvvvvv
===bgeu===
Branch if greater than or equal, unsigned. If the results of the last cmp demonstrated that the unsigned 32-bit value in $rA is greater than or equal to the unsigned 32-bit value in $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
111000vvvvvvvvvv
===bgt===
Branch if greater than. If the results of the last cmp demonstrated that the signed 32-bit value in $rA is greater than the signed 32-bit value in $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
110011vvvvvvvvvv
===bgtu===
Branch if greater than, unsigned. If the results of the last cmp demonstrated that the unsigned 32-bit value in $rA is greater than the unsigned 32-bit value in $rB, branch to the address computed by the adding the signed 10-bit immediate value to the program counter.
1100101vvvvvvvvv
===ble===
Branch if less than or equal. If the results of the last cmp demonstrated that the signed 32-bit value in $rA is less than or equal to the signed 32-bit value in $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
110111vvvvvvvvvv
===bleu===
Branch if less than or equal, unsigned. If the results of the last cmp demonstrated that the unsigned 32-bit value in $rA is less than or equal to the unsigned 32-bit value in $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
111001vvvvvvvvvv
===blt===
Branch if less than. If the results of the last cmp demonstrated that the signed 32-bit value in $rA is less than the signed 32-bit value in $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
110010vvvvvvvvvv
===bltu===
Branch if less than, unsigned. If the results of the last cmp demonstrated that the unsigned 32-bit value in $rA is less than the unsigned 32-bit value in $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
110100vvvvvvvvvv
===bne===
Branch if not equal. If the results of the last cmp demonstrated that $rA is not equal to $rB, branch to the address computed by adding the signed 10-bit immediate value to the program counter.
110001vvvvvvvvvv
===brk===
Break. The software breakpoint instruction.
00110101xxxxxxxx
===cmp===
Compare. Compares the contents of $rA to $rB and store the results in the processor's internal condition code register.
00001110AAAABBBB
===dec===
Decrement. Decrement register $rA by the 8-bit value encoded in the 16-bit opcode.
1001AAAAiiiiiiii
===div.l===
Divide, long. Divides the signed contents of registers $rA and $rB and stores the result in $rA.
00110001AAAABBBB
===gsr===
Get special register. Move the contents of the special register S into $rA.
1010AAAASSSSSSSS
===inc===
Increment. Increment register $rA by the 8-bit value encoded in the 16-bit opcode.
1000AAAAiiiiiiii
===jmp===
Jump. Jumps to the 32-bit address stored in $rA. This is not a subroutine call, and therefore the stack is not updated.
00100101AAAAxxxx
===jmpa===
Jump to address. Jumps to the 32-bit address following the 16-bit opcode. This is not a subroutine call, and therefore the stack is not updated.
00011010xxxxxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===jsr===
Jump to subroutine. Jumps to a subroutine at the address stored in $rA.
00011001AAAAxxxx
===jsra===
Jump to subroutine at absolute address. Jumps to a subroutine identified by the 32-bit address following the 16-bit opcode.
00000011xxxxxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===ld.b===
Load byte. Loads the 8-bit contents stored at the address pointed to by $rB into $rA.
00011100AAAABBBB
===ld.l===
Load long. Loads the 32-bit contents stored at the address pointed to by $rB into $rA.
00001010AAAABBBB
===ld.s===
Load short. Loads the 16-bit contents stored at the address pointed to by $rB into $rA.
00010001AAAABBBB
===lda.b===
Load absolute, byte. Loads the 8-bit value pointed at by the 32-bit address following the 16-bit opcode into register $rA.
00011101AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===lda.l===
Load absolute, long. Loads the 32-bit value pointed at by the 32-bit address following the 16-bit opcode into register $rA.
00001000AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===lda.s===
Load absolute, short. Loads the 16-bit value pointed at by the 32-bit address following the 16-bit opcode into register $rA.
00010011AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===ldi.l===
Load immediate, long. Loads the 32-bit immediate following the 16-bit opcode into register %rA.
00000001AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===ldi.b===
Load immediate, byte. Loads the 32-bit immediate following the 16-bit opcode into register %rA. This is a poor encoding, as the 32-bit value really only contains 8-bits of interest.
00011011AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===ldi.s===
Load immediate, short. Loads the 32-bit immediate following the 16-bit opcode into register %rA. This is a poor encoding, as the 32-bit value really only contains 16-bits of interest.
00100000AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===ldo.b===
Load offset, byte. Loads into $rA the 8-bit value from memory pointed at by the address produced by adding the 32-bit value following the 16-bit opcode to $rB.
00110110AAAABBBB iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===ldo.l===
Load offset, long. Loads into $rA the 32-bit value from memory pointed at by the address produced by adding the 32-bit value following the 16-bit opcode to $rB.
00001100AAAABBBB iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===ldo.s===
Load offset, short. Loads into $rA the 16-bit value from memory pointed at by the address produced by adding the 32-bit value following the 16-bit opcode to $rB.
00111000AAAABBBB iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===lshr===
Logical shift right. Performs a logical shift right of register $rA by $rB bits and stores the result in $rA.
00100111AAAABBBB
===mod.l===
Modulus, long. Compute the modulus of the signed contents of registers $rA and $rB and stores the result in $rA.
00110011AAAABBBB
===mov===
Move register to register. Move the contents of $rB into $rA.
00000010AAAABBBB
===mul.l===
Multiply, long. Multiplies the contents of registers $rA and $rB and stores the result in $rA.
00101111AAAABBBB
===neg===
Negative. Changes the sign of $rB and stores the result in $rA.
00101010AAAABBBB
===nop===
Do nothing.
00000000xxxxxxxx
===not===
Logical not. Performs a logical not operation on the contents of register $rB and stores the result in register $rAA and $rB and stores the result in $rA.
00101100AAAABBBB
===or===
Logical or. Performs a logical or operation on the contents of registers $rA and $rB and stores the result in $rA.
00101011AAAABBBB
===pop===
Pop the 32-bit contents of the top of the stack pointed to by $rB into $rA and update the stack pointer. Stacks grown down.
00000111AAAABBBB
===push===
Push the contents of $rB onto a stack pointed to by $rA and update the stack pointer. Stacks grown down.
00000110AAAABBBB
===ret===
Return from subroutine.
00000100xxxxxxxx
===ssr===
Set special register. Move the contents of $rA into special register S.
1011AAAASSSSSSSS
===st.b===
Store byte. Stores the 8-bit contents of $rB into memory at the address pointed to by $rA.
00011110AAAABBBB
===st.l===
Store long. Stores the 32-bit contents of $rB into memory at the address pointed to by $rA.
00001011AAAABBBB
===st.s===
Store short. Stores the 16-bit contents of $rB into memory at the address pointed to by $rA.
00100011AAAABBBB
===sta.b===
Store absolute, byte. Stores the lower 8-bit contents of $rA into memory at the 32-bit address following the 16-bit opcode.
00011111AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===sta.l===
Store absolute, long. Stores the full 32-bit contents of $rA into memory at the 32-bit address following the 16-bit opcode.
00001001AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===sta.s===
Store absolute, short. Stores the lower 16-bit contents of $rA into memory at the 32-bit address following the 16-bit opcode.
00100100AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===sto.b===
Store offset, byte. Stores the 8-bit contents of $rB into memory at the address roduced by adding the 32-bit value following the 16-bit opcode to $rA.
00110111AAAABBBB iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===sto.l===
Store offset, long. Stores the 32-bit contents of $rB into memory at the address roduced by adding the 32-bit value following the 16-bit opcode to $rA.
00001101AAAABBBB iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===sto.s===
Store offset, short. Stores the 16-bit contents of $rB into memory at the address roduced by adding the 32-bit value following the 16-bit opcode to $rA.
00111001AAAABBBB iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===sub.l===
Subtract, long. Subtracts the contents of registers $rA and $rB and stores the result in $rA.
00101001AAAABBBB
===swi===
Software interrupt. Trigger a software interrupt, where the interrupt type is encoded in the 32-bits following the 16-bit opcode.
00110000xxxxxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
===udiv.l===
Divide unsigned, long. Divides the unsigned contents of registers $rA and $rB and stores the result in $rA.
00110010AAAABBBB
===umod.l===
Modulus unsigned, long. Compute the modulus of the unsigned contents of registers $rA and $rB and stores the result in $rA.
00110100AAAABBBB
===xor===
Logical exclusive or. Performs a logical exclusive or operation on the contents of registers $rA and $rB and stores the result in $rA.
00101110AAAABBBB