Assembly Programming and Hand Assembly Lab - University of Florida EEL 3701, Fall 2002, Lab Reports of Electrical and Electronics Engineering

A lab handout from the university of florida, department of electrical & computer engineering, for a course on assembly programming and hand assembly using the g-cpu. The lab involves simulating existing assembly code and writing new assembly code for the g-cpu. Students are required to use maxplus ii software and create sram and rom files for data and program storage, respectively. The objectives of the lab are to learn how to simulate assembly code on the g-cpu and write new assembly code for it.

Typology: Lab Reports

Pre 2010

Uploaded on 09/17/2009

koofers-user-d3x
koofers-user-d3x 🇺🇸

5

(1)

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
University of Florida EEL 3701 Fall 2002 Dr. Eric M. Schwartz
Department of Electrical & Computer Engineering Professor in ECE
Page 2/2 Revision 4 3-Dec-027:23 PM
LAB 9: G-CPU: Assembly Programming and Hand Assembly
PART II. NEW PROGRAM CREATION (Prelab)
1. Write a program to take the average of a set of two
numbers. The input table is arranged as following:
OutAddr, TabSize, Num1a, Num2a, Num1b, Num2b, …
You will create an output table with the average of
each set of two numbers. The output table starts with
the average of the Num1a and Num2a from the input
table followed by the average of Num1b and Numb2b
from the input table, etc. OutAddr is the starting
address of the output table. TabSize is the number of
averages your program will execute. When you have
completed the data processing, execute an endless
loop (like a dog chasing its tail).
2. Assume that the input table and the output table are
both in SRAM. The input table begins at address
$1200. To test your program, you will have to create
some data in an SRAM (.mif) file as well as store your
program in a ROM (eprom.mif) file.
3. Use the X register to point to the data that is read
from the input table and use the Y register to point to
the output table.
4. REG A should be used as a loop counter. REG B
should be used for calculations. (Hint: You may need
to temporarily store the loop counter in memory, i.e.,
SRAM, while REG A is used for other purposes.)
5. Verify the program works by creating an sram.mif. For
this verification, use OutAdd = $1400, TabSize = 4,
and use at least four data bytes. Print the simulation
results and annotate it with the instructions.
6. Bring your assembly code, hand assembled machine
code and simulation results to lab.
Note: If you wish to use variables or store values in your
code, you must reference the RAM area of you memory
space. RAM is located in $1000 - $1FFF. ROM is read
only.
Note: When you change data in either the eprom.mif file
or the sram.mif file, you must recompile the computer.gdf
file.
IN-LAB REQUIREMENTS
1. Show your TA the pre-lab work associated with Part I.
results. Your TA will ask you general questions on
the operation of the code in simulation.
2. Show your TA the pre-lab work associated with Part
II. results. Your TA will again ask you general
questions on the operation of the code in simulation.
3. Your TA will give you another input table with which
to test your algorithm from Part II.
4. The TA will now ask you to write a short program
(very simple task). Create and simulate the desired
program.
pf2

Partial preview of the text

Download Assembly Programming and Hand Assembly Lab - University of Florida EEL 3701, Fall 2002 and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

University of Florida EEL 3701— Fall 2002 Dr. Eric M. Schwartz Department of Electrical & Computer Engineerin g Professor in ECE Page 2/2 Revision 4 3-Dec-02—7:23 PM

LAB 9: G-CPU: Assembly Programming and Hand Assembly

PART II. NEW PROGRAM CREATION (Prelab)

  1. Write a program to take the average of a set of two numbers. The input table is arranged as following: OutAddr, TabSize, Num1a, Num2a, Num1b, Num2b, … You will create an output table with the average of each set of two numbers. The output table starts with the average of the Num1a and Num2a from the input table followed by the average of Num1b and Numb2b from the input table, etc. OutAddr is the starting address of the output table. TabSize is the number of averages your program will execute. When you have completed the data processing, execute an endless loop (like a dog chasing its tail).
  2. Assume that the input table and the output table are both in SRAM. The input table begins at address $1200. To test your program, you will have to create some data in an SRAM (.mif) file as well as store your program in a ROM (eprom.mif) file.
  3. Use the X register to point to the data that is read from the input table and use the Y register to point to the output table.
  4. REG A should be used as a loop counter. REG B should be used for calculations. (Hint: You may need to temporarily store the loop counter in memory, i.e., SRAM, while REG A is used for other purposes.)
  5. Verify the program works by creating an sram.mif. For this verification, use OutAdd = $1400, TabSize = 4, and use at least four data bytes. Print the simulation results and annotate it with the instructions.
  6. Bring your assembly code, hand assembled machine code and simulation results to lab.

Note: If you wish to use variables or store values in your code, you must reference the RAM area of you memory space. RAM is located in $1000 - $1FFF. ROM is read only.

