Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
41 views

Lecture How To Write Program

This document discusses how to write, assemble, and execute a program for the 8085 microprocessor. It provides an example of writing a program to add two numbers in hexadecimal and display the sum. The steps include writing the program logic, translating it to assembly language instructions, making a flowchart, and executing the program by converting the instructions to hexadecimal machine code and storing the code in memory to be run by the microprocessor.

Uploaded by

Vishal Gaur
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Lecture How To Write Program

This document discusses how to write, assemble, and execute a program for the 8085 microprocessor. It provides an example of writing a program to add two numbers in hexadecimal and display the sum. The steps include writing the program logic, translating it to assembly language instructions, making a flowchart, and executing the program by converting the instructions to hexadecimal machine code and storing the code in memory to be run by the microprocessor.

Uploaded by

Vishal Gaur
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

EE-16102: MICROPROCESSOR & COMPUTER ORGANIZATION

8085 Microprocessor: Program and Instruction Cycle

Dr. Vishal Kumar Gaur


Microprocessor: 8085A
How to Write, Assemble, and Execute a Program

Problem Statement: Write a simple program of adding two numbers in the 8085 language.
1. Program Logic: To write a program, divide a given problem in small steps in terms of the operations the
8085 can perform.
2. Assembly Language Program: Translate these steps into instructions.
3. Make a Flow Chart: Graphical representation of small steps
4. Executing the Program

2
Microprocessor: 8085A
How to Write, Assemble, and Execute a Program

 Problem Statement
 Write the instructions to load the two hexadecimal numbers 32H and 48H in register A and B, respectively.
Add the numbers, and display the sum at the LED output port PORT1.

1. Problem Logic
 The given problem can be divided in to following steps of operation.
i. Load the numbers in the registers.
ii. Add the numbers.
iii. Display the sum at the output port PORT1.

3
Microprocessor: 8085A
How to Write, Assemble, and Execute a Program

2. Assembly Language Program


 Block 1: MVI A,32H
MVI B,48H

 Block 2: ADD B

 Block 3: OUT 01H

 Block 4: HALT

3. Flowchart

4
Microprocessor: 8085A
How to Write, Assemble, and Execute a Program
4. Executing the Program
 From Assembly Language to Hex Code
 To convert the mnemonics into Hex code, we need to look up the code in the 8085 instruction set.

5
Microprocessor: 8085A
How to Write, Assemble, and Execute a Program
4. Executing the Program
 Storing Hex Code in Memory
 To store the program and display output, we have to know the memory address (from where program
begins) and the output port address.

1. Reset the system by pushing RESET key.


2. Enter the first memory address using Hex keys where the program should be stored. Let us assume it is
2000H.
3. Enter each machine code by pushing Hex keys. For example, to enter the first machine code, push the 3,E
and STORE key (STORE key may be labelled differently in different systems).
4. When you push STORE key, the program will store the machine code in memory location 2000 H and
upgrade the memory address to 2001H.
5. Repeat step 3 until the last machine code, 76 H.
6. Reset the system.

6
Microprocessor: 8085A
How to Write, Assemble, and Execute a Program
4. Executing the Program
 Converting from Hex Code to Binary Code
 Once the program is saved in memory. The monitor program stored in the Read-Only-Memory of the MPU
check the keys and convert Hex code into binary code.

 Hence, the program will be stored in memory as follows:

The program has eight


machine code and will
require eight memory
locations to store the
program

7
Microprocessor: 8085A
How to Write, Assemble, and Execute a Program
4. Executing the Program
 Tell the microprocessor where the program begins by entering the memory address 2000H.
 Now, push the execute key (or the key with a similar label) to begin the execution.
 As soon as the Execute function key is pushed, the MPU loads with 2000H in PC.
 The microprocessor begins to read one machine code at a time, and when it fetches the complete
instruction, it executes that instruction.
 For example: it fetch the machine code stored in memory locations 2000 H and 2001H and execute the
instruction MVI A,32H; thus it will load 32H in register A.
 The ADD instruction will add the two numbers, and the OUT instruction will display the answer 7A H at the
LED port.
 It continues to execute instructions until it fetches the HLT instruction.

8
Microprocessor: 8085A
How to Write, Assemble, and Execute a Program
Exercise this Example

1. Write assembly language program to Load the contents of memory locations 2100 H and 2101 H in B-
register and C-register respectively. The content of memory locations 2100 H and 2101H are 16 H and
19 H respectively.
2. Program 8085 in Assembly language to add two 99H and 39H. Store the result in register C.

3. Write an assembly language program to find the 2's complement of a hexadecimal number. The
hexadecimal number 6A H is stored in memory location 2100H and the answer is to be stored in 2101 H.

4. Write an assembly language program to multiply two decimal numbers 23 and 9 and store the answer
in some memory location.

5. Write assembly language program to find number of 1's and 0's in 8-bit number stored at 2010
memory address.

9
Thank You

10

You might also like