RBCPU Instruction Set

Mattias Gustavsson, May 16, 2009

Here's a list of all the available instructions for the RetroBox CPU, their syntax, effect and what datatypes and operands they work on.

nop

Syntax  nop
Effect  No operation

 

jsr

Syntax  jsr operandA
Effect  Jump to subroutine at location specified by operandA. Will push the current value of IP onto the stack before the jump.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

jmp

Syntax  jmp operandA
Effect  Jump to location specified by operandA.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

ret

Syntax  ret
Effect  Return from subroutine call made by jsr. Will pop the return address off the stack.

 

sys

Syntax  sys operandA
Effect  Make a BIOS call. See the BIOS documentation for available BIOS calls.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
@label
x
freg
fval

 

move

Syntax  move<.b/.w/.l/.f> operandA,operandB
Effect  Move the value specified by operandA to the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
x
x
fval
x

 

add

Syntax  add<.b/.w/.l/.f> operandA,operandB
Effect  Add the value specified by operandA to the value at the location specified by operandB, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
x
x
fval
x

 

sub

Syntax  sub<.b/.w/.l/.f> operandA,operandB
Effect  Subtract the value specified by operandA from the value at the location specified by operandB, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
x
x
fval
x

 

neg

Syntax  neg<.b/.w/.l/.f> operandA
Effect  Negate the value at the location specified by operandA
Operand Types
    operandA  
ireg
x
@ireg
x
ival
@ival
x
label
@label
x
freg
fval

 

muls

Syntax  muls<.b/.w/.l> operandA,operandB
Effect  Multiply the value specified by operandA and the value at the location specified by operandB, and store the result at the location specified by operandB. Treat operandA and operandB as signed integer numbers.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

mulu

Syntax  mulu<.b/.w/.l> operandA,operandB
Effect  Multiply the value specified by operandA and the value at the location specified by operandB, and store the result at the location specified by operandB. Treat operandA and operandB as unsigned integer numbers.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

mul

Syntax  mul.f operandA,operandB
Effect  Multiply the value specified by operandA and the value at the location specified by operandB, and store the result at the location specified by operandB. Treat operandA and operandB as floating point numbers.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
x
freg
x
x
fval
x

 

divs

Syntax  divs<.b/.w/.l> operandA,operandB
Effect  Divide the value at the location specified by operandB by the value specified by operandA, and store the result at the location specified by operandB. Treat operandA and operandB as signed integer numbers.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

divu

Syntax  divu<.b/.w/.l> operandA,operandB
Effect  Divide the value at the location specified by operandB by the value specified by operandA, and store the result at the location specified by operandB. Treat operandA and operandB as unsigned integer numbers.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

div

Syntax  div.f operandA,operandB
Effect  Divide the value at the location specified by operandB by the value specified by operandA, and store the result at the location specified by operandB. Treat operandA and operandB as floating point numbers.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
x
freg
x
x
fval
x

 

itof

Syntax  itof<.b/.w/.l> operandA,operandB
Effect  Convert the value specified by operandA from an integer value into an floating point value, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
x
fval

 

ftoi

Syntax  ftoi<.b/.w/.l> operandA,operandB
Effect  Convert the value specified by operandA from a floating point value into an integer value, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
@ireg
x
x
ival
@ival
x
x
label
@label
x
x
freg
x
fval
x

 

cmpu

Syntax  cmpu<.b/.w/.l> operandA,operandB
Effect  Compare the value specified by operandA with the value specified by operandB. Treat operandA and operandB as unsigned integers. The result is used in the next call to je, jne, jge, jle, jg, or jl.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

cmps

Syntax  cmps<.b/.w/.l> operandA,operandB
Effect  Compare the value specified by operandA with the value specified by operandB. Treat operandA and operandB as signed integers. The result is used in the next call to je, jne, jge, jle, jg, or jl.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

cmp

Syntax  cmp.f operandA,operandB
Effect  Compare the value specified by operandA with the value specified by operandB. Treat operandA and operandB as floating point numbers. The result is used in the next call to je, jne, jge, jle, jg, or jl.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
x
freg
x
x
fval
x

 

je

Syntax  je operandA
Effect  Jump to location specified by operandA, if in the last compare (cmpu, cmps or cmp), operandA was equal to operandB.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

jne

Syntax  jne operandA
Effect  Jump to location specified by operandA, if in the last compare (cmpu, cmps or cmp), operandA was not equal to operandB.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

jge

Syntax  jge operandA
Effect  Jump to location specified by operandA, if in the last compare (cmpu, cmps or cmp), operandA was greater than or equal to operandB.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

jle

