Escolar Documentos
Profissional Documentos
Cultura Documentos
b. How does the .DB directive slow down programs running on the ATMega328p? 1
The .DB directive is an assembler directive, which has absolutely no effect on the speed of
any program running on the ATMega328p
c. Illustrate the different types and sub-categories of memories in the ATMega328p. Furthermore, indicate 3
the commands used to transfer data between the general-purpose registers and main memory, IO registers,
stack and program memory with relevant arrows
COMSATS University Islamabad
Sessional-1 Examination Booklet
CLO2: Perform basic tasks with Microprocessors/Microcontrollers and interface digital devices using C/Assembly
language (C3-PLO2)
Q2. Please write an assembly language program that keeps a count of the number of times an ATMega16 5
controller is booted. Make sure that the designated space (where the count will be stored) is 0 the first time the
program boots.
.INCLUDE “M32DEF.INC”
.ESEG ; refer to the EEPROM location
.ORG 0x0000
COUNTER:
.DB 0x00 ; make sure that the value is 0 on the first boot
.CSEG
.ORG 0x0000
LOAD_EEPROM:
SBIC EECR, EEWE ; or SBIC EECR, 1 to check Write Enable
RJMP LOAD_EEPROM
SBI EECR, EERE ; or SBI EECR, 0 for Read Enable
IN R20, EEDR
INC R20
OUT EEDR, R20
STORE_EEPROM:
SBIC EECR, EEWE ;or SBIC EECR, 1 to check Write Enable
RJMP STORE_EEPROM
SBI EECR, EEMWE ;or SBI EECR, 2 for Master Write Enable
SBI EECR, EEWE ;or SBI EECR, 1 for Write Enable
…
…
…
; whatever the rest of the program is doing