The moxie instruction set and encoding is evolving. Here's the current list of instructions and encodings supported in by the moxie 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 have been implemented).
Logical and. Performs a logical and operation on the contents of registers $rA and $rB and stores the result in $rA.
00100110AAAABBBB
Add, long. Adds the contents of registers $rA and $rB and stores the result in $rA.
00000101AAAABBBB
Arithmetic shift left. Performs an arithmetic shift left of $rA byt $rB bits and stores the result in $rA.
00101000AAAABBBB
Arithmetic shift right. Performs an arithmetic shift right of $rA byt $rB bits and stores the result in $rA.
00101101AAAABBBB
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
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
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
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
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
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
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
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
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
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
Break. The software breakpoint instruction.
00110101xxxxxxxx
Compare. Compares the contents of $rA to $rB and store the results in the processor's internal condition code register.
00001110AAAABBBB
Decrement. Decrement register $rA by the 8-bit value encoded in the 16-bit opcode.
1001AAAAiiiiiiii
Divide, long. Divides the signed contents of registers $rA and $rB and stores the result in $rA.
00110001AAAABBBB
Get special register. Move the contents of the special register S into $rA.
1010AAAASSSSSSSS
Increment. Increment register $rA by the 8-bit value encoded in the 16-bit opcode.
1000AAAAiiiiiiii
Jump. Jumps to the 32-bit address stored in $rA. This is not a subroutine call, and therefore the stack is not updated.
00100101AAAAxxxx
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
Jump to subroutine. Jumps to a subroutine at the address stored in $rA.
00011001AAAAxxxx
Jump to subroutine at absolute address. Jumps to a subroutine identified by the 32-bit address following the 16-bit opcode.
00000011xxxxxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Load byte. Loads the 8-bit contents stored at the address pointed to by $rB into $rA.
00011100AAAABBBB
Load long. Loads the 32-bit contents stored at the address pointed to by $rB into $rA.
00001010AAAABBBB
Load short. Loads the 16-bit contents stored at the address pointed to by $rB into $rA.
00010001AAAABBBB
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
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
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
Load immediate, long. Loads the 32-bit immediate following the 16-bit opcode into register %rA.
00000001AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
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
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
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
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
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
Logical shift right. Performs a logical shift right of register $rA by $rB bits and stores the result in $rA.
00100111AAAABBBB
Modulus, long. Compute the modulus of the signed contents of registers $rA and $rB and stores the result in $rA.
00110011AAAABBBB
Move register to register. Move the contents of $rB into $rA.
00000010AAAABBBB
Multiply, long. Multiplies the contents of registers $rA and $rB and stores the result in $rA.
00101111AAAABBBB
Negative. Changes the sign of $rB and stores the result in $rA.
00101010AAAABBBB
Do nothing.
00000000xxxxxxxx
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
Logical or. Performs a logical or operation on the contents of registers $rA and $rB and stores the result in $rA.
00101011AAAABBBB
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 the contents of $rB onto a stack pointed to by $rA and update the stack pointer. Stacks grown down.
00000110AAAABBBB
Return from subroutine.
00000100xxxxxxxx
Set special register. Move the contents of $rA into special register S.
1011AAAASSSSSSSS
Store byte. Stores the 8-bit contents of $rB into memory at the address pointed to by $rA.
00011110AAAABBBB
Store long. Stores the 32-bit contents of $rB into memory at the address pointed to by $rA.
00001011AAAABBBB
Store short. Stores the 16-bit contents of $rB into memory at the address pointed to by $rA.
00100011AAAABBBB
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
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
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
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
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
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
Subtract, long. Subtracts the contents of registers $rA and $rB and stores the result in $rA.
00101001AAAABBBB
Software interrupt. Trigger a software interrupt, where the interrupt type is encoded in the 32-bits following the 16-bit opcode.
00110000xxxxxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
Divide unsigned, long. Divides the unsigned contents of registers $rA and $rB and stores the result in $rA.
00110010AAAABBBB
Modulus unsigned, long. Compute the modulus of the unsigned contents of registers $rA and $rB and stores the result in $rA.
00110100AAAABBBB
Logical exclusive or. Performs a logical exclusive or operation on the contents of registers $rA and $rB and stores the result in $rA.
00101110AAAABBBB