$30
Programming Lab 1A
16-Bit Calculator
Topics: Introduction to the programming environment
Prerequisite Reading: Chapter 1 Appendix B
Click to view the
setup directions
Click to download
Lab1A-Main.c
Click to download
Lab1A-Calculator.s
Objective: The purpose of this lab is merely to get acquainted with the workspace environment, how to compile
the main program (Lab1A-Main.c), assemble the assembly language file (Lab1A-Calculator.s) that contains functions called by the main program, link them together with the run-time library (library.a) to create
an the executable image file (output.bin), and transfer it to the single-board computer. You are not expected
to write any code – just to become familiar with the tools.
Assignment:
1. Click on the first (top) yellow link above to view the software installation instructions. Follow the directions
to install the compiler and workspace. If you are using a Windows computer, also install GNU make for
Windows.
2. Download the files Lab1A-Main.c and Lab1A-Calculator.s and store them in the src directory of your
workspace folder. Use the following instructions to build and test the Lab 1A sample program:
3. Windows Only: Double-click on the file named setup.bat that is located in your workspace folder. This
will open a command line window with the root of the workspace folder as the current directory.
4. Linux and OS X Only: Open a terminal window and change the current directory to the root of the workspace
directory.
5. Enter the command “make”. This will run the compiler, the assembler and the linker, producing the final
program in a file named output.bin. The make program uses a text file named “makefile” that describes
how to compile, assemble, and link the program components together. It is designed to compile any C source
code files, and assemble any assembly language source code files, that it finds in the src directory. Doing so
will produce corresponding object files in the obj directory. The make
program will then link these object files with the run-time library (library.a) to produce the executable image file (output.bin); these
are both located in the root of the workspace directory.
6. Connect the single board computer to the desktop computer using a
mini-USB cable. A window will open as if you had inserted a USB
thumb drive. Into that window, copy the file output.bin from the
root directory of your workspace to the window that just opened. The
board will automatically load and execute your program.
7. If everything proceeds normally, you should see the 16-bit calculator
on the display of the board shown at right. Use the touch screen to
enter numbers, change the radix (number base), or do simple arithmetic operations. The arithmetic operations are implemented in the assembly language file; everything else is implemented in the main program.