misc
Interface RISC


public interface RISC


Nested Class Summary
static class RISC.Helper
           
 
Field Summary
static int ADD
          Opcode: integer addition.
static int ADDI
          Opcode: integer addition with signed immediate.
static int ADDIU
          Opcode: integer addition with unsigned immediate.
static int AND
          Opcode: logical and.
static int ANDI
          Opcode: logical and with signed immediate.
static int ANDIU
          Opcode: logical and with unsigned immediate.
static int ASH
          Opcode: arithmetic shift.
static int ASHI
          Opcode: arithmetic shift with signed immediate.
static int BEQ
          Opcode: branch if equal.
static int BGE
          Opcode: branch if greater or equal.
static int BGT
          Opcode: branch if greater than.
static int BIC
          Opcode: logical bic.
static int BICI
          Opcode: logical bic with signed immediate.
static int BICIU
          Opcode: logical bic with unsigned immediate.
static int BLE
          Opcode: branch if equal less or equal.
static int BLT
          Opcode: branch if less than.
static int BNE
          Opcode: branch if not equal.
static int BREAK
          Opcode: stop execution and return to debugger.
static int BSR
          Opcode: branch to subroutine.
static int CHK
          Opcode: bound check.
static int CHKI
          Opcode: bound check with signed immediate.
static int CHKIU
          Opcode: bound check with unsigned immediate.
static int CMP
          Opcode: integer comparison.
static int CMPI
          Opcode: integer comparison with signed immediate.
static int CMPIU
          Opcode: integer comparison with unsigned immediate.
static int DIV
          Opcode: integer division.
static int DIVI
          Opcode: integer division with signed immediate.
static int DIVIU
          Opcode: integer division with unsigned immediate.
static int JSR
          Opcode: jump to subroutine.
static int LDB
          Opcode: load byte from memory.
static int LDW
          Opcode: load word from memory.
static int LNK
          Register: return address
static int LSH
          Opcode: logical shift.
static int LSHI
          Opcode: logical shift with signed immediate.
static java.lang.String[] mnemonics
          String representation of instructions
static int MOD
          Opcode: integer modulo.
static int MODI
          Opcode: integer modulo with signed immediate.
static int MODIU
          Opcode: integer modulo with unsigned immediate.
static int MUL
          Opcode: integer multiplication.
static int MULI
          Opcode: integer multiplication with signed immediate.
static int MULIU
          Opcode: integer multiplication with unsigned immediate.
static int OR
          Opcode: logical or.
static int ORI
          Opcode: logical or with signed immediate.
static int ORIU
          Opcode: logical or with unsigned immediate.
static int POP
          Opcode: pop word from stack.
static int PSH
          Opcode: push word on stack.
static int RES
          Register: return value
static int RET
          Opcode: jump to return address.
static int SP
          Register: stack pointer
static int STB
          Opcode: store byte into memory.
static int STW
          Opcode: store word into memory.
static int SUB
          Opcode: integer subtraction.
static int SUBI
          Opcode: integer subtraction with signed immediate.
static int SUBIU
          Opcode: integer subtraction with unsigned immediate.
static int SYS_EXIT
          System call: terminate the emulation.
static int SYS_GC_ALLOC
          System call: allocate a memory block from the heap.
static int SYS_GC_INIT
          System call: initialize the garbage collector.
static int SYS_GET_TOTAL_MEM_SIZE
          System call: get memory size.
static int SYS_IO_RD_CHR
          System call: read one character.
static int SYS_IO_RD_INT
          System call: read an integer.
static int SYS_IO_WR_CHR
          System call: write one character.
static int SYS_IO_WR_INT
          System call: write an integer.
static int SYSCALL
          Opcode: invoke a system function.
static int WORD_SIZE
          The word size
static int XOR
          Opcode: logical xor.
static int XORI
          Opcode: logical xor with signed immediate.
static int XORIU
          Opcode: logical xor with unsigned immediate.
static int ZERO
          Register: zero
 

Field Detail

WORD_SIZE

public static final int WORD_SIZE
The word size

See Also:
Constant Field Values

ADD

public static final int ADD

Opcode: integer addition.

ADD a b c
R.a = R.b + R.c

