Question 1
Q1
C code
Int i, n = 0, c = 0, y = 0;
While ( LastName [ c ] == FirstName [ n ] )
{ if ( i != n )
{ While ( NameList [ i ] == LastName [ c ] )
{ y + = 1;
I + = 1; } }
Else
{ FullName [ i ] = LastName [ c ] + FirstName [ n ]; } }
i is in $S0, c is in $s2
n is in $S1, y is in $s3
Base address for array ‘LastName’* is in $S6
Base address for array ‘FirsName’* is in $S7
Base address for array ‘FullName’* is in $S5
*Note:- Use your First name, Last name and Full name in place of the arrays FirstName, LastName and FullName, respectively
A) Convert the above given C code to MIPS assembly code
B) Convert the MIPS assembly code from part ‘A’ to Machine Language (Binary).
Question 2
Q2 ML (BINARY)
ADDRESS
1000 000000 00000 10110 01000 00010 000000
1004 000000 10110 01000 01000 00000 100000
1008 100011 01000 01001 0000 0000 0000 0000
1012 000000 00000 10111 01010 00010 000000
1016 000000 10111 01010 01010 00000 100000
1020 100011 01010 01011 0000 0000 0000 0000
1024 000100 01001 01011 0000 0100 0001 1100
1028 000101 10110 10111 0000 0100 0001 0000
1032 000000 01001 01011 10110 00000 100000
1036 000010 00 0000 0000 0000 0011 1110 1000
1040 000101 01011 10110 0000 0011 1110 1000
1044 001000 10111 10111 1111 1111 1111 1111
1048 000010 00 0000 0000 0000 0011 1110 1000
1052
A) Convert the above given ML (Binary) code to MIPS.
B) Convert the MIPS code from part A to C code.
Note:- You can use any name for the arrays in the C code.