CS301 Lab: Macros and the Stack

Objective of this lab:


        To investigate the use of the hardware stack. You will write push and
        pop operations directly into a spim program.

        To design and use m4 macros in a spim program. You will learn how to
        generalize and reuse code like the push and pop operations.

Preparation


	Read lab lecture notes.

Lab Assignment

Assignment#1: Using the Stack

Write a SPIM assembly language program reverse.s.
The program will do the following:
  1. Prompt the user to enter 5 integers.
  2. Print the integers in reverse order using only the stack.
  3. Your output should resemble the following:
    Please enter 5 integers:
    1
    2
    3
    4
    5
    
    Here are the numbers you entered in reverse order:
    5
    4
    3
    2
    1
    

Assignment#2: Writing and Using Macros

  1. Extend printLib.m4 to include integer reading and printing macros.
    They need to have the following features:
  2. Write a new macro library called macroOps.m4 that contains two macros: push and pop. They must:
  3. Copy reverse.s to reverseMac.m4 and modify it to use the macros you just defined.
    Necessary steps include:

You will hand in the following:

  1. The source code in the files printLib.m4, stackOps.m4, reverse.s, reverseMac.m4, and reverseMac.s
  2. For each of reverse.s and reverseMac.s

This page last modified:
Accessed     times.

CS Dept Home Page
CS Dept Class Files
CS115 Lab Files

Copyright: Department of Computer Science, University of Regina.