In: Electrical Engineering
1. The lines of code below form a counting loop:
LoadDelay mov.w #0x001A, R15
LoopTop dec.w R15
jnz LoopTop
Done
How many times will this loop execute? Provide the answer in decimal_________
2. Suppose the state of bits at P1OUT are 10110111 and the following line is executed:
xor.b #0x05,&P1OUT
What is the new state of bits at P1OUT after the above line executes? Provide the answer in binary_____________
3. What value is contained in R9 after the following lines complete execution?
mov #0x0C07, R9
bic #0x0703, R9
Provide the answer in hexadecimal_________
4. What value is contained in R9 after the following lines complete execution?
mov #0x0C07, R9
and #0x1783, R9
Provide the answer in hexadecimal_________
5. What value is contained in R9 after the following lines complete execution?
mov #0x0C02, R9
sub #0x0001, R9
Provide the answer in hexadecimal_________
6. Execute the following lines:
mov.w #0xFF02, R12
dec R12
jz CaseA
jmp CaseB
Which branch is taken? (circle one) CaseA CaseB
7. Execute the following lines:
mov.w #0x1234, R12
rra R12
What is the final value in R12?
Provide the answer in hexadecimal_________
8. Execute the following lines:
mov.w #0x8431, R12
rla R12
What is the final value in R12? Provide the answer in hexadecimal_________
Ans 1.> Here in the first line of code Register R15 is loaded with value 0x001A which is equivalent to 26 in decimal. so, from now loop will decrement it by 1 until the value in Register R15 Becomes 0, so after 26 iterations the value in R15 will become zero. Hence the loop will execute 26 times.
Ans 2.> Given initially P1OUT=10110111,
now, xor.b #0x05,&P1OUT will XOR the binary value of 0x05 i.e, 00000101 , with the value of P1OUT i.e, 10110111, so output =(00000101) XOR (10110111) = 10110010.
Ans 3.> Here in the first line of code, Register R9 is filled with value 0x0C07 and then the second line of code clears bits in the register R9 as,
R9= (NOT 0x0703) AND (0x0C07)
In binary, (NOT 0x0703) = inverting bits of 0703 =(1111 1000 1111 1100)
also, 0x0C07 in binary is (0000 1100 0000 0111)
so , R9= (1111 1000 1111 1100) AND (0000 1100 0000 0111) =0000 1000 0000 0100= 0x0804 in Hexadecimal.
Ans 4> in the first line of code Register R9 is loaded with 0x0C07= 0000 1100 0000 0111
in second line of code Value in register R9 is ANDed with immediate value 0x1783 ie, 0001 0111 1000 0011.
so, Answer is (0000 1100 0000 0111) AND (0001 0111 1000 0011) =0000 0100 0000 0011= 0x043 in Hexadecimal.
Ans 5.> In first line of code, Register R9 is loaded with 0x0C02, now in second line of code 0x0001 is subtracted from register R9.
So , Answer is (0x0C02 -0x0001)= 0x0C01
Ans 6.> Here in first line of code, Register R12 is loaded with 0xFF02 , in second line of code the value in R12 is decremented by 1 , so now the value in Register R12 is 0xFF01 which is not zero, so jz case 1 will not true and hence jmp case B will be executed so, The branch taken is Case B.
Ans 7.> Here in first line of code , R12 is filled with 0x1234 and in the second line of code , instruction is to rotate the bits in Register R12 To Right so, Answer after roatating the bits of R12 is 0x091A.
Ans 8> Here in first line of code R12 is filled with 0x8431 and in the second line of code, instruction is to rotate the bits in R12 to Left. so, After rotating the bits to right, the answer is 0x0862