Microprocessors and Applications CCE 322
Lecture 5
Assembly Programming of 8085-Part I
Dr. Emad Badry
Stack
❑ In 8085 microprocessor systems, the beginning of the stack is defined in the program by using the instruction
LXI SP, 16-bit. The LXI SP is a 16-bit state that loads the 16-bit address into the stack pointer register.
Lecture 5: Instruction set of 8085- Part I
Lecture 5: Instruction set of 8085- Part I
❑ The stack space grows upward in
the numerically decreasing order of
memory addresses.
Lecture 5: Instruction set of 8085- Part I
❑ Information in the stack locations may
not be destroyed until new
information is stored in that memory
location.
Lecture 5: Instruction set of 8085- Part I
Subroutines
❑ When a main program calls a subroutine, the program execution is transferred to the subroutine and
after the completion of the subroutine, the program execution returns to the main program.
❑ The microprocessor uses the stack to store the return address of the subroutine.
❑ A subroutine is implemented with two associated instructions, namely, Call and Return. Call is used to
call a subroutine and the Call instruction is written in the main program. Return is used to return from the
subroutine.
Lecture 5: Instruction set of 8085- Part I
❑ The general characteristics of CALL and RET instructions are given below:
The following types of subroutines are generally used in microprocessors:
1. Multiple CALL subroutines
2. Nested subroutines
3. Multiple ending subroutines
Lecture 5: Instruction set of 8085- Part I
Multiple CALL subroutines
❑ This is a subroutine called from many locations in the
main program.
❑ These types of routines are easy to trace and need
minimal stack space
Lecture 5: Instruction set of 8085- Part I
Nested subroutines
❑ When the subroutine is called by another subroutine, it
is called a nested subroutine.
❑ When a subroutine calls another subroutine, all return
addresses are stored on the stack. Therefore, only the
number of available stack locations limits the extent of
nesting.
Lecture 5: Instruction set of 8085- Part I
Multiple ending subroutines
❑ When a subroutine can be terminated at more than one place, it is called
a multiple ending subroutine.
❑ This subroutine has an unconditional return (RET).
Lecture 5: Instruction set of 8085- Part I
Instruction Format
❑ Each statement in an assembly-language program consists of the following fields: Memory address, Machine
Codes, Labels, Mnemonics, Operands and Comments.
Examples
Lecture 5: Instruction set of 8085- Part I
Examples of Assembly programs
❑ Consider the first number 26H is stored in the memory location 8000H and the second number 62H is
stored in the memory location 8001H. The result after addition of two numbers is to be stored in the
memory location 8003H. Assume the program starts from the memory location 8500H.
Lecture 5: Instruction set of 8085- Part I
Lecture 5: Instruction set of 8085- Part I
Lecture 5: Instruction set of 8085- Part I
Lecture 5: Instruction set of 8085- Part I
Lecture 5: Instruction set of 8085- Part I
❑ The first number F2H is stored in the memory
location 8501H and the second number 2FH is
stored in the memory location 8502H. The result
after addition will be stored in the memory
locations 8503H and 8504H. Consider the program
is written from the memory location 8000H.
Lecture 5: Instruction set of 8085- Part I
Lecture 5: Instruction set of 8085- Part I