See Also:
Constant Field Values

SUB

public static final int SUB

Opcode: integer subtraction.

SUB a b c
R.a = R.b - R.c

See Also:
Constant Field Values

MUL

public static final int MUL

Opcode: integer multiplication.

MUL a b c
R.a = R.b * R.c

See Also:
Constant Field Values

DIV

public static final int DIV

Opcode: integer division.

DIV a b c
R.a = R.b / R.c

See Also:
Constant Field Values

MOD

public static final int MOD

Opcode: integer modulo.

MOD a b c
R.a = R.b % R.c

See Also:
Constant Field Values

CMP

public static final int CMP

Opcode: integer comparison.

CMP a b c
R.a = <a value with the same sign as (R.b - R.c) but with a possibly different magnitude>

See Also:
Constant Field Values

OR

public static final int OR

Opcode: logical or.

OR a b c
R.a = R.b | R.c

See Also:
Constant Field Values

AND

public static final int AND

Opcode: logical and.

AND a b c
R.a = R.b & R.c

See Also:
Constant Field Values

BIC

public static final int BIC

Opcode: logical bic.

BIC a b c
R.a = R.b & ~R.c

See Also:
Constant Field Values

XOR

public static final int XOR

Opcode: logical xor.

XOR a b c
R.a = R.b ^ R.c

See Also:
Constant Field Values

LSH

public static final int LSH

Opcode: logical shift.

LSH a b c
R.a = (R.c > 0) ? (R.b << R.c) : (R.b >>> -R.c)

See Also:
Constant Field Values

ASH

public static final int ASH

Opcode: arithmetic shift.

ASH a b c
R.a = (R.c > 0) ? (R.b << R.c) : (R.b >> -R.c)

See Also:
Constant Field Values

CHK

public static final int CHK

Opcode: bound check.

CHK a c
raise an error if not (0 <= R.a < R.c)

See Also:
Constant Field Values

ADDI

public static final int ADDI

Opcode: integer addition with signed immediate.

ADDI a b ic
R.a = R.b + ic

See Also:
Constant Field Values

SUBI

public static final int SUBI

Opcode: integer subtraction with signed immediate.

SUBI a b ic
R.a = R.b - ic

See Also:
Constant Field Values

MULI

public static final int MULI

Opcode: integer multiplication with signed immediate.

MULI a b ic
R.a = R.b * ic

See Also:
Constant Field Values

DIVI

public static final int DIVI

Opcode: integer division with signed immediate.

DIVI a b ic
R.a = R.b / ic

See Also:
Constant Field Values

MODI

public static final int MODI

Opcode: integer modulo with signed immediate.

MODI a b ic
R.a = R.b % ic

See Also:
Constant Field Values

CMPI

public static final int CMPI

Opcode: integer comparison with signed immediate.

CMPI a b ic
R.a = <a value with the same sign as (R.b - ic) but with a possibly different magnitude>

See Also:
Constant Field Values

ORI

public static final int ORI

Opcode: logical or with signed immediate.

ORI a b ic
R.a = R.b | ic

See Also:
Constant Field Values

ANDI

public static final int ANDI

Opcode: logical and with signed immediate.

ANDI a b ic
R.a = R.b & ic

See Also:
Constant Field Values

BICI

public static final int BICI

Opcode: logical bic with signed immediate.

BICI a b ic
R.a = R.b & ~ic

See Also:
Constant Field Values

XORI

public static final int XORI

Opcode: logical xor with signed immediate.

XORI a b ic
R.a = R.b ^ ic

See Also:
Constant Field Values

LSHI

public static final int LSHI

Opcode: logical shift with signed immediate.

LSHI a b ic
R.a = (ic > 0) ? (R.b << ic) : (R.b >>> -ic)

See Also:
Constant Field Values

ASHI

public static final int ASHI

Opcode: arithmetic shift with signed immediate.

ASHI a b ic
R.a = (ic > 0) ? (R.b << ic) : (R.b >> -ic)

See Also:
Constant Field Values

CHKI

public static final int CHKI

Opcode: bound check with signed immediate.

CHKI a ic
raise an error if not (0 <= R.a < ic)

See Also:
Constant Field Values

ADDIU

public static final int ADDIU

