Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume that a 32 bit bit pattern already held in $ to has the following fields.

ID: 3678766 • Letter: A

Question

Assume that a 32 bit bit pattern already held in $ to has the following fields. Write instructions to extract the fields as indicated. Each can be done in two ox three instructions. So, field A is one bit wide in bit 31, and field E is 6 bits wide in bits 9 - 4, etc. Convert field C into an unsigned 32 bit value in register $t.2. Test the bit in field G and branch to LABEL if (and only if) it is 1. Convert field B into a two's complement signed value in register $t.2. A.s B is signed two's complement already.

Explanation / Answer

16)

a)
using lw ==> load instruction we can store field C into 32 bit register
lw $t2, 32($t0) ;assume $t0 holds the value of C

------------------------------------------------------------------------------------------
b)
using JE statement.. we can achieve this
JE statement make jump equal...
if it equals to value, then it jumps to label

Here is the code:

cmp eax, 1 ; eax will hold value of G
je LABEL ;jumping to label
; if G value doesn't have value 1.. then these lines will be executed

LABEL:
; when G value is equal to 1 then these lines will be executed


------------------------------------------------------------------------------------------------
c)
using cbw command we can achieve this ... it converts into signed number
mov al, $t1 ;assume #t1 holds the value of B
cbw ; ax holds the signed number .. cbw convert bytes into signed by adding sign bit.
mov $t2,ax ;storing signed number into $t2 register

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote