Homework 1
CS/ECE 354, Fall 2003
Send e-mail questions to Nitin Agrawal, nitina@cs.wisc.edu
Due Friday, September 19, before 5pm.
Homework (48 points total)
Notes:
A subscript indicates the base of a number.
Subscripts are in base ten.
Partial credit may be given for incorrect answers only if
work is shown.
- (4 points) A research group has discovered a long lost
civilization that used writing.
Their alphabet contained 142 characters.
To record and preserve the content of written artifacts,
a fixed-size, binary encoding of each of the characters of the alphabet
will be used.
How many bits are needed to represent a character?
If a trinary encoding where to be used instead (of a binary encoding),
how many trinary symbols would be needed to represent a character?
- (12 points) Fill in the following table, giving
the same value in the different number systems across a row.
Decimal Binary Octal Hexadecimal
------- ------- ----- -----------
31
1010111
0573
0x13c
- (2 points) Give a base 3 representation for the value
481.129
- (2 points) Give a base 9 representation for the value
20101.213
- (4 points) Give an octal representation for the value
25.36
- (4 points) Give a base 5 representation for the value
123.34
- (3 points) Give a single sentence that describes what an assembler does.
- (3 points) Write the SAL equivalent of the following C/C++/Java statement:
dd = aa / ( -(bb) + cc );
You may assume that dd, aa, bb,
and cc have been declared as integers,
and that any temporary variables (t1, t2, etc.)
needed have also been declared.
- (5 points) Write the SAL equivalent of the following
C/C++/Java statement:
if ( (i <= 400) && (j == 0) ) {
x = i + y;
} else {
x = x - 1;
}
- (5 points) The following SAL code fragment does not work.
Identify the problem with the fragment, explain why the fragment
does not work, and give a code fragment that works
correctly.
The code fragment contains a procedure call and the procedure.
.data
proc_rtn_addr: .word
a: .word
x: .word
y: .word
.text
# the SAL code for the start of the program would be here
la proc_rtn_addr, rtn1
b proc
rtn1: done
proc: add a, a, 1
sub x, y, a
b proc_rtn_addr
- (2 points)
Which instructions in the (corrected) procedure
proc
of problem 10 change the value of the program counter? Why?
- (2 points) Which steps within the instruction fetch and execute cycle
require a memory access for a SAL arithmetic instruction?
Handing In the Homework
Turn in your file containing answers by running the script:
handinHW1 hw1file
where hw1file is an example name of a file
containing the homework answers.
The handinHW script submits your homework for you.
No printout will be turned in.
(We assume that you have put
/p/course/cs354-common/public/bin
in your path by now.)