Syntax  jle operandA
Effect  Jump to location specified by operandA, if in the last compare (cmpu, cmps or cmp), operandA was less than or equal to operandB.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

jg

Syntax  jg operandA
Effect  Jump to location specified by operandA, if in the last compare (cmpu, cmps or cmp), operandA was greater than operandB.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

jl

Syntax  jl operandA
Effect  Jump to location specified by operandA, if in the last compare (cmpu, cmps or cmp), operandA was less than operandB.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

tst

Syntax  tst<.b/.w/.l/.f> operandA
Effect  Test if value specified by operandA is zero. The result is used in the next call to jz or jnz.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
x
fval
x

 

jz

Syntax  jz operandA
Effect  Jump to location specified by operandA, if in the last test (tst or btst), the result was zero.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

jnz

Syntax  jnz operandA
Effect  Jump to location specified by operandA, if in the last test (tst or btst), the result was non-zero
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
fval

 

push

Syntax  push<.b/.w/.l/.f> operandA
Effect  Push the value specified by operandA onto the stack.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
x
@ival
x
label
x
@label
x
freg
x
fval
x

 

pop

Syntax  pop<.b/.w/.l/.f> operandA
Effect  Pop a value off the stack, and store it at the location specified by operandA.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
@ival
x
label
@label
x
freg
x
fval

 

and

Syntax  and<.b/.w/.l> operandA,operandB
Effect  Perform a bitwise AND on the value specified by operandA and the value at the location specified by operandB, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

or

Syntax  or<.b/.w/.l> operandA,operandB
Effect  Perform a bitwise OR on the value specified by operandA and the value at the location specified by operandB, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

xor

Syntax  xor<.b/.w/.l> operandA,operandB
Effect  Perform a bitwise XOR on the value specified by operandA and the value at the location specified by operandB, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

not

Syntax  not<.b/.w/.l> operandA
Effect  Perform a bitwise NOT on the value at the location specified by operandA.
Operand Types
    operandA  
ireg
x
@ireg
x
ival
@ival
x
label
@label
x
freg
fval

 

bset

Syntax  bset<.b/.w/.l> operandA,operandB
Effect  Set the bit at bit index specified by operandA, in the value at the location specified by operandB. Bit indices start at 0 and increase with significance.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

bclr

Syntax  bclr<.b/.w/.l> operandA,operandB
Effect  Clear the bit at bit index specified by operandA, in the value at the location specified by operandB. Bit indices start at 0 and increase with significance.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

btst

Syntax  btst<.b/.w/.l> operandA,operandB
Effect  Test the bit at bit index specified by operandA, in the value at the location specified by operandB. Bit indices start at 0 and increase with significance. The result is used in the next call to jz or jnz.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

rol

Syntax  rol<.b/.w/.l> operandA,operandB
Effect  Perform a bitwise left shift of the value at the location specified by operandB. Number of bits to shift is the value specified by operandA.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

ror

Syntax  ror<.b/.w/.l> operandA,operandB
Effect  Perform a bitwise right shift of the value at the location specified by operandB. Number of bits to shift is the value specified by operandA.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
fval

 

mod

Syntax  mod<.b/.w/.l/.f> operandA,operandB
Effect  Perform MOD on operandB by operandA and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
x
x
fval
x

 

abs

Syntax  abs<.b/.w/.l/.f> operandA,operandB
Effect  Perform ABS on operandA and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
x
x
fval
x

 

pow

Syntax  pow<.b/.w/.l/.f> operandA,operandB
Effect  Perform POW on operandB by operandA and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
x
x
@ireg
x
x
ival
x
@ival
x
x
label
x
@label
x
x
freg
x
x
fval
x

 

sin

Syntax  sin.f operandA,operandB
Effect  Calculate SIN of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x

 

cos

Syntax  cos.f operandA,operandB
Effect  Calculate COS of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x

 

tan

Syntax  tan.f operandA,operandB
Effect  Calculate TAN of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x

 

asin

Syntax  asin.f operandA,operandB
Effect  Calculate ASIN of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x

 

acos

Syntax  acos.f operandA,operandB
Effect  Calculate ACOS of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x

 

atan

Syntax  atan.f operandA,operandB
Effect  Calculate ATAN of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x

 

sqrt

Syntax  sqrt.f operandA,operandB
Effect  Calculate SQRT of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x

 

log

Syntax  log.f operandA,operandB
Effect  Calculate LOG of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x

 

exp

Syntax  exp.f operandA,operandB
Effect  Calculate EXP of the value specified by operandA, and store the result at the location specified by operandB.
Operand Types
    operandA     operandB  
ireg
@ireg
x
x
ival
@ival
x
x
label
@label
x
freg
x
x
fval
x