Index ¦ Archives ¦ Atom ¦ RSS

Architecture

Overview

Moxie is a general purpose bi-endian load-store processor, with sixteen 32-bit general purpose registers and a comprehensive ISA. It was originally designed to be an ideal target for the GNU Compiler Collection, and has since evolved to include many supervisory level instructions required to run an embedded RTOS such has RTEMS.

Most moxie instructions are 16-bits long, while the remainder include an additional 16- or 32-bit immediate value resulting in 32- and 48-bit instructions. A variable width instruction architecture was chosen over a fixed-width RISC implementation in order to optimize for instruction memory bandwidth, a key performance limiter for many FPGA applications.

As a fair warning to readers, it should be mentioned that the moxie architecture is still evolving. That being said, there have been few changes in recent history. Feedback, of course, is certainly welcome! Please send all comments to the author.

Registers

Moxie defines 16 32-bit registers as follows:

NameDescription
$fpthe frame pointer
$spthe stack pointer
$r0 through $r13general purpose registers
In addition, there are a number of special registers whose values are accessible only with the Get Special Register (gsr) and Set Special Registers (ssr) instructions. Some of these registers have special purposes:

Special RegisterDescription
0status regsiter with the following bit values:
1a pointer to the Exception Handler routine (invoked by swi, IRQs, Divide by Zero and illegal instructions (bad))
2upon invocation of the Excecption Handler (see above), special register 2 will have one of four values..
3the swi request number (by convention)
4address of the supervisor mode stack on which exceptions are executed
5return address upon entering the exception handler
6reserved
7reserved
8reserved
9an optional non-zero pointer to the Device Tree blob describing this device

Instruction Set

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.

and00100110AAAABBBB

Logical and. Performs a logical and operation on the contents of registers $rA and $rB and stores the result in $rA.

add00000101AAAABBBB

Add, long. Adds the contents of registers $rA and $rB and stores the result in $rA.

ashl00101000AAAABBBB

Arithmetic shift left. Performs an arithmetic shift left of $rA byt $rB bits and stores the result in $rA.

ashr00101101AAAABBBB

Arithmetic shift right. Performs an arithmetic shift right of $rA byt $rB bits and stores the result in $rA.

beq110000vvvvvvvvvv

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 shifted to the left by 1 to the program counter. The branch is relative to the start of this instruction.

bge110110vvvvvvvvvv

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 shifted to the left by 1 to the program counter. The branch is relative to the address of this instruction.

bgeu111000vvvvvvvvvv

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 shifted to the left by 1 bit to the program counter. The branch is relative to the address of this instruction.

bgt110011vvvvvvvvvv

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 shifted to the left by 1 bit to the program counter. The branch is relative to the address of this instruction.

bgtu110101vvvvvvvvvv

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 shifted to the left by 1 bit to the program counter. The branch is relative to the address of this instruction.

ble110111vvvvvvvvvv

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 shifted to the left by 1 bit to the program counter. The branch is relative to the address of this instruction.

bleu111001vvvvvvvvvv

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. The branch is relative to the address of this instruction.

blt110010vvvvvvvvvv

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 shifted to the left by 1 bit to the program counter. The branch is relative to the address of this instruction.

bltu110100vvvvvvvvvv

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 shifted to the left by 1 bit to the program counter. The branch is relative to the address of this instruction.

bne110001vvvvvvvvvv

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 shifted to the left by 1 bit to the program counter. The branch is relative to the address of this instruction.

brk00110101xxxxxxxx

Break. The software breakpoint instruction.

cmp00001110AAAABBBB

Compare. Compares the contents of $rA to $rB and store the results in the processor's internal condition code register. This is the only instruction that updates the internal condition code register used by the branch instructions.

dec1001AAAAiiiiiiii

Decrement. Decrement register $rA by the 8-bit value encoded in the 16-bit opcode.

div00110001AAAABBBB

Divide, long. Divides the signed contents of registers $rA and $rB and stores the result in $rA. Two special cases are handled here: division by zero asserts an Divide by Zero [[Exceptions|Exception]], and INT_MIN divided by -1 results in INT_MIN.

gsr1010AAAASSSSSSSS

Get special register. Move the contents of the special register S into $rA.

inc1000AAAAiiiiiiii

Increment. Increment register $rA by the 8-bit value encoded in the 16-bit opcode.

jmp00100101AAAAxxxx

Jump. Jumps to the 32-bit address stored in $rA. This is not a subroutine call, and therefore the stack is not updated.

jmpa00011010xxxxxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

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.

jsr00011001AAAAxxxx

Jump to subroutine. Jumps to a subroutine at the address stored in $rA.

jsra00000011xxxxxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Jump to subroutine at absolute address. Jumps to a subroutine identified by the 32-bit address following the 16-bit opcode.

ld.b00011100AAAABBBB

Load byte. Loads the 8-bit contents stored at the address pointed to by $rB into $rA. The loaded value is zero-extended to 32-bits.

ld.l00001010AAAABBBB

Load long. Loads the 32-bit contents stored at the address pointed to by $rB into $rA.

ld.s00100001AAAABBBB

Load short. Loads the 16-bit contents stored at the address pointed to by $rB into $rA. The loaded value is zero-extended to 32-bits.

lda.b00011101AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Load absolute, byte. Loads the 8-bit value pointed at by the 32-bit address following the 16-bit opcode into register $rA. The loaded value is zero-extended to 32-bits.

lda.l00001000AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Load absolute, long. Loads the 32-bit value pointed at by the 32-bit address following the 16-bit opcode into register $rA.

