Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

GYANMANJARI INSTITUTE OF TECHNOLOGY

Bachelor of Engineering | Semester : 6 | Computer Engineering

Microprocessor and
Interfacing
Course Code : 3160712

Prof. Mayank K. Champaneri


Computer Engineering Department
SYLLABUS

UNIT TITLE % WEIGHTAGE


1 Introduction to Microprocessor 8%

2 Microprocessor Architecture and Operations 7%

3 8085 Microprocessor 12%

4 Assembly Language Basics 13%

5 8085 Assembly Language Programs 12%

6 Stack and Subroutines 13%

7 I/O Interfacing 20%

8 Advanced Microprocessor 15%


UNIT : 5

8085 Assembly Language Programs


Looping 4
 Topics to be covered

 Writing 8085 assembly language programs


Assembly Language Programs
5

Program : 1
Store the data byte 50h into memory location 2000h.

MVI A, 50h ; Store 50h in the accumulator


STA 2000h ; Copy accumulator contents at memory location 2000h
HLT ; Terminate program execution

Result : (2000h)=50h
Assembly Language Programs
6

Program : 2
Copy the contents of register B to memory location 1000h.

MOV A, B ; Copy the accumulator into register C


STA 1000h ; Get the contents of memory location 1000h into accumulator
HLT ; Terminate program execution

Result : (1000h)=4Ah
Assembly Language Programs
7

Program : 3
Exchange the contents of memory locations 2000h and 2001h.

LDA 2000h ; Get the contents of memory location 2000h into accumulator
MOV B, A ; Save the contents into B register
LDA 2001h ; Get the contents of memory location 2001h into accumulator
STA 2000h ; Store the contents of accumulator at address 2000h
MOV A, B ; Get the saved contents back into A register
STA 2001h ; Store the contents of accumulator at address 2001h
HLT ; Terminate program execution

Result : (2000h)=44h and (2001h)=55h


Assembly Language Programs
8

Program : 4
Add two 8-bit numbers stored in memory locations 2050h and 2051h.
Store result in location 2052h.

LXI H, 2050h ; HL points 2050h


MOV A, M ; Get first operand
INX H ; HL points 2051h
ADD M ; Add second operand
INX H ; HL points 2052h
MOV M, A ; Store result at 2052h
HLT ; Terminate program execution

Result : (2050h)=14h and (2051h)=89h , 14h + 89h = 9Dh


Assembly Language Programs
9

Program : 5
Subtract two 8-bit numbers stored in memory locations 2050h and 2051h.
Store result in location 2052h.

LXI H, 2050h ; HL points 2050h


MOV A, M ; Get first operand
INX H ; HL points 2051h
SUB M ; Subtract second operand
INX H ; HL points 2052h
MOV M, A ; Store result at 2052h
HLT ; Terminate program execution

Result : (2050h)=51h and (2051h)=19h , 51h - 19h = 38h


Assembly Language Programs
10

Program : 6
Add two 16-bit numbers stored in memory locations 2000h and 2001h.
Store result in memory locations 2004h and 2005h.

LHLD 2000h ; Get first 16-bit number in HL


XCHG ; Save first 16-bit number in DE
LHLD 2002h ; Get second 16-bit number in HL
MOV A, E ; Get lower byte of the first number
ADD L ; Add lower byte of the second number
MOV L, A ; Store result in L register
MOV A, D ; Get higher byte of the second number
ADC H ; Add higher byte of the second number with carry
MOV H, A ; Store result in H register
SHLD 2004h ; Store 16-bit result in memory locations 2004h and 2005h
HLT ; Terminate program execution

Result : (2004h) = CCh , (2005h) = 76h


Assembly Language Programs
11

Program : 7
Find the 1’s complement of the number stored at memory location 3200h and store the
complemented number at memory location 3301h.

LDA 3200h ; Get the number


CMA ; Complement number
STA 3301h ; Store the result
HLT ; Terminate program execution

Result : (3200h)=55h , (3301h) = AAh


Assembly Language Programs
12

Program : 8
Find the 2’s complement of the number stored at memory location 4200h and store the
complemented number at memory location 4301h.

LDA 4200h ; Get the number


CMA ; Complement number
ADI 01h ; Add one in the number
STA 4301h ; Store the result
HLT ; Terminate program execution

Result : (4200h)=55h , (4301h) = AAh + 1 = ABh


Assembly Language Programs
13
Program : 9
Pack the two unpacked BCD numbers stored in memory locations 2200h and 2201h and store
result in memory location 2300h.

LDA 2201h ; Get the most significant BCD digit


RLC
RLC
RLC
RLC ; Adjust the position
ANI F0h ; Make least significant BCD digit zero
MOV C, A ; Store the partial result
LDA 2200h ; Get the lower BCD digit
ADD C ; Add lower BCD digit
STA 2300h ; Store the result
HLT ; Terminate program execution

Result : (2200h)=04 , (2201h) = 09 , (2300h) = 94


Assembly Language Programs
14

Program : 10
To shift an 8-bit data four bits right. Assume that data in register C.

MOV C, E
RAR
RAR
RAR
RAR
MOV C, A
HLT
THANK YOU

You might also like