Laboratory Exercises For Computer Science 211

Introduction to HP Assembly Language

Introduction to HP Assembly Language

Goals: This laboratory provides an introduction to HP assembly language and allows for some comparisons between C and Pascal.

Resource: For this lab, you will want to refer to HP's manual, PA-RISC 1.1 Architecture and Instruction Set Reference Manual, Third Edition. This is available on-line in either html or postscript format. It is strongly recommended that you include one or both of these references in your list of Web bookmarks.

Steps for this Lab:

  1. Programs ~walker/assembly/prog1.c and ~walker/assembly/prog2.c each contain a linear search procedure, written in C.

    1. Copy these programs to your account.
    2. Peruse, compile, and run the programs to check how they work.
    3. Compare on any similarities or differences between these two programs:
      • How are constants declared?
      • Where are variables item, elements and itemFound declared?
      • How are data values read?
      • What parameters are used for procedures, and what is being passed (e.g., addresses or values)?
      • How is the linear search performed?
      • How is the found variable set?

  2. Compile prog1 to assembly code, using the command:

    
         gcc -S prog1.c
    
    This command will produce an assembly language program, stored in file prog1.s. Comment upon the general organization of data for the portion of this assembly language program which comes from the linearSearch procedure. In particular,

    1. Where are variables item, elements and itemFound stored?
    2. Indicate where the local variable index and the parameters number, dataArray and found are stored.
    3. Outline which registers are used for what information when.
    4. How are values computed for the done variable, and how is done tested in the code generated from the while and if statements.

  3. Next compile prog2.c to assembly language.

    Annotate the portion of this assembly language program which comes from the linearSearch procedure. That is,

    1. Where are variables item, elements and itemFound declared?
    2. Indicate where all local variables and parameters are stored.
    3. Identify all assembly language instructions and macros in the listing.
    4. Outline which registers are used for what information when.


Work to be turned in:


This document is available on the World Wide Web as

     http://www.math.grin.edu/~walker/courses/211.fa99/labs/as-assembler.html

created September 30, 1997
last revised October 3, 1999