EXPERIMENT 1-8 K

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Faculty of Engineering

MAHSA UNIVERSITY

BEE 3013

Microprocessor and Microcontroller Lab

LAB MANUAL

Year 3

Semester 1
Doc No:
MAHSA/ENG/FM/09

ASSIGNMENT COVER SHEET Rev No: 0

Date:

Faculty of Engineering & IT


Department of Electrical and Electronics Engineering
Module Code Module Name
MPCL Microprocessor and Microcontroller Lab

Name of the student Mohammad Kanakri


Student ID
BEEE20046465
(MAHSA/ARU)
Email mohammadkanakry@gmail.com

Mobile Phone +60182737922


Batch/Intake
Academic Session December
Year/Level 3 Semester 2
EXPERIMENT 1: ADDITION AND SUBTRACTION OF TWO 8-BIT NUMBERS
Experiment 1.1 for 8085 Microprocessor Simulator
Objective:
To understand how to run assembly program to perform addition using microprocessor 8085
simulator
Equipment required:
1. 8085 Microprocessor Simulator

Procedure:
1. Turn on the microprocessor Simulator
2. Run the following assembly language

ADDRESS MNEMONICS
2003 LXI H 2000

2006 MOV A, M

2007 INX H

2008 ADD M

2009 INX H

200A MOV M, A

200B HLT

3. Capture and discuss the result in the lab report.

 CODE ERROR, FUNCTION, AND INSTRUCTION.


Code Function Comment
MVI A,02H Move immediate data 02H to A First data
STA 2000H Store data 02H in address 2000H in the Store data
accumulator
MVI A,03H Move immediate data 03H to A Second data
STA 2001H Store data 03H in address 2001H in the Store data
accumulator
LXI H,2000H Load and initiate 2000 into the HL register Add comma
MOV A,M Get the stored data back to A Remove space
INX H Add 1 to the value of the register No comment
ADD M Add the content of M to the Accumulator Operand
STA 2003H Move the content of A to register M Store the new data

1|Page
HLT Halt the program Execute
 PROBLEM
02H + 03H = 05H

 CODE FLOWCHART

 OUTPUT AND FIGURES

Figure (1) Store data 02H in address 2000H in the accumulator

2|Page
Figure (2) Store data 03H in address 2001H in the accumulator

Figure (3) Load and initiate 2000 into the HL register

3|Page
Figure (4) Get the stored data back to A

Figure (5) Add 1 to the value of the register

4|Page
Figure (6) Add the content of M to the Accumulator

Figure (7) Get the result and store it at A

5|Page
 DISCUSSION
In this experiment, to perform addition using microprocessor 8085 simulator,
normally, the microprocessor fetches, decodes, and executes one instruction after another in
this experiment before an HLT (halt) instruction is executed. The program is an instruction
cycle that consists of several instruction sets, such as read or writes operations between the
processor and memory, registers, or input/output machines, as well as the fetching, encoding,
and execution of a single instruction.
The program starts initializing the first data and the second data and stores them in
sequential addresses, then, load and initiate the program starting from the first address, the
program begins by using the LXI instruction to set the address in the memory pointer (HL) to
2000, then bring the stored data back to A, then performs an addition operation between two
numbers. The memory pointer's address is then expanded by one. The contents of the operand
(register or memory) are added to the contents of the accumulator, and the output is saved in
the accumulator, with the address being raised by one. The STA instruction copies and store
the contents of the source register from address 2002H into the destination register without
changing the contents of the source register, and at the end of the program, the contents of the
HL registers specify the location of one of the operands if it is a memory location, the result
is (05H + 02H = 07H).

 CONCLUSION
In summary, for the objective of this experiment, to understand how to run an
assembly program to perform addition using microprocessor 8085 simulators, the program is
used to store data and perform arithmetical operations, the above code used to add to the
number and store the data at a specified address, by providing two hexadecimal numbers and
store them in the memory for processing, the data that has been processed is stored at the
registers (Accumulator), then executing the program.

___________________________________________________________________________
___________________________________________________________________________
Experiment 1.2 for 8085 Microprocessor Simulator

6|Page
Objective:
To write an assembly program to subtract two numbers using microprocessor 8085 simulator
Equipment required:
1. 8085 Microprocessor Simulator

Procedure:
1. Turn on the microprocessor Simulator
2. Write the assembly code to subtract two numbers starting at address 3003 and
increment the address accordingly.
3. Capture and discuss the result in the lab report

 CODE ERROR, FUNCTION, AND INSTRUCTION.


Code Function Comment
MVI A,05H Move immediate data 05H to A First data
STA 2000H Store data 05H in address 2000H in the Store data
accumulator
MVI A,02H Move immediate data 02H to A Second data
STA 2001H Store data 02H in address 2001H in the Store data
accumulator
LXI H,2000H Load and initiate 2000 into the HL register Add comma
MOV A,M Get the stored data back to A Remove space
INX H Subtract 1 to the value of the register No comment
SUB M Subtract content of M to the Accumulator Operand
STA 2003H Move the content of A to register M Store the new data
HLT Halt the program Execute

 PROBLEM
1ST COMPLEMENT
05H - 02H = 03H

2ND COMPLEMENT
03H - 05H = -02H

7|Page
 CODE FLOWCHART

 OUTPUT AND FIGURES

Figure (1) Store data 05H in address 2000H in the accumulator

8|Page
Figure (2) Store data 02H in address 2001H in the accumulator

Figure (3) Load and initiate 2000 into the HL register

9|Page
Figure (4) Get the stored data back to A

Figure (5) Subtract 1 to the value of the register

10 | P a g e
Figure (6) Subtract content of M to the Accumulator

Figure (7) Get the result and store it at A

 DISCUSSION

11 | P a g e
In this experiment, to write an assembly program to subtract two numbers using
microprocessor 8085 simulators, the experiment runs to absorb a subtraction of two given
numbers, by providing the MIV which moves immediate data 05H and 02H to the
accumulator sequentially, at address 2000H and 2001H sequentially, which is resulting in a
positive number which has a first complement binary number (05H – 02H = 03H), and the
sign flag and the carry flag was disabled and state high = 0.
By providing different operand, it will move immediate data 02H and 05H to the
accumulator sequentially, which will be resulting in a negative number that has a second
complement binary number (02H – 05H = -03H), and both sign flag and carry flag will be
enabled and state high = 1, at address 2000H and 2001H sequentially, the output of this
experiment is always stored at the accumulator (A), at address 2003, this program used the
first complement so the hexadecimal result is (05H – 02H = 03H).

 CONCLUSION
In summary, for the objective of this experiment, to write an assembly program to
subtract two numbers using microprocessor 8085 simulators, the program runs to subtract to
given operand and obtain the value at the accumulator, the result stored at the accumulator
has second complement binary number, if the output number in a positive sign, carry and sign
flags will be disabled state, and if the output number in a negative sign, carry and sign flags
will be enabled state, All the condition code flags are affected depending upon the result, the
actual result is (05H – 02H = 03H).

12 | P a g e

You might also like