UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
University
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
of
ENGINEERING & TECHNOLOGY
TAXILA
A PROGRAMMER'S PERSPECTIVE
MICROCONTROLLE
R SYSTEM DESIGN
LAB MANUAL
04
MUNIZA
21-CP-31
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
Practice of Assembly Language Instructions -I
OBJECTIVE:
➢ Practice the basic AVR assembly language instruction LDS, MOV, ADD, etc.
➢ Practice the AVR assembly language instructions for Data Memory
TASKS:
LAB TASK 01:
Write and assemble a program to add the following data and then use the simulator to examine the C,
H and Z flags after the execution of each addition. $92, $23, $66, $87, $F5?
OUTPUT:
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
LAB TASK 02:
Write and assemble the following program. Use the simulator to single-step and examine the flags
and register content after the execution of each instruction.
CODE:
.INCLUDE "[Link]"
LDI R20,$27
LDI R21,$15
SUB R20, R21
LDI R20,$20
LDI R21,$15
SUB R20, R21
LDI R24,95
LDI R25,95
SUB R24, R25
LDI R22,50
LDI R23,70
SUB R22, R23
L1: RJMP L1
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
OUTPUT:
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
LAB TASK 03:
Write and assemble a program to load a value into each location of R20 – R23. Use the COM
instruction to complement the value in each register. Use the simulator to singl step and examine the
flags and register content after the execution of each instruction?
OUTPUT:
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
QUESTION NO 04:
Write an assembly code to output data at Port B and Port C in such a way that Port B becomes ON
then Port C becomes Off and vice versa . Use the simulator to single-step and examine the flags and
I/O Ports after the execution of each instruction.?
OUTPUT:
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
QUESTION NO 05:
Write and assemble a program to add all the single digits of your CNIC numbers and save the result in
data memory in consecutive location then output this data to Port B. Pick 7 random numbers (all
single digit) if you do not want to use your ID number. Then use the simulator to single step the
program and examine the registers?
OUTPUT:
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
LAB TASK 06:
Add sum of series of first 9 numbers and save it into one of the registers. Again, take the sum of first 9
numbers and save it to another register. The contents of both the register must be added finally and
save the result data memory. Then use the simulator to single step the program and examine the
registers.?
OUTPUT:
UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING
COMPUTER ENGINEERING DEPARTMENT
QUESTION NO 07:
X=(A+B) – (C+D)
Implement the following equation and place the result in R16 register
OUTPUT: