Machine Instructions - Machine Structures - Exams, Exams of Structural Analysis

Main points of this exam paper are: Machine Instructions, Assembly Language, Language Program, Program Segment, Given Machine, Handle Branches, Hexadecimal Byte, Byte Address, Relocation Entry, Cast Converts

Typology: Exams

2012/2013

Uploaded on 04/02/2013

shalabh_li43y
shalabh_li43y 🇮🇳

4.5

(18)

88 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS61C Midterm 2 Spring 03 (Clancy)
Problem
0
(1
point,
1
minute)
Put
your
login name on each page.
Also
make sure you have provided the
informa
-
tion requested on the
first
page.
Problem
1
(6
points,
15
minutes)
Consider the following three machine instructions, which appear in memory starting
at the address 0x00400000.
address
(in
hex)
contents
(in
hex)
00400000 12080002
00400004
3C11FFFF
00400008 08100004
Part
a
“Disassemble” the instructions; that
is,
give
an
assembly language program segment
that would be translated into the given machine language.
You
may use numeric
rather than symbolic register names.
A
list
of
op codes (Figure
A.19
from
P&H)
appears
at
the end
of
this
exam.
Handle branches and jumps specially; where you
would
normally have
a
label, pro
-
vide instead
a
hexadecimal byte address.
For
example, you should list
a
jump
to
the
first
instruction
as
j
0x00400000
and represent
a
branch
to
the
first
instruction, say
bltz,
similarly
as
bltz
$9,0x00400000
A2
pf3
pf4
pf5

Partial preview of the text

Download Machine Instructions - Machine Structures - Exams and more Exams Structural Analysis in PDF only on Docsity!

CS61C Midterm 2 Spring 03 (Clancy)

Problem 0 (1 point, 1 minute)

Put your login name on each page. Also make sure you have provided the informa-

tion requested on the first page.

Problem 1 (6 points, 15 minutes)

Consider the following three machine instructions, which appear in memory starting at the address 0x00400000.

address (in hex) contents (in hex) 00400000 12080002 00400004 3C11FFFF 00400008 08100004

Part a “Disassemble”the instructions; that is, give an assembly language program segment

that would be translated into the given machine language. You may use numeric

rather than symbolic register names. A list of op codes (Figure A.19 from P&H)

appears at the end of this exam. Handle branches and jumps specially; where you would normally have a label, pro-

vide instead a hexadecimal byte address. For example, you should list a jump t o the

first instruction as j 0x

and represent a branch to the first instruction, say bltz, similarly as

bltz $9,0x

Part b

Your login name: c^ s^6 1 c

For each of the instructionsindicate whether (a)it must have contributed an entry to

the relocation table, (b)it may have contributed an entry to the relocation table, or (c)

it could not have contributed an entry to the relocation table. Briefly explain your answers.

address (in hex) contents (in hex)

00400000

00400004

00400008

12080002

3 CllFFFF

08100004

explanation of why this instruction must have, may have, or could not contribute relocation entry

Your login name: c^ s^6 lc-,

Part c

Give the largest (signed) hexadecimal integer value that k could contain and still produce the output

Briefly explain your answer.

no change after conversion to float

Part d

Give the 4 - byte (single precision) IEEE floating-point representation (in hexadeci-

mal) of your answer to part c. Show how you got your answer.

45

Your login name: c^ s^6 1 c

Problem 3 (7 points, 24 minutes)

Both parts of this question involve code from our solution to lab assignment 9, which appears at the end of this exam.

Part a

Suppose that the output buffer were redefined as follows:

Below, describe clearly what other changes to the code are necessary to accommodate

the smaller buffer (give line numbers of statements to be modified, and say what

modifications are necessary).

buffer: .space 2

Execution traces

Version A

I p r i n t c h k f u l l i n t r p no t E m pt y intDone p r i n t chkfull i n t r p notEmpty intDone p r i n t chkfull i n t r p notEmpty i n t Done p r i n t alldone loop

1 7 1 6 25 3 3. 43 49 # 103 1 0 3 9 1 0 4 7 1 0 6 4

2053 2 0 6 1 2077 2080 2081-inf

Version C

p r i n t 1 chkfull i n t r p not E m p t y intDone p r i n t chkfull p r i n t chkfull i n t r p notEmpty intDone x i n t illdone .oop .ntrp

ntDone OOP

1otEmpty

7 1 6 25 3 3 43 49 59

1 0 3 9 1 0 4 7 1 0 6 5 1 0 6 8 1069- 2044 2053 2 0 6 1 2070 - w

IUUI- 1og-m name: (^) C S ~ ~ C -

p r i n t 1 chkfull 7 i n t r p 1 6 notEmpty 25 intDone 1 0 3 3 p r i n t 1 0 4 3 chkfull 1 0 4 9 i n t r p 1 0 5 4 notEmpty 1 0 6 3 intDone 2 0 7 1 p r i n t 2 0 8 1 chkfull 2 0 8 7 i n t r p 2 0 9 2

intDone 3 1 0 8 p r i n t 3 1 1 8 alldone 3 1 2 1

notEmpty 2 1 0 1

loop 3122-inf