homework1_solution

homework1_solution - unsigned int valid : 1; } bits;...

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

View Full Document Right Arrow Icon
2.2 By lookup using the table in Figure 2.5 on page 62, 7fff fffa hex = 0111 1111 1111 1111 1111 1111 1111 1010 two = 2,147,483,642 ten 2.3 By lookup using the table in Figure 2.5 on page 62, 1100 1010 1111 1110 1111 1010 1100 1110 two = cafe face hex 2.6 sll $t0, $t3, 9 # shift $t3 left by 9, store in $t0 srl $t0, $t0, 15 # shift $t0 right by 15 2.9 [12] <§2.5> Implement the following lines of C code in MIPS: int a = 27; struct { unsigned int data0 : 8; unsigned int data1 : 8; unsigned int data2 : 8;
Background image of page 1

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

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

Unformatted text preview: unsigned int valid : 1; } bits; bits.data0 = a; bits.data1 = bits.data0; bits.data2 = d; bits.valid = 1; Assume that the struct bits is in $s0 and the memory address of a is stored in $s1 Solution: lb $s0, 0($sl) # load the lower 8 bytes of a into bits sll $t0, $s0, 8 # $t0 = bits &lt;&lt; 8 or $s0, $s0, $t0 # bits.data1 = bits.data0 lui $s0, 0000 0000 0110 0100 # bits.data2 = d lui $t0, 0000 0001 0000 0000 # load a 1 into the upper bits of $t0 or $s0, $s0, $t0 # bits.valid = 1...
View Full Document

This note was uploaded on 04/15/2008 for the course ENGR 2405 taught by Professor Bittle during the Fall '08 term at North Texas.

Page1 / 2

homework1_solution - unsigned int valid : 1; } bits;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online