Ecen 350 prelab questions with correct answers
Write |down |the |representation |of |R- |and |I-format |instructions. |Explain |the |purpose |of |each |
field |in |the |instruction.
(fill |in |the |large |text |box) |- |CORRECT |ANSWER✔✔-R-Format |Instructions: |opcode |(6 |bits), |Rm |
(5 |bits), |Shamt |(6 |bits), |Rn |(5 |bits), |Rd |(5 |bits)
opcode: |the |operation |instruction
Rm: |Source |register, |but |the |second |operand
Shamt: |Shift |amount
Rn: |Source |register, |but |the |first |operand
Rd: |Destination |Register
EXAMPLE:ADD |X1, |X2, |X3Translated |as: |X1 |(Rd) |= |X2 |(Rn) |+ |X3 |(Rm)
opcode: |ADD |= |10001011000 |in |binary
Rm: |X3 |= |00011 |(3 |in |binary)
Shamt: |0 |= |000000
Rn: |X2 |= |00010 |(2 |in |binary)
Rd: |X1 |= |00001 |(1 |in |binary)
Put |it |all |together: |10001011000 |00011 |000000 |00010 |00001
I-format |Instructions: |opcode |(10 |bits), |immediate |(12 |bits), |Rn |(5 |bits), |Rd |(5 |bits)
,opcode: |the |operation |instruction
immediate: |the |constant |being |added |in |the |instruction
Rn: |Source |register
Rd: |Destination |Register
EXAMPLE: |ADD |X0, |X0, |#0x64
(Because |there |is |a |constant, |we |are |using |ADDI)
opcode: |ADDI |= |1001000100
immediate/"constant": |#0x64 |(this |is |in |hex) |= |000001100100
Rn: |X0 |= |00000
Rd: |X0 |= |00000
Put |it |all |together: |1001000100 |000001100100 |00000 |00000
For |each |of |the |following |instructions, |list |the |instruction |format |type:
SUB |X1, |X2, |#4:
AND |X1, |X2, |X3:
CBZ:
B:
LDUR:
STURB:
(note: |you |will |likely |want |to |use |the |Green |Sheet |in |your |book |to |answer |this)
(fill |in |SIX |blanks) |- |CORRECT |ANSWER✔✔-I
R
CB
, B
D
D
Write |the |binary |encoding |for |the |following |instructions. |Indicate |the |different |fields |in |the |
encoding |by |placing |a |space |between |them.
ADD |X3,X2,X5:
ADD |X3, |X2, |#40:
SUB |X3,X5, |X3:
(fill |in |THREE |blanks) |- |CORRECT |ANSWER✔✔-10001011000 |00101 |000000 |00010 |00011
1001000100 |000000101000 |00010 |00011
11001011000 |00011 |000000 |00101 |00011
Translate |the |following |high-level |code |into |assembly |language.
Assume |variables |a |− |c |are |held |in |registers |X0 |- |X2 |and |f |− |j |are |in |X19 |- |X23
a=b-c;f=(g+h)-(i+j);
(fill |in |the |large |text |box) |- |CORRECT |ANSWER✔✔-GIVENS: |
a |= |X0; |b |= |X1; |c |= |X2
f |= |X19; |g |= |X20; |h |= |X21; |i |= |X22; |j |= |X23
SUB |X0, |X1, |X2 |(a |= |b |- |c)
Write |down |the |representation |of |R- |and |I-format |instructions. |Explain |the |purpose |of |each |
field |in |the |instruction.
(fill |in |the |large |text |box) |- |CORRECT |ANSWER✔✔-R-Format |Instructions: |opcode |(6 |bits), |Rm |
(5 |bits), |Shamt |(6 |bits), |Rn |(5 |bits), |Rd |(5 |bits)
opcode: |the |operation |instruction
Rm: |Source |register, |but |the |second |operand
Shamt: |Shift |amount
Rn: |Source |register, |but |the |first |operand
Rd: |Destination |Register
EXAMPLE:ADD |X1, |X2, |X3Translated |as: |X1 |(Rd) |= |X2 |(Rn) |+ |X3 |(Rm)
opcode: |ADD |= |10001011000 |in |binary
Rm: |X3 |= |00011 |(3 |in |binary)
Shamt: |0 |= |000000
Rn: |X2 |= |00010 |(2 |in |binary)
Rd: |X1 |= |00001 |(1 |in |binary)
Put |it |all |together: |10001011000 |00011 |000000 |00010 |00001
I-format |Instructions: |opcode |(10 |bits), |immediate |(12 |bits), |Rn |(5 |bits), |Rd |(5 |bits)
,opcode: |the |operation |instruction
immediate: |the |constant |being |added |in |the |instruction
Rn: |Source |register
Rd: |Destination |Register
EXAMPLE: |ADD |X0, |X0, |#0x64
(Because |there |is |a |constant, |we |are |using |ADDI)
opcode: |ADDI |= |1001000100
immediate/"constant": |#0x64 |(this |is |in |hex) |= |000001100100
Rn: |X0 |= |00000
Rd: |X0 |= |00000
Put |it |all |together: |1001000100 |000001100100 |00000 |00000
For |each |of |the |following |instructions, |list |the |instruction |format |type:
SUB |X1, |X2, |#4:
AND |X1, |X2, |X3:
CBZ:
B:
LDUR:
STURB:
(note: |you |will |likely |want |to |use |the |Green |Sheet |in |your |book |to |answer |this)
(fill |in |SIX |blanks) |- |CORRECT |ANSWER✔✔-I
R
CB
, B
D
D
Write |the |binary |encoding |for |the |following |instructions. |Indicate |the |different |fields |in |the |
encoding |by |placing |a |space |between |them.
ADD |X3,X2,X5:
ADD |X3, |X2, |#40:
SUB |X3,X5, |X3:
(fill |in |THREE |blanks) |- |CORRECT |ANSWER✔✔-10001011000 |00101 |000000 |00010 |00011
1001000100 |000000101000 |00010 |00011
11001011000 |00011 |000000 |00101 |00011
Translate |the |following |high-level |code |into |assembly |language.
Assume |variables |a |− |c |are |held |in |registers |X0 |- |X2 |and |f |− |j |are |in |X19 |- |X23
a=b-c;f=(g+h)-(i+j);
(fill |in |the |large |text |box) |- |CORRECT |ANSWER✔✔-GIVENS: |
a |= |X0; |b |= |X1; |c |= |X2
f |= |X19; |g |= |X20; |h |= |X21; |i |= |X22; |j |= |X23
SUB |X0, |X1, |X2 |(a |= |b |- |c)