Manish Document
Manish Document
07 15/05/2021 Write an assembly program to find largest and smallest number from a
given array.
08 22/05/2021 Write an assembly program to sort an array in ascending and descending
order.
EXP 1. Write an introduction to 8085 Microprocessor, an 8085 kit and an 8085 simulator.
The 8085 is a conventional von Neumann design based on the Intel 8080. Unlike the 8080 it does not
multiplex state signals onto the data bus, but the 8-bit data bus is instead multiplexed with the lower
eight bits of the 16-bit address bus to limit the number of pins to 40. State signals are provided by
dedicated bus control signal pins and two dedicated bus state ID pins named S0 and S1. Pin 40 is used
for the power supply (+5 V) and pin 20 for ground. Pin 39 is used as the Hold pin. The processor was
designed using nMOS circuitry, and the later "H" versions were implemented in Intel's enhanced nMOS
process called HMOS ("High-performance MOS"), originally developed for fast static RAM products. Only
a single 5-volt power supply is needed, like competing processors and unlike the 8080. The 8085 uses
approximately 6,500 transistors.
The 8085 incorporates the functions of the 8224 (clock generator) and the 8228 (system controller) on
chip, increasing the level of integration. A downside compared to similar contemporary designs (such as
the Z80) is the fact that the buses require demultiplexing; however, address latches in the Intel 8155,
8355, and 8755 memory chips allow a direct interface, so an 8085 along with these chips is almost a
complete system.
Accumulator
It is an 8-bit register used to perform arithmetic, logical, I/O & LOAD/STORE operations. It is connected
to internal data bus & ALU.
Arithmetic and logic unit
As the name suggests, it performs arithmetic and logical operations like Addition, Subtraction, AND,
OR, etc. on 8-bit data.
There are 6 general purpose registers in 8085 processor, i.e. B, C, D, E, H & L. Each register can hold 8-
bit data.
These registers can work in pair to hold 16-bit data and their pairing combination is like B-C, D-E & H-L.
Program counter
It is a 16-bit register used to store the memory address location of the next instruction to be executed.
Microprocessor increments the program whenever an instruction is being executed, so that the
program counter points to the memory address of the next instruction that is going to be executed.
Stack pointer
It is also a 16-bit register works like stack, which is always incremented/ decremented by 2 during push
& pop operations.
Temporary register
It is an 8-bit register, which holds the temporary data of arithmetic and logical operations.
Flag register
It is an 8-bit register having five 1-bit flip-flops, which holds either 0 or 1 depending upon the result
stored in the accumulator.
MICROPROCESSOR 8085 SIMULATOR
The simulator has two parts, an assembler (built using PEGjs) which translates 8085 assembly code to
machine code and a 8085 microprocessor simulator (written in C and compiled to JS using Emscripten)
which executes machine code. This web application is a graphical interface for the simulator.
Simulator is a graphical simulator, assembler and debugger for the Intel 8085 microprocessor
in Linux and Windows. It is among the 20 winners of the FOSS India Awards announced on February,
2008. Simulator was originally written by Sridhar Ratnakumar in fall 2003 when he realized that no
proper simulators existed for Linux. Several patches, bug fixes and software packaging have been
contributed by the GNUSim8085 community. Simulator users are encouraged to contribute to the
simulator through coding, documenting, testing, translating and porting the simulator.
EXP.02 Add the 8 bit contents of memory locations XX00 H and XX01 H and place the
result in memory location XX02H.
MEMORY LOCATION :
ADDITION : 99H+39H=D2H
1 0 0 1 1 0 0 1 (99H)
+ 0 0 1 1 1 0 0 1 (39H)
1 1 0 1 0 0 1 0 (D2H)
ALGORITHM
Start the program by loading the first data into Accumulator.
Move the data to a register (B register).
Get the second data and load into Accumulator.
Add the two register contents.
Check for carry.
Store the value of sum and carry in memory location.
Terminate the program
PROGRAM ALGORITHM
LXI H 8000H HL points 8000H
MOV A, M Get first operand
INX H HL points 8001H
ADD M Add second operand
INX H HL points 8002H
MOV M, A Store result at 8002H
HLT Terminate program execution
NOTE:
THEORY : Consider the first 16-bit number 02H & 03H is stored in memory location 8501H & 8502h, the
second 16-bit number 05H & 04H is stored in memory location 8503H & 8504h.The result after addition
of two numbers is to be stored in the memory location 8505 H(LSB’s sum) & 8506H(MSB’s sum). Assume
program starts from memory location 8000H
PROGRAM:
NOTE:
Write a program to move blocks of bits from source location starting at 2500 to destination location
starting from 2600 where size of blocks is 05 bytes
Algorithm –
Load register pair H-L with the address 2500H
Load register pair D-E with the address 2600H
Move the content at memory location into accumulator
Store the content of accumulator into memory pointed by D-E
Increment value of register pair H-L and D-E by 1
Decrements value of register C by 1 If zero flag not equal to 1, go to step 3
Stop
Program:
Memory address Mnemonics Operands Comments
2000 MVI C, 05 [C]<-05
2002 LXI H, 2500 [H-L]<-2500
2005 LXI D, 2500 [D-E]<-2600
2008 MOV A, M [A]<-[[H-L]]
2009 STAX D [A]<-[[D-E]]
200A INX H [H-L]<-[H-L]+1
200B INX D [D-E]<-[D-E]+1
200C DCR C [C]<-[C]-1
200D JNZ 2008 Jump if not zero to
2008
200d HLT stop
Algorithm –
Take a count equal to 4
Store the starting address of both blocks in 2 different register pairs
Now exchange the contents at the addresses in both register pairs
Increment the values of both register pairs
Decrements count by 1
If count is not equal to 0 repeat steps 3 to 5
PROGRAM:
Procedure:-
To Feed the program and data in the RAM, for machine language follow the steps 7 to 9 and for
assembly language programming steps 10 to 14.
Press [M][ENTER]. Starting address here is 2000H, so syntax will be [M][ENTER].
The LCD display will show the address and its content. Modify the content according to the
program using keyboard then press [ENTER] or [SPACEBAR]. The content will be saved and
display will move the next address. Modify if required.
Use UP/DOWN arrow keys move between the memory locations.
Press [1][A] to select assembler mode.
The display will show ‘RAM ADR: [BLANK]’, asking for the starting address which is 2000H in the
above program.
Type [2000] and press [ENTER].
Display will show ‘2000: [BLANK]’. Type the mnemonics of the command operand etc. and press
[ENTER].
The display will show the next location. Type desired mnemonics and operand. Keep on doing
this until the end of the program.
Feed the data using the [M] command.
To RUN/ EXECUTE the program Press [G][$].
Go to memory locations used for result storage using [M] command and verify the results.
Program:
Precautions:-
(2) Make sure that all the machine codes / mnemonics are as per the program.
EXP 7. Write an assembly program to find largest and smallest number from a given array.
42H 21H 01H 1FH FFH 25H 32H 34H 0AH ABH
Let the list of numbers be from 2050H to 2059H and output at 2060H and 2061H.
Algorithm:
Explanation –
One by one all elements are compared with B and C register.
Element is compared with maximum, if it greater than maximum then it is stored in B register. Else,
it is compared with minimum and if it is less than minimum, then it stored in C register.
Loop executes 10 number of times.
At the end of 10 iterations, maximum and minimum are stored at 2060H and 2061H respectively.
Precautions:-
(1) Make sure proper handling of equipments/ kits.
(2) Make sure that all the machine codes/ mnemonics are as per the program.
EXP. 8 Write an assembly program to sort an array in ascending and descending order.
Problem – Write an assembly language program in 8085 microprocessor to sort a given list of n numbers
using Bubble Sort. Size of list is stored at 2040H and list of numbers from 2041H onwards.
Algorithm:
PROGRAM:
Address Instruction Comment
2000H LXI H, 2040H Load size of array
2003H MVI D, 00H Clear D register to set up a flag
2005H MOV C, M Set C register to set up a flag
2006H DCR C Decrement C
2007H INX H Increment memory to access list
2008H MOV A, M Retrieve list element in Accumulator