Opcode: integer addition with unsigned immediate.

ADDIU a b uc
R.a = R.b + uc

See Also:
Constant Field Values

SUBIU

public static final int SUBIU

Opcode: integer subtraction with unsigned immediate.

SUBIU a b uc
R.a = R.b - uc

See Also:
Constant Field Values

MULIU

public static final int MULIU

Opcode: integer multiplication with unsigned immediate.

MULIU a b uc
R.a = R.b * uc

See Also:
Constant Field Values

DIVIU

public static final int DIVIU

Opcode: integer division with unsigned immediate.

DIVIU a b uc
R.a = R.b / uc

See Also:
Constant Field Values

MODIU

public static final int MODIU

Opcode: integer modulo with unsigned immediate.

MODIU a b uc
R.a = R.b % uc

See Also:
Constant Field Values

CMPIU

public static final int CMPIU

Opcode: integer comparison with unsigned immediate.

CMPIU a b uc
R.a = <a value with the same sign as (R.b - uc) but with a possibly different magnitude>

See Also:
Constant Field Values

ORIU

public static final int ORIU

Opcode: logical or with unsigned immediate.

ORIU a b uc
R.a = R.b | uc

See Also:
Constant Field Values

ANDIU

public static final int ANDIU

Opcode: logical and with unsigned immediate.

ANDIU a b uc
R.a = R.b & uc

See Also:
Constant Field Values

BICIU

public static final int BICIU

Opcode: logical bic with unsigned immediate.

BICIU a b uc
R.a = R.b & ~uc

See Also:
Constant Field Values

XORIU

public static final int XORIU

Opcode: logical xor with unsigned immediate.

XORIU a b uc
R.a = R.b ^ uc

See Also:
Constant Field Values

CHKIU

public static final int CHKIU

Opcode: bound check with unsigned immediate.

CHKIU a uc
raise an error if not (0 <= R.a < uc)

See Also:
Constant Field Values

LDW

public static final int LDW

Opcode: load word from memory. The address R.b must be aligned on a word boundary.

LDW a b ic
R.a = <word at address R.b + ic>

See Also:
Constant Field Values

LDB

public static final int LDB

Opcode: load byte from memory.

LDB a b ic
R.a = <byte at address R.b + ic>

See Also:
Constant Field Values

POP

public static final int POP

Opcode: pop word from stack. The address R.b must be aligned on a word boundary.

POP a b ic
R.a = <word at address R.b>
R.b = R.b + ic

See Also:
Constant Field Values

STW

public static final int STW

Opcode: store word into memory. The address R.b must be aligned on a word boundary.

STW a b ic
<word at address R.b + ic> = R.a

See Also:
Constant Field Values

STB

public static final int STB

Opcode: store byte into memory.

STB a b ic
<byte at address R.b + ic> = (byte)R.a

See Also:
Constant Field Values

PSH

public static final int PSH

Opcode: push word on stack. The address R.b must be aligned on a word boundary.

PSH a b ic
R.b = R.b - ic
<word at address R.b> = R.a

See Also:
Constant Field Values

BEQ

public static final int BEQ

Opcode: branch if equal.

BEQ a oc
branch to (PC + 4*oc) if (R.a == 0)

See Also:
Constant Field Values

BNE

public static final int BNE

Opcode: branch if not equal.

BNE a oc
branch to (PC + 4*oc) if (R.a != 0)

See Also:
Constant Field Values

BLT

public static final int BLT

Opcode: branch if less than.

BLT a oc
branch to (PC + 4*oc) if (R.a < 0)

See Also:
Constant Field Values

BGE

public static final int BGE

Opcode: branch if greater or equal.

BGE a oc
branch to (PC + 4*oc) if (R.a >= 0)

See Also:
Constant Field Values

BLE

public static final int BLE

Opcode: branch if equal less or equal.

BLE a oc
branch to (PC + 4*oc) if (R.a <= 0)

See Also:
Constant Field Values

BGT

public static final int BGT

Opcode: branch if greater than.

BGT a oc
branch to (PC + 4*oc) if (R.a > 0)

See Also:
Constant Field Values

BSR

public static final int BSR

Opcode: branch to subroutine.

