1) Show the effect each instruction has on the N, Z, V, and C flags in the progr
ID: 3595354 • Letter: 1
Question
1) Show the effect each instruction has on the N, Z, V, and C flags in the program status register. Assume the N, Z, V, and C flags are initialized as indicated below. [ 10 points] LDR R4,=0x7FFFFFFF LDR R5,#0x1 CMP R4, R5 BGE S3 BHS S4 2) Would the BGE branch be taken or skipped in problem #1? Prove it using the logic equation the "BGE" instruction uses to determine whether to take or skip the branch. [2 points] 3) Would the code labeled S5 ever be executed? Why or why not? [2 points] 4) Write a small MSP432 code segment that adds the 64-bit binary numbers 0x1122 3344 5566 7788 and 0x8877 6655 4433 2211 together and stores the 64-bit binarv result to memory location 0x2000_0000. Enter the code in your lab tools and cross-check your answer. Include a printout of your source assembly file with the final answer. [5 points] 5) Write a small MSP432 code segment that subtracts the 64-bit binary numbers 0x0000 0000_1122_3344 from 0x1122_3344_5566_7788 and stores the 64-bit binary result to memory location 0x2000_0000. Enter the code in your lab tools and cross-check your answer Include a printout of your source assembly file with the final answer. [5 points]Explanation / Answer
1)
Rules:
1. Once a flag is set, it remains in that state until another instruction that affects the flags is executed.
N Z V C
1 0 1 0
LDR R4, =0x7FFFFFFF 1 0 1 0 // Rule 1 and Rule2
LDR R5, =0x1 1 0 1 0 // Rule 1 and Rule2
CMP R4, R5 0 0 0 0 // R4 != R5 rule 3, rule4,rule5
BGE S3 0 1 0 0
BHS S4 0 0 0 0
S5: …
S4: …
S3: …
2) BGE S3 will be taken as CMP R4, R5 à R4 >= R5 which is true.
3) No, S5 is never linked in the code. Only S3 & S4 are linked in BGE and BHS respectively. If S3 & S4 calls S5 explicitly then only it will be called which is not seen in above code.
4)
LDR R1, =0x1122334455667788
LDR R2, =0x8877665544332211
ADD R3, R1,R2
STR R3, [0x20000000+4]
5)
LDR R1, =0x1122334455667788
LDR R2, =0x8877665544332211
SUB R3, R1,R2
STR R3, [0x20000000+4]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.