{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

H2soln - Prohlem l Endian Representation[18 points The...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 4
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 6
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Prohlem l. Endian Representation [18 points} The following as serrih 13-; code sequence is executed on two differem machines, one of which is hig—endian and the other little—endian. 1W $5: {“155} Min $T, 4E$53I 1—11 $3: 5E$51 lui $9, DxBABE ori $9, $9, EIxFEED 1b $1EI, 11[$5]I 1bu $11, 14l$51| Gri $12, $12, DXFEED lui $12, [la-{BABE ID $13; 5l$5l 1W $14, EE$EIII The initial contents of memory are the same on both machines, as shown in below. Word 5,, we —IE---“ umuurnuu umuurum UflEDDFDDB mm DHZDDFDDC mm a} Contents of the registers on the hig—endian machine afier execution of all instructions {assume 5:5 to 513 are initially El}: _ _ @— h) Contents of the registers on the little—endian maehine after execution of all instructions {assume $6 to 513 are initially tit]: DxlEDDFDDD DKADDEDECD DKDDDDCEFA DKDDDDEEFI DKEAEEFEED DKFFFFFFCI DKDDDDDDCA 2 DKEAEEDDDD DXFFFFFFFI DKCIAEDDEE Problem 2. Answer the following questions about the following MIPS funetlon [15 points} [a] What is the size, in words, of foo‘s staek frame? 22 [b] How many arguments does foo have? For eaeh argument, list the plaee where foo would find it. At least IS. The first four are in the argument registers Sail, Sal, Sa2, Sa3, and the next two are on the stack at of'f'sets sp+l [l4 and sp+l US. to) How many words are reserved in foo’s staek frame to preserve “saved registers”? What are the staek frame offsets [in bytes] for eaeh of these registers? There are ti saved registers at offsets sp+24, sp+28, sp+32, sp+3ti, sp+4[l, and sp+44. (d) What is the stack frame offset {in bytes) for saving the return address? The offset is sp+43. {e} Does foo“ s staek frame have a pad? If so what is its staek frame offset [in bytes)? Yes. The offset is sp+52. {1) How many words are reserved in foo‘s staek frame for loeal data storage? 3 words. {g} At point X in foo, list all the registers whose value foo eould ehange without violating the MIPS oalling oonvention? Stfl—St‘il, Ssll, $sl, SsE, Ss3, SsS, $s7, Svtl, Sit] and SaD-Sa3 [Era may also be included in the answer, but is not required.) {h} Does this ehange at point Y? If so, list the additional registers available for foo to use at this point. No change. You may inolude a drawing of the staek frame in your solution [this may he eonsidered by the graders for partial eredit, if necessary.) The stack frame for foo is as follows: 5P+103 5P+|D4 5P+|UU — 5P+95 — 5P+93 — 5P+33 — 5P+34 — 5P+30 — 5P+75 — 5P+TE Problem 3. Design a stack frame for the function bar. (15 points} The Emotion bar is exaotly the same a foo, except that [1} it requires storage for 4 saved registers and [2) it only requires space in its looal data storage area for an array of 4 words. Answer the following questions about bar‘ s staek frame {a} What is the size, in words, of bar’s staek frame? Io" words {b} What are the staok frame offsets {in bytes) for eaeh of bar‘s saved registers? 5p+24, sp+28, sp+32, sp+3fi {o} What is the stash frame offset {in bytes} for saying the return address? sp+4ll {d} Does bar” s staok frame have a pad? If so what is its staok frame offset [in bytes}? Yes, sp+44 {e} What are the offsets of the first and last word of loeal storage? sp+48 and sp+fill {1] Where do you find bar‘s argl}? argl ?, arg2?, arg3?, arg4?, arg5?, arg6?, arg?? SE10, Sal, Sa2, Sa3, sp+3fl, sp+34, sp+83, sp+92 {g} Sketoh the staek frame for bar. Show what is to be found at eaoh offset in the staok frame. [A text 1.rersion of the drawing is UK as long as it olear.) The stack frame for foo is as follows: saved re 3 say ed re 2 say ed re I say ed re CI _| __ __ __ __ —- __ Problem 4. Create a stack frame for the function foobar. (15 points} The flinction foobar has 2 arguments, requires 5 saved registers, requires 3 words of local data storage, and calls functions with 4, 6, and S arguments. (a) How many words are required by foobar's argument section? What are the stack frame offset for each of these words? 3, sp+Li, sp+4, sp+3, sp+12, sp+l I5, sp+2[l, 5p+24, 5p+23 (b) How many words are required for saved registers? What are the stack frame’s offsets for each of these words? 5, sp+32, sp+36, sp+40, sp+44, sp+48 (c) What is the stack frame offset {in bytes} for saving the return address? sp+52 {d} Does foobar’s stack frame have a pad to double word align the local data storage? If so what is its stack frame offset {in bytes}? No (e) How many words are required in foobar’s stack frame for local data storage? 4 words {i} What is the size {in bytes} of foobar‘s stack frame? T2 bytes (1 3 words} [g] Sketch the stack frame for bar. Show what is to be found at each offset in the stack frame. {A text version of the drawing is OK as long as it clear.) The stack frame for foobar is as follows: sFI+SU sp+T6 sp+T2 sp+u58 sp+64 ]ooa] data sp+60 stora e sp+55 sp+52 Sra sp+48 saved re ister 4 sp+44 saved re ister 3 sp+40 saved re ister 2 sp+35 saved re ister I sp+32 saved re ister D sp+28 ar T sp+24 ar 6 sp+20 ar 5 sp+lfi ar 4 sp+12 (ar 3} sp+8 ar sp+4 ar I so (ar 0} Problem 5. MIPS Assembly,r Programming [21} points} A beginning student wrote the following MIPS assembly language program, but ran screaming from the room before hefshe oould finish. F: ### Start Prologue HERE ### acidic. 529,529, 415 3w 33L,32[EE§] 3w 535,2Gfi529] 3w 53L,24[52§] 3w 531,23fi525] ### End Prologue HERE ### 1w $tB,EB[$EPl ow $afl.4&t$epl addi $el,$a1,1 addi $a2.$a3,12 sub $a3,$efl,$sfl addi $t3,,$t3..11‘r 1w $510.43 t$spl ow $el.lfit$spl or $al.$0.$sl 5w $tE.40t$epl jal G 1w $t3,40£$5pl add $55,$v0,$t3 xor $ST.$VD.$aD sub $tflr$55.$eT add $v0,$55,$sl ### Start Epilogue HERE ### +++++ 1w 537,2ofiore] ;w 53;,2flt525] ;w 535,2G[32§] ;w 53L,32[52§] addiu 529,529.45 ##t': End Epilogue HERE Hit jr $31 As you ean see the body of the funet ion F has been oompleted, but there is no prologue or epilogue. Nor is there any indieation of what the stack frame looks like. Please answer the questions on the following pages. a) How many words are required for the stack frame for F? 43 h} Dees the staek flame ferF require an argument bleek? If se, what is its size in werds? Yes, 5 werds e) Dees the staek flame fer F require a saved registers bleek? If se, what is its size in werds? What are the saved registers? Yes, 3 werds fer registers Sis], SsS, and $s? d] Dees the staek flame fer F require a return address bleek? If se, what is the effset fer the return address? Yes, effset sp+32 e] Dees the staek flame fer F require a pad henveen the argument, saved register andfer return address bleeks and the leeal data sterage? Yes f] Dees the staek flame fer F require leeal data sterage? If se, what is its tetal size in werds [including an}:r neeessarv padding]? Yes, 2 werds. Duly the werd at eff'set 4D is used; the werd at ef'f'set 44 is padding. Dees F use its eallers staek flame fer anything? If se, what? Yes, it steres the value ef Sat] inte the eallefis stack flame (eff set 43}. It aise retrieves the value ef its 5m argument frern the caller’s stack frame {ef'f'set 53}. g} In the empty staok frame below, fill in the blanks with a short desoription of the purpose of that word, e. g., “local variable storage". Ca] lens ’5 steel: frame PAD Era F’ 5 stat: k frame [i]: Fill in the entire prologue and epilogue for the proeeclure F in the spaoes provided {more than one instruotion may be neoessary.) Be sure to observe eorreet calling oonvennons ...
View Full Document

{[ snackBarMessage ]}