BSR oc
R.31 = PC + 4
branch to (PC + 4*oc)

See Also:
Constant Field Values

JSR

public static final int JSR

Opcode: jump to subroutine.

JSR lc
R.31 = PC + 4
branch to (4*lc)

See Also:
Constant Field Values

RET

public static final int RET

Opcode: jump to return address.

RET c
jump to R.c

See Also:
Constant Field Values

BREAK

public static final int BREAK

Opcode: stop execution and return to debugger.

BREAK
stop execution and return to debugger

See Also:
Constant Field Values

SYSCALL

public static final int SYSCALL

Opcode: invoke a system function.

SYSCALL a b uc
invoke system function uc with registers R.a and R.b

See Also:
Constant Field Values

SYS_IO_RD_CHR

public static final int SYS_IO_RD_CHR

System call: read one character.

SYSCALL a 0 SYS_IO_RD_CHR
R.a = <Unicode of read character or -1 if EOF>

See Also:
Constant Field Values

SYS_IO_RD_INT

public static final int SYS_IO_RD_INT

System call: read an integer.

SYSCALL a 0 SYS_IO_RD_INT
R.a = <value of read integer>

See Also:
Constant Field Values

SYS_IO_WR_CHR

public static final int SYS_IO_WR_CHR

System call: write one character.

SYSCALL a 0 SYS_IO_WR_CHR
<write character with Unicode R.a>

See Also:
Constant Field Values

SYS_IO_WR_INT

public static final int SYS_IO_WR_INT

System call: write an integer.

SYSCALL a b SYS_IO_WR_INT
<write signed value R.a in decimal format and space padded to width R.b>

See Also:
Constant Field Values

SYS_GC_INIT

public static final int SYS_GC_INIT

System call: initialize the garbage collector.

The garbage collector is initialized with an empty heap that starts at address R.a and with a maximum size of sz = R.b & 0x07FFFFFF words. If sz is zero then the heap extends to the end of the memory.

The value sp = R.b >>> 27 determines whether there is a stack and which register is the stack pointer: if sp is non-zero, the garbage collector assumes that there is a stack and that R.sp is the stack pointer register. It is assumed that the stack starts at the end of the memory and grows downwards.

During a garbage collection, the garbage collector frees all the memory blocks which are not referenced by any live pointer. A live pointer (resp. value) is either a root pointer (resp. value) or a pointer (resp. value) contained in a block referenced by a live pointer. Note that as there is no way to distinguish between pointers and non-pointer values, all values are regarded as pointers. A root value is one that is contained in a register, in the memory below the heap or in the stack. If there is no stack, all the values contained in the memory above the heap are also root values.

SYSCALL a b SYS_GC_INIT
<initialize the garbage collector>

See Also:
Constant Field Values

SYS_GC_ALLOC

public static final int SYS_GC_ALLOC

System call: allocate a memory block from the heap.

Allocates a memory block of, at least, R.b bytes from the heap and returns its address in R.a. The allocated memory is zero-initialized and its address is guaranteed to be aligned on a word boundary. If there is not enough free memory, a garbage collection is triggered and if this doesn't free enough memory, an error is raised and the execution stopped.

SYSCALL a b SYS_GC_ALLOC
R.a = <address of the newly allocated and zero-initialized memory block of R.b bytes>

See Also:
Constant Field Values

SYS_GET_TOTAL_MEM_SIZE

public static final int SYS_GET_TOTAL_MEM_SIZE

System call: get memory size.

SYSCALL a 0 SYS_GET_TOTAL_MEM_SIZE
R.a = <memory size in bytes>

See Also:
Constant Field Values

SYS_EXIT

public static final int SYS_EXIT

System call: terminate the emulation.

SYSCALL a 0 SYS_EXIT
<terminates the emulation with status code R.a>

See Also:
Constant Field Values

ZERO

public static final int ZERO
Register: zero

See Also:
Constant Field Values

RES

public static final int RES
Register: return value

See Also:
Constant Field Values

SP

public static final int SP
Register: stack pointer

See Also:
Constant Field Values

LNK

public static final int LNK
Register: return address

See Also:
Constant Field Values

mnemonics

public static final java.lang.String[] mnemonics
String representation of instructions