![]() |
|
SML: an Assembly Language The JAVA applet "Simpletron3" simulates a computer executing a program in assembly language: the language is SML. Each SML instruction contains four digits.The first two digits represent the operation code; the second digit pair is the RAM address.
Simpletron3 has a 100 word memory (00...99). All arithmetic instructions leave their results in the accumulator.
OP CODE
10##
11##
20##
21##
30##
31##
32##
33##
34##
40##
41##
42##
43##MEANING
Read a word from the keyboard into a specific memory location.
Write a word from a specific memory location to the screen.
Load a word from a specific memory location to the accumulator.
Store a word from the accumulator to specific memory location.
Add a word from a specific memory location to the accumulator.
Subtract a word from a specific memory location to the accumulator.
Multiply a word from a specific memory location to the accumulator.
Divide a word from a specific memory location to the accumulator.
Raise a word in the accumulator to a power from a specific memory location.
Branch to specific location in memory.
Branch to a specific location in memory if accumulator is negative.
Branch to a specific location in memory if accumulator is zero.
Halt
[top]
Sample Programs
Program: reads two integers; determines and prints the larger.
- 00 1009 Read A
- 01 1010 Read B
- 02 2009 Load A
- 03 3110 Subtract B
- 04 4107 if Acc<0 goto 07
- 05 1109 else Print A
- 06 4300
- 07 1110 Print B
- 08 4300
- 09 A
- 10 B
Program: reads integer list, calculates and prints average.
- 1050 Read C; (counter-length of list)
- 1052 Read N; (list item,"0" ends list)
- 2052
- 4211
- 2051
- 3050
- 2151
- 2052
- 3053
- 2153
- 4001
- 2053
- 3351
- 2154
- 1154
- 4300
Your program here.
Write a program in SML and send to Frankie: Webmaster@iXoraWebDesign for posting.
[top]