Difference between revisions of "SIMPLESEM"
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
− | '''SIMPLESEM''' is the silly pseudo-assembly being used in my paradigms class. | + | '''SIMPLESEM''' is the silly pseudo-assembly being used in my [[GWU CSCI 169|paradigms class]]. |
=Architecture= | =Architecture= | ||
Line 93: | Line 93: | ||
=References= | =References= | ||
− | + | * [[Programming Language Concepts (book)]] | |
=See Also= | =See Also= | ||
* [http://www.infosys.tuwien.ac.at/pl-book/simplesem/ A SIMPLESEM interpreter] | * [http://www.infosys.tuwien.ac.at/pl-book/simplesem/ A SIMPLESEM interpreter] |
Latest revision as of 00:19, 26 October 2005
SIMPLESEM is the silly pseudo-assembly being used in my paradigms class.
Contents
Architecture
It's a Harvard architecture (unlike Von Neumann architecture, it stores code and data in separate data segments).
Code is stored in the array C[], and data in the array D[]. C and D are zero-based and programs and data are expected to start at C[0] and D[0]. In D[X], X is an lvalue and D[X] is an rvalue.
The (only) register ip is the instruction pointer. An index to C, it is initialized to 0.
The processor operates by repeating the following, in order, until a halt instruction:
- Fetch the instruction C[ip]
- Increment ip
- Execute the fetched instruction
ip is thus the value of the next instruction by the time the current instruction is executed. The program
set write, ip halt
accordingly outputs 1 (the output line is C[0]).
Instructions
set
set target, D[source]
Where target and source are as read. Like
D[target] = D[source]
traditionally.
set 10, D[20]
copies D[20] to D[10].
Memory indirection
The distinction between lvalue and rvalue is important because SIMPLESEM allows indirection. That is,
set D[10], D[20]
is not what the naïve might expect; it means
D[D[10]] = D[20]
because target is an address.
read and write
The variables read and write (which are not locations—they are not ever subscripts to D) are mapped to stdio, so that
set 15, read
means to read a value to D[15], and
set write, D[50]
means to write D[50].
Arithmetic expressions
Unlike real assembly, arithmetic is performed inline with set:
set 99, D[15]+D[33]*D[41]
works as expected. The need for accumulators/registers is thus obviated.
jump
jump location
An unconditional jump. It's no more complex than it looks (SIMPLESEM isn't pipelined). If ip is involved somehow, remember that it is set to the index after the current instruction.
jump 47 jump D[13]
work as expected.
jumpt
jumpt location, conditional
The same as jump, with a conditional clause. Like the arithmetic, conditional operators (like < and >) are inlined:
jumpt 47, D[3] > D[8]
jumps the program to C[47] (that is, sets ip = 47 then continues) only if D[3] is greater than D[8].