Assignment 4: Intro to ARM -- 2/10/2020

COSC 2200, Spring 2020

Marquette University, Department of Computer Science

Due: Monday, February 17 at 11:59pm CDT
Submit: Turn in your source files using the turnin command on Morbius. Please name your files "main-stats.S", "main-exp.S", and "main-psi2kpa.S". Failure to follow this simple convention will cause TA-Bot to fail. What is TA-Bot?

Note: Because turnin overwrites submissions with each command, you must turn in all three files at the same time:
turnin -c cosc2200 main-exp.S main-psi2kpa.S main-stats.S

Work may be completed in teams of two. The names of both partners must appear in a comment block at the top of your file for credit to be given. I strongly recommend that you take the time to meet with your partner in person and work together on these projects, rather than work separately and try to integrate at the last minute. Use the command hook "TA-BOT:MAILTO" in a comment in your source files to designate mail addresses for TA-Bot output. An example of this hook is included for you at line 1 of the "main.S" template (in pi3Playground).

This UNIX tutorial may be of some assistance.

Preparation

You will have to familiarize yourself with several common UNIX tools for this assignment. The first of these is tar, a utility originally devised to create tape archives for the purpose of backing files up onto computer tapes.

While tar is still used to create tape backups of filesystems, it has become far more common to use tar to group files and/or directories together into a single entity, typically called a "tar-ball". (So common is the use of tar that it has been verbed in computer science terminology: We speak of "tarring" files, or files that have been "tarred up".) Tar syntax is somewhat arcane, as tar came into existence before modern standards for command-line options.



Click here for my instructional video that explains the preparation steps.

  • Login to Morbius, and change to a fresh working directory.
  • Execute the the following command:

       tar xvzf ~pmcgee6/cosc2200/pi3Playground.tgz
  • This untars the files into your working directory, in a subdirectory called pi3Playground/. For more information on tar, please see the UNIX man pages.

    Running your code

    Edit the file main.S to write your program. Your work must be compiled on a machine with the proper tools, such as the Systems Lab machines. In order to compile your program, use the command "make". In order to run your program, use the command "arm-console". At any time, you can shutdown the remote console system by hitting Ctrl-Space, followed by the letter 'q', for 'quit'.

    Few rules govern the format of assembly language programs. Make an effort to keep your programs readable and well-documented; sometimes partial credit may be given if we can tell what you were trying to do, even if it doesn't quite make it.

    The ARM Playground (or Pi3 Playground) kernel includes several useful functions for input and output in these earliest assignments, as outlined in the README.txt file. The first is getnum. When executing the getnum function, (with the assembly code " bl getnum",) the user is prompted with a question mark, and a simple integer will be read into register r0. The printnum function will output a base-10 representation of the contents of register r0. The divide function takes a dividend in r0 and a divisor in r1; upon return, the integer quotient is stored in r0 and any remainder in r1.

    In keeping with the standard ARM calling convention, registers r0 through r3 may have their values changed by any function call, as they are volatile.

    Arm-console Tips & Avoiding Failed Backends

    Click here for my instructional video that explains this process.

    The arm-console command transfers your compiled kernel onto an available Raspberry Pi 3 board. After running the command, if all goes well, you should see the message "kexecing new kernel..". This is the kernel transfer procedure. If you do not see this message, it means the backend machine is not functioning properly. Luckily, you can specify a different backend by adding it as a parameter to the arm-console command. First, note the name of the bad backend machine so you can avoid it ('auton' in the example below'):

    $ arm-console
    spawn xinu-console -c rpi3
    connection 'auton', class 'rpi3', host 'morbius.mscsnet.mu.edu'
    ...


    Next, run xinu-status -c rpi3 to print a list of Pi3-class boards (one of these are chosen for you when running arm-console without parameters). Pick one from the list, and then run arm-console <name-of-backend>.
    If all goes well, you should see a "Hello Xinu World" message after "kexecing new kernel..".

    Q1 - Stats

    Write an assembler program that reads in integers from the user until a zero is entered. Print the total, the average (total divided by number of items, truncated to an integer), the highest integer seen, and the lowest integer seen.

    Example:
    ? 3
    ? 4
    ? 5
    ? 0
    12
    4
    5
    3

    You may assume that overflow and underflow do NOT occur.

    Q2 - Exponent

    Write an assembler program that reads two positive integers, x and y, and prints x to the y power. Your program should continue asking for integers until it has gotten two positive, nonzero numbers.

    Example:
    ? 2
    ? 30
    1073741824

    You may assume that overflow and underflow do NOT occur.

    Q3 - Psi to kPa Converter

    Write an assembler program that reads a positive integer representing a pound-force per square inch (Psi) value, and prints the value measured in kilopascals (kPa).
    For simplicity, assume 1000 Psi = 6895 kPa.

    Example:
    ? 124
    854

    You may assume that overflow and underflow do NOT occur.