lda.s00100010AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Load absolute, short. Loads the 16-bit value pointed at by the 32-bit address following the 16-bit opcode into register $rA. The loaded value is zero-extended to 32-bits.

ldi.l00000001AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Load immediate, long. Loads the 32-bit immediate following the 16-bit opcode into register %rA.

ldi.b00011011AAAAxxxx 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.

ldi.s00100000AAAAxxxx 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.

ldo.b00110110AAAABBBB iiiiiiiiiiiiiiii

Load offset, byte. Loads into $rA the 8-bit value from memory pointed at by the address produced by adding the 16-bit value following the 16-bit opcode to $rB. The loaded value is zero-extended to 32-bits.

ldo.l00001100AAAABBBB iiiiiiiiiiiiiiii

Load offset, long. Loads into $rA the 32-bit value from memory pointed at by the address produced by adding the 16-bit value following the 16-bit opcode to $rB.

ldo.s00111000AAAABBBB iiiiiiiiiiiiiiii

Load offset, short. Loads into $rA the 16-bit value from memory pointed at by the address produced by adding the 16-bit value following the 16-bit opcode to $rB. The loaded value is zero-extended to 32-bits.

lshr00100111AAAABBBB

Logical shift right. Performs a logical shift right of register $rA by $rB bits and stores the result in $rA.

mod00110011AAAABBBB

Modulus, long. Compute the modulus of the signed contents of registers $rA and $rB and stores the result in $rA.

mov00000010AAAABBBB

Move register to register. Move the contents of $rB into $rA.

mul00101111AAAABBBB

Multiply. Multiplies the contents of registers $rA and $rB and stores the lower 32-bits of a 64-bit result in $rA.

mul.x00010101AAAABBBB

Signed multiply, upper word. Multiplies the contents of registers $rA and $rB and stores the upper 32-bits of a 64-bit result in $rA.

neg00101010AAAABBBB

Negative. Changes the sign of $rB and stores the result in $rA.

nop00001111xxxxxxxx

Do nothing.

not00101100AAAABBBB

Logical not. Performs a logical not operation on the contents of register $rB and stores the result in register $rA.

or00101011AAAABBBB

Logical or. Performs a logical or operation on the contents of registers $rA and $rB and stores the result in $rA.

pop00000111AAAABBBB

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.

push00000110AAAABBBB

Push the contents of $rB onto a stack pointed to by $rA and update the stack pointer. Stacks grown down.

ret00000100xxxxxxxx

Return from subroutine.

sex.b00010000AAAABBBB

Sign-extend byte. Sign-extend the lower 8-bits of $rB into a $rA as a 32-bit value.

sex.s00010001AAAABBBB

Sign-extend short. Sign-extend the lower 16-bits of $rB into a $rA as a 32-bit value.

ssr1011AAAASSSSSSSS

Set special register. Move the contents of $rA into special register S.

st.b00011110AAAABBBB

Store byte. Stores the 8-bit contents of $rB into memory at the address pointed to by $rA.

st.l00001011AAAABBBB

Store long. Stores the 32-bit contents of $rB into memory at the address pointed to by $rA.

st.s00100011AAAABBBB

Store short. Stores the 16-bit contents of $rB into memory at the address pointed to by $rA.

sta.b00011111AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Store absolute, byte. Stores the lower 8-bit contents of $rA into memory at the 32-bit address following the 16-bit opcode.

sta.l00001001AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Store absolute, long. Stores the full 32-bit contents of $rA into memory at the 32-bit address following the 16-bit opcode.

sta.s00100100AAAAxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Store absolute, short. Stores the lower 16-bit contents of $rA into memory at the 32-bit address following the 16-bit opcode.

sto.b00110111AAAABBBB iiiiiiiiiiiiiiii

Store offset, byte. Stores the 8-bit contents of $rB into memory at the address roduced by adding the 16-bit value following the 16-bit opcode to $rA.

sto.l00001101AAAABBBB iiiiiiiiiiiiiiii

Store offset, long. Stores the 32-bit contents of $rB into memory at the address roduced by adding the 16-bit value following the 16-bit opcode to $rA.

sto.s00111001AAAABBBB iiiiiiiiiiiiiiii

Store offset, short. Stores the 16-bit contents of $rB into memory at the address roduced by adding the 16-bit value following the 16-bit opcode to $rA.

sub00101001AAAABBBB

Subtract, long. Subtracts the contents of registers $rA and $rB and stores the result in $rA.

swi00110000xxxxxxxx iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii

Software interrupt. Trigger a software interrupt, where the interrupt type is encoded in the 32-bits following the 16-bit opcode.

udiv00110010AAAABBBB

Divide unsigned, long. Divides the unsigned contents of registers $rA and $rB and stores the result in $rA.

umod00110100AAAABBBB

Modulus unsigned, long. Compute the modulus of the unsigned contents of registers $rA and $rB and stores the result in $rA.

umul.x00010100AAAABBBB

Unsigned multiply, upper word. Multiplies the contents of registers $rA and $rB and stores the upper 32-bits of an unsigned 64-bit result in $rA.

xor00101110AAAABBBB

Logical exclusive or. Performs a logical exclusive or operation on the contents of registers $rA and $rB and stores the result in $rA.

zex.b00010010AAAABBBB

Zero-extend byte. Zero-extend the lower 8-bits of $rB into a $rA as a 32-bit value.

zex.s00010011AAAABBBB

Zero-extend short. Zero-extend the lower 16-bits of $rB into a $rA as a 32-bit value.

© Anthony Green. Built using Pelican. Theme by Giulio Fidente on github.