************Simpletron 3************

Java computer image
Computer Simulation

Simpletron3 simulates a computer executing a program written in SML, a fakey assembly language. The user can enter a program, then watch the computer assemble and execute each statement.

Programs can manipulate integer data from -9999 to +9999 with the five operations: addition, subtraction, multiplication, division, and exponentiation.

During execution certain fatal errors are detected: attempts to divide by zero, accumulator overflow, invalid operation codes. These errors will produce an error message and a memory dump; the memory will also be displayed after a valid program is executed. Other careless user errors will cause the applet to crash.

Simpletron3 has a RAM of 100 addresses from 00 to 99.

SML: the Language
SML: the Programs
Sim3: the Computer
[Frankie's Applet Forum] [JAVA Applets]

Sim3: CPU Simulator

Sample program: adds two integers

  • 1007   Read A, store in 07
  • 1008   Read B, store in 08
  • 2007   Load A in Acc
  • 3008   Add B
  • 2109   Store sum(A+B)in 09
  • 1109   Write sum
  • 4300   Halt

How to Operate Sim3
  1. move cursor to instruction field
  2. type instruction, press enter key
  3. repeat step 2 to enter program
  4. click DONE button
  5. click NEXT button to execute
  6. enter data at sound signal, press enter key
  7. repeat step 5 to end of program
ALT="Your browser understands the <APPLET> tag but isn't running the applet, for some reason." Your browser is completely ignoring the <APPLET> tag!
[top]

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]