Note: When you change data in either the eprom.mif file or the sram.mif file, you must recompile the computer.gdf file.

IN-LAB REQUIREMENTS

  1. Show your TA the pre-lab work associated with Part I. results. Your TA will ask you general questions on the operation of the code in simulation.
  2. Show your TA the pre-lab work associated with Part II. results. Your TA will again ask you general questions on the operation of the code in simulation.
  3. Your TA will give you another input table with which to test your algorithm from Part II.
  4. The TA will now ask you to write a short program (very simple task). Create and simulate the desired program.

University of Florida EEL 3701— Fall 2002 Dr. Eric M. Schwartz Department of Electrical & Computer Engineerin g Professor in ECE Page 1/2 Revision 4 3-Dec-02—7:23 PM

LAB 9: G-CPU: Assembly Programming and Hand Assembly

OBJECTIVE

The objectives of this lab are to learn how to simulate existing assembly code on the G-CPU and also how to write new assembly code for the G-CPU.

MATERIALS

  • MaxPlus II Software (on our web site)
  • G-CPU documentation (on the web site)

INTRODUCTION With the knowledge gained in earlier labs, you now have a detailed understanding of the internal structure of a simple Central Processing Unit (CPU). Instead of continuing with your previous existing hardware designs, you are now given a more complete CPU, which is denoted as the General CPU or G-CPU. In this lab you will first dissect and simulate the assembly code that is given with the G-CPU. Then in the second part of the lab you will write new assembly code for creation of a new G-CPU program. This new program will then be simulated in MaxPlusII to observe the G- CPU bus and register changes during program execution.

SPECIFICATIONS

  1. Download gcpu_MaxPlus.zip and unzip it into your lab 9 directory on your hard disk.
  2. A new directory, gcpu_MaxPlus has been created. Open MaxPlusII and load the file computer.gdf (found in the gpcu_MaxPlus directory). Set this file as the current file.
  3. Next select compile from the menu. This will bring up the compile window. While the compile window is active, go to the menu and choose “Processing | Functional SNF Extractor.” This will allow you to compile and simulate without fitting the design into a particular device. Go to the menu and choose “Assign | Device” and then select the Device Family “Flex10K.” Then in the Devices, select “Auto” then select OK. Note: The G-CPU is too large to fit into a device offered by Altera in the student software (i.e., Flex10K devices) thus we will not fit it into any particular device but will instead just perform a functional simulation.

PART I. SIMULATING EXISTING CODE (Prelab)

  1. Open the file called “eprom.mif” in the computer directory. This is the code that is run out of reset (Address = 0) at start.
  2. Describe what the purpose of this program.
  3. Use the “sram.mif” to give the program in “eprom.mif” some data to work with. Create a small table of how you expect the registers to change when this code is run. In other words, try to simulate the execution of the code by hand. The columns of the table should

be as follows: Address(es), Instruction, A, B, X, Y, Z, N, and PC. The columns labeled A-PC should be filled out assuming that the instruction has been completed

  1. Compile the computer.gdf file and then simulate. CLOCK, RESET, STATE, ADDR, DATA, R_/W, IR, A, B, X, Y, ALU, N_FLG, and Z_FLG.
  2. Compare the hand simulation results with the MaxPlusII results.
  3. Use your table to identify when the flags (i.e., status bits Z and N) change and specify why they are set at a particular time. Annotate your table with this information.
  4. Use your table to identify where data is being written into memory and where in the simulation data is being read from or written to memory. Pay close attention to the address bus. Annotate your table with this information.
  5. Modify the data in sram.mif and try it again with your own data. Note: When you change data in either the eprom.mif file or the sram.mif file, you must recompile the computer.gdf file.
  6. Bring printouts of the above to lab for grading by your TA. Note: When you change data in either the eprom.mif file or the sram.mif file, you must recompile the computer.gdf file. MIF FILE CREATION INFORMATION When you write new code, you will hand assemble your code and put it into the “eprom.mif” file. As observed in Part I., this file already has a sample program, which you can use as a template. Key points related to this file are:
  7. The comments are surrounded by “%” signs. The left most number (or numbers) represents the address (or range of addresses) followed by the hex value to the right. For example: 37 :7C % Address=$37, Data=$7C% [37..42] :A3 % Address=$37-$42, Data=$A3%
  8. The last line of code in the “eprom.mif,” file (after your program) should zero out the remaining data in ROM. This is accomplished as shown below: [ XX ..FFF] :00 %zero remaining memory% where XX represents the next address after the last address of your code. For example, if the last byte of your assembly program resides in memory location $25, then replace XX by $26 as shown below: [26..FFF] :00 %zero remaining memory% This will initialize all your remaining unused memory to a known value of zero. (A zero happens to represent the TAB instruction.)