Programming Assignment Two_ PA2

SPARC Architecture, Assembly Language Programming, and C (2nd Edition)

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Programming Assignment Two: PA2 Programming Assignment Two: PA2 Due Wednesday night, February 13 @ 11:59 p.m. For this assignment you will build a BCD (Binary Coded Decimal) clock simulator. BCD is a way to represent decimal digits (0-9) in 4 bits (0000-1001). You will use an array of 3 unsigned chars to store the tens and ones values of the clock's hours, minutes, and seconds. The tens digit will be stored in the upper 4 bits (nibble) of each byte. The ones digit will be stored in the lower 4 bits of each byte. The BCD clock display will be similar to the BCD clock I have in my office. An example display of a time value representing 15:03:27 (15 hours, 3 minutes, 27 seconds) will look like: .. . . . . <- 2 3 .O . . .O <- 2 2 .. .O OO <- 2 1 OO .O .O <- 2 0 15 03 27 A capital-O ( O ) will represent an LED ON (bit in that position = 1) while a dot ( . ) will represent an LED OFF (bit in that position = 0). The actual BCD values will be displayed below the bit patterns. For this example time, the array of 3 unsigned chars would have the following bit values: clock [0] [1] [2] 0 0 0 1 | 0 1 0 1 0 0 0 0 | 0 0 1 1 0 0 1 0 | 0 1 1 1 tens | ones tens | ones tens | ones hours minutes seconds 1 5 0 3 2 7 The purpose of this programming assignment is to gain more experience with SPARC assembly language constructs especially bit-wise operations, memory loads and stores (ld/st), allocating local variables on the runtime stack in the save instruction and accessing them relative to the frame pointer (%fp) by converting a function you wrote in C in PA1 into assembly with an additional parameter. You will use use a couple new Standard C Library routines and use two different techniques to communicate C Preprocessor-derived values to your assembly routines (accessing global variables set in a C function and calling C functions from assembly). Grading Breakdown http://ieng9.ucsd.edu/~cs30x/pa2.html (1 of 7) [2/8/2008 12:35:47 PM]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Programming Assignment Two: PA2 README: 10 points Compiling (our Makefile; no warnings): 10 points Style [See pa1 "Code Style"] (Including Comments): 30 points Correctness: 50 points Optimization: 5 Points Must correctly pass at least 70% of test cases to be eligible for Extra Credit Filling delay slots with useful instructions (eliminating nops) At least 80% of nops need to be filled to get full "filling delay slots" Extra Credit Strategy The function prototypes for the various C and Assembly functions are as follows: C routines /* int main( int argc, char *argv[] ); */ void usage( const char * programName ); void updateBCDClock( unsigned char clock[] ); void displayBCDClock( const unsigned char clock[] ); /* * C routines only called from Assembly: * * size_t tm_hourOffset(); * size_t tm_minOffset(); * size_t tm_secOffset(); */ Assembly routines: void setBCDClock( const struct tm *tmPtr, unsigned char clock[] ); long strToLong( const char *str, const int base, const char *msg ); unsigned char updateBCDValue( unsigned char BCDBits, const unsigned int maxValue );
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Programming Assignment Two_ PA2 - Programming Assignment...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online