

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Machine Dependent Prog; Subject: Engineering Computer Science; University: University of California - Davis; Term: Winter 2008;
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Practice Midterm Problem #1 Write the CUSP floating point representation for the decimal 135.0625.
Remember the CUSP’s representation is 8-bit exponent, followed by the sign bit, followed by the 16-bit mantissa which excludes the leading 1 (leading one is implicit). Thus, as 13510 = 10000111 2. 062510 =
. 00012. The binary representation of 135. 0625 is 10000111 .0001 = 1. 000011100010000 ∗ 27
8-bit exponent field = 7 = 135excess 128 = 10000111 2 Sign bit = 0 , positive number 16 bit mantissa field with implicit leading 1 = 000011100010000
Putting all that together you get: 100001110000011100010000 which is 870710.
Practice Midterm Problem #2 Signed ( 2 s^ complement) values are added or substracted in exactly the same manner as unsigned ones. Remember, as mentioned in the book, that computers do not substract – they negate the second operand and add them together. Also, in the case of unsigned addition, overflow occurs when the correct sum is too large to be represented using the available bits. In the case of unsigned substraction, overflow occurs if the value being substracted is the larger one. In the case of signed addition as well as substraction, overflow occurs when the result has an incorrect sign.
Assume signed, 2 s^ complement operation.
A56FF
Exercise #
Exercise #2 Convert the following C code into CUSP.
if (n <= 10) x = 1; else { x = 3; y = 5; }
In CUSP code.
LDA N ; n <= 10? CMA# 10 JGT ELSE ; If not, skip to else part LDA# 1 ; x = 1 STA X JMP AFTER ; Branch around else part ELSE: LDA# 3 ; x = 3 STA X LDA# 5 ; y = 5 STA Y AFTER: ... ; Both paths continue from here
More C code.
i = 1; while (i <= 10) { ... i++; }
In CUSP code.
LDA# 1 ; i = 1 STA I LOOP: CMA# 10 ; i <= 10? JGT OUT ; if not, break ... INC I ; i++ JMP LOOP ; go re-test i OUT: ...