Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this function has to be done with SPARC assembly architecture Void convert To BC

ID: 3664923 • Letter: T

Question

this function has to be done with SPARC assembly architecture

Void convert To BCD( const long clockDecimal[], unsigned char clock BCD[]); This function will convert our decimal clock array to BCD format so it can be displayed. It takes the array of the HH, MM, and SS values in decimal (clockDecimal), and will convert them as follows: Each decimal value for hours, minutes, and seconds will be expanded into two nibbles (one byte for each unit of time). These BCD bytes will be stored into clock BCD. Remember that each byte can be represented by two hexadecimal digits these two hexadecimal digits will reflect the decimal value.

Explanation / Answer

updateClockDecimalValue.s

long updateClockDecimalValue( long * clockVal, long updateAmt, long maxVal );

convertToBCD.s

void convertToBCD( const long clockDecimal[], unsigned char clockBCD[] );

For example: Consider the time 11:56:23.

This will generate the bytes:

We can then store these bytes

into the clockBCD array.

HH = 0x11 = 00010001

MM = 0x56 = 01010110

SS = 0x23 = 00100011

checkRange.s

long checkRange( long minRange, long offset, long value );

Copied from PA1, no changes necessary.

isNegative.s

long isNegative( long num );

Copied from PA1, no changes necessary.

printChar.s

void printChar( char ch );

Copied from PA1, no changes necessary.

Unit tests you need to complete:

testparseStartTime.c

testconvertToBCD.c

testupdateClockDecimalValue.c

To compile:

$ make testparseStartTime

To run:

$ make runtestparseStartTime

(Replace “testparseStartTime” with the appropriate

Milestone Turn-in Instructions

Use the following turnin script to submit the milestone before the due date:

$ cse30_pa2milestone_turnin

Files required for Milestone:

convertToBCD.s

parseStartTime.c

updateClockDecimalValue.s

checkRange.s

isNegative.s

Makefile

pa2.h

pa2Strings.h

Function Prototypes of functions that are provided or you have already written:

long checkRange( long minRange, long offset, long value );

long isNegative( long num );

void printChar( char ch );

Function Prototypes of the C functions you will write:

int main( int argc, char * argv[] );

void usage( const char * programName );

unsigned long parseStartTime( long clockDecimal[], const char * time );

void displayBCDClock( const unsigned char clockBCD[] );

void updateClockDecimal( long clockDecimal[], long intervalSeconds );

Function Prototypes of the SPARC Assembly functions you will write:

long updateClockDecimalValue( long * clockVal, long updateAmt, long maxVal );

void convertToBCD( const long clockDecimal[], unsigned char clockBCD[] );

For the Milestone, you will need to complete:

parseStartTime(), convertToBCD(), and updateClockDecimalValue()

C Functions to be Written

Listed below are the modules to be written in C.

pa2.c