Professional Documents
Culture Documents
CENG380 Midterm Review Exercises: CLC LDI R25, 0x55 Ror R25 Ror R25 A) B)
CENG380 Midterm Review Exercises: CLC LDI R25, 0x55 Ror R25 Ror R25 A) B)
Exercises
Ahmad Kobeissi
(ahmad.kobeissi@liu.edu.lb) July
16, 2021
Question 1.
What is the value of R25 after the execution of the following program?
CLC
LDI R25, 0x55
ROR R25
ROR R25
a) 0x2A
b) 0x15
c) 0x95
Question 2.
What will be the contents of R16 after the following instruction?
CLC
LDI R16, 0xCC
ASR R16
LSR R16
a) 0x94
b) 0xE6
c) 0x73
d) 0x33
Question 3.
What is the size of the data bus and the address bus connecting the ATMEGA32 microprocessor to the ROM?
ROM:
Data bus is 16-bits.
Address bus is 22-bits.
Question 4.
Explain the difference between the Harvard and Von-Neumann architectures. Which one is used in the ATMEGA32
microcontrollers?
The Harvard architecture designates separate busses for ROM and RAM. While the Von-Neuman architecture employs
a shared bus.
The ATMEGA32 microcontrollers use the Harvard architecture.
Question 5.
What is the maximum supported RAM and ROM in AVR ATMEGA32?
Max. supported = 2y * x (y is number of bits on address bus, x is number of bits on data bus)
RAM has 12 address bits bus; number of addressable locations is 212 = 4KB; multiply by 1 Byte: 4KB
ROM has 22 address bits bus; number of addressable locations is 222 = 4MB; multiply by 2 Bytes: 8MB
Question 6.
An ATMEGA32 has 0x7FF as the address of its last location of its RAM.
What is the size of the RAM?
Question 7.
An ATMEGA32 has 0x7FF as the address of its last location of its ROM.
What is the size of the ROM?
Question 8.
Translate the following program into its machine code values.
Question 9.
What are the contents of R18 and the carry flag after the execution of the following sequence of instructions?
SEC
LDI R18, 0xA9
ROR R18
ASR R18
R18: 0xEA; Carry: 0
Question 10.
What are the contents of R21 after performing the following sequence of instructions?
R21: 0x01;
Question 11.
Fill the following AVR assembly program with the appropriate code to multiply by 5 the contents of the RAM location
0x200 and store the lower byte of the result at the RAM location 0x700:
.org 0x00
LDI R16, 5
LDS R10, 0x200
MUL R16, R10
STS 0x700, R0
Question 12.
Fill the following AVR assembly program with the appropriate code to subtract the contents of the RAM location
0x600 from the contents of the RAM location 0x700 and store the result in R5:
.org 0x00
LDS R16, 0x700
LDS R17, 0x600
SUB R16, R17
MOV R5 , R16
Question 13.
What is the value of the C flag after the execution of the following program?
a) 0
b) 1
c) Unknown
Question 14.
Choose the answer from the multiple choices that correctly reflects the values of the SREG flags after the execution of
the following program:
Question 15.
The following instruction is a correct instruction:
a) True
b) False
Question 16.
How many general–purpose registers do the AVR microcontroller have?
a) 8
b) 16
c) 32
d) None of the mentioned
Question 17.
What is the mnemonic for the last AVR general-purpose register?
a) R0
b) R16
c) R31
d) R32
Question 18.
What will be the contents of R16 after executing the following program?
a) 0xDE
b) 0xDF
c) 0xE0
Question 19.
What will be the contents of R16 after executing the following program?
a) 0xDE
b) 0xDD
c) 0x13
Question 20.
To divide a signed number in register R16 by 2, we can use the instruction:
a) LSL R16
b) LSR R16
c) ASR R16
d) ROR R16
Question 21.
Which instruction clears the carry bit?
a) SEC
b) CLC
c) BCLR