Question

In: Electrical Engineering

1. The lines of code below form a counting loop: LoadDelay mov.w #0x001A, R15 LoopTop dec.w...

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_________

Solutions

Expert Solution

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


Related Solutions

In this assignment, you will use a LOC counting tool to count the lines of code...
In this assignment, you will use a LOC counting tool to count the lines of code of the tool itself. 1. There are several open source free tools for LOC counting such as CLOC and SLOC. 2. Run the tool to count the lines of code of the source files of the tool (usually in the src directory). 3. Submit a report which includes: a. Description of the tool 1. Name 2. Creator 3. Language(s) it is written 4. URL...
Code in python Write a while loop code where it always starts form 2. Then it...
Code in python Write a while loop code where it always starts form 2. Then it randomly chooses a number from 1-4. If the number 4 is hit then it will write “TP” if the number 1 is hit then it will write”SL”. It will rerun the program every time the numbers 1 and 5 are hit. The code should also output every single number that is randomly chosen. 2 of the same numbers can't be chosen back to back...
Here is an example of jumping out of a loop too early. The code below is...
Here is an example of jumping out of a loop too early. The code below is intended to test if all of the letters in a string are in ascending order from left to right. But, it doesn’t work correctly. Can you fix it? Fix the code below so it does not leave the loop too early. Try the CodeLens button to see what is going on. When should you return true or false? p public class Loop3 { public...
Counting evens Write the pseudo-code for a brute force approach to counting the number of even...
Counting evens Write the pseudo-code for a brute force approach to counting the number of even integers in an array of n integers. Write the pseudo-code divide-and-conquer algorithm for counting the number of even integers in an array of n integers. Give the recurrence relation for the number of additions in your divide-and-conquer algorithm.  
Where is the infinite loop in the code? Input for the code 1 2.5 2 40200000...
Where is the infinite loop in the code? Input for the code 1 2.5 2 40200000 1 0 2 80400000 2 ffffffff 3 #include <stdio.h> #include <math.h> #include <stdlib.h> int count = 31; void toBinary(int num, int n){ for(int i = 1; i < n; i++){ if((int)(num/pow(2,(n-i))) > 0){ num = num - pow(2,(n-i)); printf("1"); count--; }else{ printf("0"); count--; } } } char checkSign (int sign) { char new_sign; if (sign == 0) { new_sign = '+'; return new_sign; }...
Counting integers greater than 10 Write the pseudo-code for a brute force approach to counting the...
Counting integers greater than 10 Write the pseudo-code for a brute force approach to counting the number of integers greater than 10 in an array of n integers. Write the pseudo-code divide-and-conquer algorithm for counting the number of integers greater than 10 in an array of n integers. Give the recurrence relation for the number of comparisons in your divide-and-conquer algorithm in part b.  
Study the following code with a while-loop and convert it to a for-loop (fill in the...
Study the following code with a while-loop and convert it to a for-loop (fill in the blanks). int i=4, result=1; while(i>1) { result *= i; i--; } The following for-loop performs the same functionality: int result=1; for (__________ i=4; i _________1;____________) { result *= i; }
The wavelengths in the hydrogen spectrum with m = 1 form a series of spectral lines...
The wavelengths in the hydrogen spectrum with m = 1 form a series of spectral lines called the Lyman series. Part A Calculate the wavelength of the first member of the Lyman series. Express your answer to three significant figures and include the appropriate units. λ1λ 1 = nothing nothing Request Answer Part B Calculate the wavelength of the second member of the Lyman series. Express your answer to three significant figures and include the appropriate units. λ2λ 2 =...
CODE WITH ARDUINO: With an RGB Led, Use the iterative loop (for loop) to make red,...
CODE WITH ARDUINO: With an RGB Led, Use the iterative loop (for loop) to make red, blue, and green. Use ‘analogWrite’ command inside the 'for loop.' Use the value ranges from 0-255 for this command. So, to activate any of the pins, the value should be 255. To turn off 0. pattern: First for loop Red light – delay – Second for loop for blue light – delay - Third for loop for green light - delay. (The resulting lights...
Write a python code which prints triangle of stars using a loop ( for loop )...
Write a python code which prints triangle of stars using a loop ( for loop ) Remember what 5 * "*" does The number of lines of output should be determined by the user. For example, if the user enters 3, your output should be: * ** *** If the user enters 6, the output should be: * ** *** **** ***** ****** You do NOT need to check for valid input in this program. You may assume the user...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT