The file c5asm is a shell script that invokes an assembler, written by Wayne Lang, for the Chapter 5 computer. The assembler is a tad rough in places. Consider it a work-in-progress or a good opportunity for a senior project. A Veriwell RTL specification, also written by Wayne Lang, suitable for executing the output of the assembler is found in C5rtl.v. The final file, loop.asm, is a sample assembler program.
Remember! The veriwell simulator will only run on a Sun SPARC workstation. If you are not logged into one of these machines type the following commands:
Let's start by looking at loop.asm, the sample assembler
program. The Verilog program that simulates the Chapter 5
computer always starts executing at memory location 0. Consequently
our program starts with a branch to PRG, the read start
of the code
ORG 000 BUN PRG
The program itself is a single loop, with a bit of initialization code. Ten numbers are stored beginning at the memory location called VEC. The program adds up these ten numbers and stores the result in SUM.
The first step of the program is to initialize SUM to
0, initialize VPT to point to the first element of
VEC, and to initialize TOX to -10.
PRG CLA STA SUM LDA VAD STA VPT LDA MSX STA TOX
The loop proceeds by increment VPT to point to
successive elements of VEC. The up-counter
TOX goes from -10 to 0 to make sure the loop is only
executed 10 times.
LOP LDA VPT I ADD SUM STA SUM ISZ VPT ISZ TOX BUN LOP
Run Wayne Lang's assembler by typing
You'll see some informative messages flash by. Now use pico to examine the file loop.out that was created in your directory. The file will begin with a "label table" that will give the locations of your programs address in memory. Lines of the table will resemble
which tells us that the variable SUM is stored at memory location 20A. The remainder of the file is a assembler listing. It tells us the machine instructions associated with each assembler statement.
The c5asm program also created a file loop.bin. This file is not intended for Veriwell input not for human consumption; however, you should still look at loop.bin and relate it to your assembler program.
The Veriwell program C5rtl.v is a faithful, but incomplete, specification of the RTL found on page 159 of the textbook. Let's not worry about the details of C5rtl.v this week. Instead just run Veriwell to simulate the loop program by typing
Look at the file veriwell.log, the debugging output of the simulation. Wayne Lang's Veriwell program outputs a line similar to
whenever a machine language instruction is simulated. Only the AC= field and the last field, the current instruction, interests us at this time. Now go through the file veriwell.log and trace through the execution of your program.
Modify the loop.asm program either to compute the exclusive-OR (XOR) of the ten array values or to add only the positive elements found within the ten array values.
If you compute the XOR of the ten values, you'll need to compute the exclusive OR with only the NOT and AND operators. This can be done as
By the way, it is probably easier to add up the positive elements.
Return to CSCI 274 labs
Return to CSCI 274 home page
Return to Dean Brock's
home page
Return to the UNCA Computer Science home
page