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

Q10: Consider the following problem: writing an assembly code to check the value

ID: 3803851 • Letter: Q

Question

Q10: Consider the following problem: writing an assembly code to check the value of a signed variable x, if x>20 && x<25 then y=5 otherwise y=-5.

Do you think that the following code can be used to solve this problem? Explain?

AREA mycode, CODE, READONLY EXPORT asm_main

asm_main

LDR r0,=x;

LDR r1,=y;

LDR r2,[r0]

CMP r2,#20

CMPGT r2,#25

MOVLT r3,#5

MOVGE r3,#-5

STR r3,[r1]

AREA mydata, DATA, READWRITE

x DCD 12

y DCD 0

END

Q11: The assembly codes shown in parts a and b below perform the same task. Briefly explain the task, and highlight the approach used to perform the task by each part. a) TST r0, 0x01 ADDNE r1, r1, #1 b) LSRS r0, r0, #1 ADDHS r1, r1,#1

Q12: Do the assembly codes shown in parts (a) and (b) below perform the same task? Explain. a) TST r0, (1<<13) ADDNE r1, r1, #1 b) TEQ r0, (1<<13) ADDEQ r1, r1, #1

Q13: Write an assembly code to check the number stored in register r1, if it is even then store 0x12 in register r2, if it is odd then store 0x10 in register r2.

Q14: Suppose that registers r0 and r1 contain values as shown below r0 0b1010 1101 0001 0000 0000 0000 0000 0010 r1 0b0011 1111 1111 1000 0000 0000 0000 0000 What would be the content of register r2 after the execution of the following instructions? MOV r2, #0 CMP r0,r1 BGE else B done else MOV r2, #2 done

Explanation / Answer

Let me explain you everything in a step by step manner. To give an overview of each and every registers, where R0 to R12 are mainly serve as General-purpose registers.

Q11) The TST evaluates a bitwise AND operation for the execution to solve the assembly codes.

a)

b) The LSR operation is used to perfrom the logical shift by including the n bits,

Q12)

a)

b) The TEQ assembly code calculates a bitwise exclusive OR operation,

Q13) The assembly code used to check the number storing it in the registers r1 and even to check the storage locations for register r2.

Q14) The R0 and R1 contains the content for each registers in the execution of the following instructions like: