-
Notifications
You must be signed in to change notification settings - Fork 33
instructions
Bob Rubbens edited this page Jun 30, 2015
·
19 revisions
Const 5 RegA
Compute Add RegA RegB RegC
Write RegA (Addr 0xFF)
Branch RegA (Rel 1)
Local instructions act on the local memory and registers only.
Instruction | a1 | a2 | a3 | a4 | Description |
---|---|---|---|---|---|
Const | Int | Reg | Store value a1 at a2
|
||
Compute | Operator | Reg | Reg | Reg | Store result of operator on a2 , a3 in a4
|
Load | MemAddr | Reg | Load from address a1 , store at a2
|
||
Store | Reg | MemAddr | Store a1 at a2
|
||
Branch | Reg | Target | Jump to a2 if value at a1 is not zero |
||
Jump | Target | Jump to a1
|
|||
Push | Reg | Push a1 to top of the stack |
|||
Pop | Reg | Pop from stack and store result at a1
|
|||
Nop | Do absolutely nothing. | ||||
EndProg | Terminate program |
System instructions communicate with the external system (or shared memory). Read
sends a request, but does not wait for the system to reply. Note that you can use this to issue multiple
requests, and wait for their replies later on. Do keep in mind that inputs are non-buffered. That is,
if you miss a reply by not waiting for an answer with Receive
the message is lost forever.
Instruction | a1 | a2 | Description |
---|---|---|---|
Read | MemAddr | Send request to shared memory to fetch a1
|
|
Receive | Reg | Block and wait for a message to arrive (from system / shared memory). Store the result in a1
|
|
Write | Reg | MemAddr | Write a1 to shared memory a2
|
TestAndSet | MemAddr | If the rightmost bit of a1 is a one, do nothing and return zero. If it was a zero, write the integer one to the memory address and return one. |
The types mentioned in the table below can be used in the instructions above. For example, 'MemAddr' can either expand to 'Addr Int' or 'Deref Reg' (which can further expand to Addr 3
or Deref RegB
).
Type | Resolves to | Description |
---|---|---|
Reg | Register | Architecture#Registers |
MemAddr | Addr Int | Local or shared memory address Int
|
Deref Reg | Local or shared memory address stored at Reg
|
|
Target | Abs Int | Instruction Int
|
Rel Int | Current program counter plus Int
|
|
Ind Reg | Instruction number stored at Reg
|
|
Operator | Add | Add |
Sub | Subtract | |
Mul | Multiply | |
Div | Divide | |
Mod | Modulo | |
Equal | Equals | |
NEq | Not equals | |
Gt | Greater than | |
GtE | Greater than or equal to | |
Lt | Lesser than | |
LtE | Lesser than or equal to | |
And | Bitwise AND | |
Or | Bitwise OR | |
Xor | Bitwise XOR | |
LShift | Left shift | |
RShift | Right shift |