Generic Stack Assembly Language Simulation

written by Teresa Carrigan


Run model in your browser


Top

EXTENDING THE MODEL

Add another operator to the possible commands, such as exponentiation, or sin.

Show the memory locations of the lines of the program as well as the variables. Be sure to show the bus stopping at the correct line when it fetches an instruction.

Modify push to limit the number of items that can be pushed on the stack (to prevent wrapping).

Allow labels on lines, so that you can implement the various jump and branch opcodes.

Add MAR and MBR registers, and separate the datapath into the internal bus, address bus, and data bus.

Show the ALU, with the top two items of the stack going into it with the opcode being executed, and the result coming out then going on the top of the stack.

Top

NETLOGO FEATURES

In several places, the bus turtle uses while [ pcolor-of (patch-ahead 1) = red ] [ wait slow-me-down fd 1 ] to follow the datapath in a straight line, slowly enough that the animation can be seen.

The setup-file procedure lets the user browse to find a saved textfile, opens it, and then reads the contents of the file into a list, with each line a separate list item.

upper! converts a string to upper-case.

The four demo programs had to be hard-coded as lists, because an applet won't allow them to be read from textfiles.

Top

RELATED MODELS


Home

Applets on this website were written by Teresa Carrigan in 2004, for use in computer science courses at Blackburn College, with the exception of the Fireworks applet. The applets made with NetLogo require Java 1.4.1 or higher to run. The applets made with NetBeans require Java 1.4.2 or higher to run. Applets might not run on Windows 95 or Mac OS 8 or 9. You may obtain the latest Java plugin from Sun's Java site.