[NEXT] [PREV]    HANDBOOK / CASE STUDY / The Target Machine /

ICode Instructions

Gentle
Applications
Concepts
Examples
Handbook
Support
Download

For each ICode instruction its operation code, its parameters and its meaning are given in the following. The meaning is given as text and as formula which describe operations on the runtime stack. To simplify the description, within formulas it is not taken care about the types of the stack elements.

If not further mentioned, the operations apply to the top of the stack, which contains the actual element. The following shorthand notations are used:

Note: The types integer, real and boolean are encoded with 1, 2, and 3. The boolean values FALSE and TRUE are encoded by 0 and 1.

Load Instructions

LDA l o

load address with base and offset


   SP:=SP+1
   S[SP]:=base(l)+o;
LDC t c

load constant c of type t


   SP:=SP+1;
   S[SP]:=c;
LDI load indirect


   S[SP]:=S[S[SP]]

Store Instructions

STI

store into address contained in the element below the top


   S[S[SP-1]]:=S[SP];
   SP:=SP-1;

Jump Instructions

JMP a

unconditional jump


   PC:=a;
FJP a

conditional jump


   if not S[SP] then PC:=a;
   SP:=SP-1;

Arithmetic Instructions

ADD t

addition of type t


   SP:=SP-1;
   S[SP]:=S[SP]+S[SP+1];
SUB

integer subtraction


   SP:=SP-1;
   S[SP]:=S[SP]-S[SP+1];
MUL t

multiplication of type t


   SP:=SP-1;
   S[SP]:=S[SP]*S[SP+1];

Logic Instructions

INV

   S[SP]:=not S[SP];
LES t

less operation of type t


   SP:=SP-1;
   S[SP]:=S[SP]

Address Calculation Instructions

IXA c"

compute indexed address


   SP:=SP-1;
   S[SP]:=c*S[SP+1]+S[SP];

Convert Instructions

FLT

converts from integer to real


   S[SP]:=real(S[SP]);

Input-Output Instructions

WRI t


   write(S[SP]);
   SP:=SP-1;
REA t

   SP:=SP+1;
   read(S[SP]);

Subroutine Handling Instructions

MST l

activation record initialization:


   S[SP+1]:=base(l);- store static predecessor
   S[SP+2]:=AP; - store dynamic predecessor
   SP:=SP+3; - return address (=S[SP+3]) is stored by JSR
JSR o a

set AP to point to new activation record
o = number of locations for parameters


   AP:=SP-(o+2);
   S[AP+2]:=PC; - store return address
   PC:=a ; - set PC to first instruction of subroutine
ENT o

storage reservation for new block
o = length of local data segment


   SP:=SP+o
RET

return from subroutine:


   SP:=AP-1;
   PC:=S[SP+3]; - fetch return address to restore PC
   AP:=S[SP+2]; - restore activation record pointer AP

Check Instructions

CHK c1 c2

check against upper and lower bounds


   if (S[SP]c2) then error




[NEXT] [PREV]