Question: Consider the AVR assembly code provided below. Read the code and use your knowledge of assembly instructions to answer the questions given at the bottom

Consider the AVR assembly code provided below. Read the code and use your knowledge of assembly

instructions to answer the questions given at the bottom of this page.

.EQU var1 = 0b11011010 

.EQU var2 = 8

.DEF count = r17 

.ORG 0x0000

init:

RJMP init

.ORG 0x0046

LDI XH, HIGH(resultA) 
LDI XL, LOW(resultA) 
LDI YH, HIGH(resultB) 
LDI YL, LOW(resultB) 

CLR r10

LDI r20, var1

LDI count, var2 

loop:

skip:

CLC

ROR r20

BRCC skip

INC r1

ROL r10

done:

.DSEG

DEC count

BRNE loop

ST X, r10 ST Y+, r1 

RJMP done

.ORG 0x03FE

resultA: .BYTE 1 resultB: .BYTE 1 

Answer the following questions (assuming that the code has executed and reached the done label):

  1. (a) What is the decimal value of the count register?

  2. (b) In total, how many times is the instruction ROR r20 executed?

  3. (c) What are the hexadecimal values of r27 and r26?

  4. (d) What are the hexadecimal values of r29 and r28?

  5. (e) What hexadecimal address does the assembler assign to the label resultB?

  6. (f) What 8-bit binary value is stored in SRAM at the memory location specified by resultA?

  7. (g) What decimal value is stored in SRAM at the memory location specified by resultB?

Now, suppose that the entire program is executed again, with one small difference. Assume that the first line of the program is replaced with: .EQU var1 = 0b10101010 Assuming that the code has executed and reached the done label:

  1. (h) What 8-bit binary value is stored in SRAM at the memory location specified by resultA?

  2. (i) What decimal value is stored in SRAM at the memory location specified by resultB?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!