Computer Organization Architecture and Assembly Language File/8085 File
Computer Organization Architecture and Assembly Language File/8085 File
TECHNOLOGY
SUBMITTED TO:
SUBMITTED BY:
Enrollment no.
INDEX
S.NO
.
1.
2.
3.
4.
5.
Title
6.
7.
Theory of 8085
Features
Architecture
40 Pin diagram of 8085
Instructions symbols according to categories
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
Page
No.
Remar
k
Theory of 8085
Registers
The 8085 programming model includes six registers, one accumulator, and one flag register. In
addition, it has two 16-bit registers: the stack pointer and the program counter. They are described
briefly as follows. The 8085 has six general-purpose registers to store 8-bit data; these are identified
as B,C,D,E,H, and L. They can be combined as register pairs - BC, DE, and HL - to perform some
16-bit operations. We cant combine registers in the form of CD, EH. The programmer can use these
registers to store or copy data into the registers by using data copy instructions.
Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic unit (ALU). This register is
used to store 8-bit data and to perform arithmetic and logical operations. The result of an operation
is stored in the accumulator. The accumulator is also identified as register A.
Flags
The ALU includes five flip-flops, which are set or reset after an operation according to data
conditions of the result in the accumulator and other registers. They are called Zero(Z), Carry (CY),
Sign (S), Parity (P), and Auxiliary Carry (AC) flags; they are listed in the Table and their bit
positions in the flag register are shown in the Figure below. The most commonly used flags are
Zero, Carry, and Sign. The microprocessor uses these flags to test data conditions.
For example, after an addition of two numbers, if the sum in the accumulator is larger than eight
bits, the flip-flop uses a flag to indicate a carry -- called the Carry flag (CY) -- which is set to one.
When an arithmetic operation results in zero, the flip-flop called the Zero(Z) flag is set to one.
There is an 8-bit register, called the flag register, adjacent to the accumulator. However, it is not
used as a register; five bit positions out of eight are used to store the outputs of the five flip-flops.
The flags are stored in the 8-bit register so that the programmer can examine these flags (data
conditions) by accessing the register through an instruction. These flags have critical importance in
the decision-making process of the microprocessor. The conditions (set or reset) of the flags are
tested through the software instructions. For example, the instruction JC (Jump on Carry) is
implemented to change the sequence of a program when CY flag is set. The thorough understanding
of flag is essential in writing assembly language programs.
D7
S
D6
Z
D5
D4
AC
D3
D2
P
D1
D0
CY
Instruction Register/Decoder
It is a temporary store for the current instruction of a program. Latest instruction are sent here from
memory prior to execution. Decoder then takes the instruction and decodes or interprets the
instruction. Decoded instruction then is passed to the next stage.
Features
It has 16-bit address lines - A0-A15 (to point the memory locations) and hence can point up
to 2^16 = 65535 bytes (64KB) memory locations.
The first 8 lines of address bus and 8 lines of data bus are multiplexed AD0-AD7. Data bus
is a group of 8 lines D0-D7.
It provides 1 accumulator, 2 flag register, and six 8-bit general purpose register arranged in
pairs: BC, DE, HL and 2special purpose registers.
It requires a signal +5V power supply and operates at 3.2 MHZ single phase clock with
maximum clock frequency 6 MHz and minimum clock frequency 500 kHz.
It can be used to implement (interface) 3 chip micro-computers (8085, 8155, 8255 and 8355:
Peripheral IC's).
Architecture
This is the functional block diagram of the 8085 Microprocessor.
Accumulator
It is an 8-bit register which is used to perform arithmetical and logical operation. It stores the
output of any operation. It also works as registers for i/o accesses.
Temporary Register
It is an 8-bit register which is used to hold the data on which the accumulator is computing
operation. It is also called as operand register because it provides operands to ALU.
Registers
These are general purposes registers. Microprocessor consists 6 general purpose registers of 8bit each named as B, C, D, E, H and L. Generally theses registers are not used for storing the
data permanently. It carries the 8-bits data. These are used only during the execution of the
instructions.
These registers can also be used to carry the 16 bits data by making the pair of 2 registers. The
valid register pairs available are BC, DE, and HL. We cannot use other pairs except BC, DE and
HL. These registers are programmed by user.
ALU
ALU performs the arithmetic operations and logical operation.
Flag Registers
It consists of 5 flip flops which changes its status according to the result stored in an
accumulator. It is also known as status registers. It is connected to the ALU.
There are five flip-flops in the flag register are as follows:
Sign(S)
Zero (z)
Auxiliary carry (AC)
Parity (P)
Carry(C)
The bit position of the flip flop in flag register is:
D7
D6
D5
D4
AC
D3
D2
D1
D0
CY
All of the three flip flops set and reset according to the stored result in the accumulator.
1. SignIf D7 of the result is 1 then sign flag is set otherwise reset. As we know that a number on the D7
always decides the sign of the number. if D7 is 1: the number is negative. if D7 is 0: the number
is positive.
2. Zeros (Z)If the result stored in an accumulator is zero then this flip flop is set otherwise it is reset.
3. Auxiliary carry (AC)If any carry goes from D3 to D4 in the output then it is set otherwise it is reset.
4. Parity (P)-
If the no of 1's is even in the output stored in the accumulator then it is set otherwise it is reset
for the odd.
5. Carry(C)If the result stored in an accumulator generates a carry in its final output then it is set otherwise
it is reset.
Instruction Decoder
Instruction decoder identifies the instructions. It takes the informations from instruction register
and decodes the instruction to be performed.
Program Counter
It is a 16 bit register used as memory pointer. It stores the memory address of the
next instruction to be executed. So we can say that this register is used to sequencing the
program. Generally the memory has 16 bit addresses so that it has 16 bit memory. The program
counter is set to 0000H.
Stack Pointer
It is also a 16 bit register used as memory pointer. It points to the memory location called stack.
Generally stack is a reserved portion of memory where information can be stores or taken back
together.
There are two pins in this unit. This unit is used for serial data communication.
Interrupt Unit
There are 6 interrupt pins in this unit. Generally an external hardware is connected to these pins.
These pins provide interrupt signal sent by external hardware to microprocessor and
microprocessor sends acknowledgement for receiving the interrupt signal. Generally INTA is
used for acknowledgement.
Register Section
Many registers has been used in microprocessor. PIPO shift register It consists of PIPO (Parallel
Input Parallel Output) register.
Properties
Single + 5V Supply
4 Vectored Interrupts (One is Non Maskable)
Serial In/Serial Out Port
Decimal, Binary, and Double Precision Arithmetic
Direct Addressing Capability to 64K bytes of memory
The Intel 8085A is a new generation, complete 8 bit parallel central processing unit
(CPU). The 8085A uses a multiplexed data bus. The address is split between the 8bit
address bus and the 8bit data bus. Figures are at the end of the document.
Pin Description
The following describes the function of each pin:
ALE (Output)
Address Latch Enable: It occurs during the first clock cycle of a machine state and
enables the address to get latched into the on chip latch of peripherals. The falling
edge of ALE is set to guarantee setup and hold times for the address information.
ALE can also be used to strobe the status information. ALE is never 3stated.
SO, S1 (Output)
Data Bus Status. Encoded status of the bus cycle:
S1 S0
O O HALT
0 1 WRITE
1 0 READ
1 1 FETCH
S1 can be used as an advanced R/W status.
RD (Output 3state)
READ; indicates the selected memory or 1/0 device is to be read and that the Data
Bus is available for the data transfer.
WR (Output 3state)
WRITE; indicates the data on the Data Bus is to be written into the selected memory
or 1/0 location. Data is set up at the trailing edge of WR. 3stated during Hold and Halt
modes.
READY (Input)
If Ready is high during a read or write cycle, it indicates that the memory or
peripheral is ready to send or receive data. If Ready is low, the CPU will wait for
Ready to go high before completing the read or write cycle.
HOLD (Input)
HOLD; indicates that another Master is requesting the use of the Address and Data
Buses. The CPU, upon receiving the Hold request. will relinquish the use of buses as
soon as the completion of the current machine cycle. Internal processing can continue. The
processor can regain the buses only after the Hold is removed. When the Hold is
acknowledged, the Address, Data, RD, WR, and IO/M lines are 3stated.
HLDA (Output)
HOLD ACKNOWLEDGE; indicates that the CPU has received the Hold request and
that it will relinquish the buses in the next clock cycle. HLDA goes low after the Hold
request is removed. The CPU takes the buses one half clock cycle after HLDA goes
low.
INTR (Input)
INTERRUPT REQUEST; is used as a general purpose interrupt. It is sampled only
during the next to the last clock cycle of the instruction. If it is active, the Program
Counter (PC) will be inhibited from incrementing and an INTA will be issued. During
this cycle a RESTART or CALL instruction can be inserted to jump to the interrupt
service routine. The INTR is enabled and disabled by software. It is disabled by Reset
and immediately after an interrupt is accepted.
INTA (Output)
INTERRUPT ACKNOWLEDGE; is used instead of (and has the same timing as) RD
during the Instruction cycle after an INTR is accepted. It can be used to activate the
8259 Interrupt chip or some other interrupt port.
RST 5.5
TRAP (Input)
Trap interrupt is a nonmaskable restart interrupt. It is recognized at the same time as
INTR. It is unaffected by any mask or Interrupt Enable. It has the highest priority of
any interrupt.
RESET IN (Input)
Reset sets the Program Counter to zero and resets the Interrupt Enable and HLDA
flipflops. None of the other flags or registers (except the instruction register) are
affected The CPU is held in the reset condition as long as Reset is applied.
X1, X2 (Input)
Crystal or R/C network connections to set the internal clock generator X1 can also be
an external clock input instead of a crystal. The input frequency is divided by 2 to
give the internal operating frequency.
CLK (Output)
Clock Output for use as a system clock when a crystal or R/ C network is used as an
input to the CPU. The period of CLK is twice the X1, X2 input period.
IO/M (Output)
IO/M indicates whether the Read/Write is to memory or l/O Tristated during Hold and
Halt modes.
SID (Input)
Serial input data line The data on this line is loaded into accumulator bit 7 whenever a
RIM instruction is executed.
SOD (output)
Serial output data line. The output SOD is set or reset as specified by the SIM
instruction.
Opcode
Operand
Description
This instruction copies the contents of the source
register into the destination register; the contents of
the source register are not altered.
Example: MOV B, C or MOV B, M
The 8-bit data is stored in the destination register or
memory.
Example: MVI B, 57H or MVI M, 57H
The contents of a memory location, specified by a
16-bit address in the operand, are copied to the accumulator.
Example: LDA 2034H
The contents of the designated register pair point to a memory
location. This instruction copies the contents of that memory
location into the accumulator.
Example: LDAX B
The instruction loads 16-bit data in the register pair
designated in the operand.
Example: LXI H, 2034H or LXI H, XYZ
ARITHMETIC INSTRUCTIONS
Opcode
Operand
Description
INR
R
M
BRANCHING INSTRUCTIONS
Opcode
Operand
Description
Jump conditionally
Operand: 16-bit address
The program sequence is transferred to the memory location
specified by the 16-bit address given in the operand based on the
specified flag of the PSW as described below.
Description
Jump on Carry
Jump on no Carry
Jump on positive
Jump on minus
Jump on zero
Jump on no zero
Jump on parity even
Jump on parity odd
Flag Status
CY = 1
CY = 0
S=0
S=1
Z=1
Z=0
P=1
P=0
LOGICAL INSTRUCTIONS
Opcode
Operand
Description
R
M
R
M
R
M
8-bit data
R
M
8-bit data
Example: RLC
Rotate accumulator right
RRC
Complement accumulator
CMA
MACHINE INSTRUCTION
Opcode
Operand
HLT
Description
It shows the ending of the programs
Example: HLT
PUSH
RP
POP
RP
NOP
No Operation
a) Addition
MVI B,10H
MVI C,05H
MOV A,C
ADD B
HLT
Output:
b) Subtraction
MVI B,25H
MVI C,10H
MOV A,B
SUB C
HLT
Output:
2. To develop an Assembly Code to perform the swapping of data of two memory locations.
LDA 2000H
MOV B, A
LDA 2002H
STA 2000H
MOV A, B
STA 2002H
HLT
Output:
Before Swapping
After Swapping
3. To develop an Assembly Code to perform Right rotation and left rotation of the Register
D.
Right Rotation
MVI C, 05H
MOV A, C
RAR
MOV C, A
HLT
Output:
Left Shift:
MVI C, 03H
MOV A, C
RAL
MOV C, A
HLT
Output:
4. To develop a program to load the two largest 4 digit hexadecimal numbers. Add the
numbers, and display the sum. Assume register of your choice.
LHLD 2010H
XCHG
LHLD 2012H
MOV A,E
ADD L
MOV L,A
MOV A,D
ADC H
MOV H,A
SHLD 2018H
(Transfers the data from 2010 memory location to register L and from
next memory location to register H)
(Exchange data from HL register pair to DE register pair)
(Move data from register E to accumulator)
(Add register L with accumulator)
(Then move the data back into register L)
(Register H is added to the accumulator with carry and stored back in
accumulator)
HLT
ORG 2010H
DB FFH, FFH, FFH, FEH
Output:
MVI B, 05H
MVI D, 04H
S: ADD B
DCR D
JNZ S
HLT
Output
6. Write an Assembly Code to count number of ls in the contents of D register and store
the count in the B register.
MVI C,8H
MVI B,0H
MVI D,7H
MOV A,D
SHIFT: RAR
JNC ZERO
INR B
ZERO: DCR C
JNZ SHIFT
HLT
Output:
MVI B, 03H
MOV D,B
S: ADD B
DCR D
JNZ S
HLT
Output:
8. To develop an 8085 assembly language program to find the smallest value between two
numbers .Store the value in memory location 2012H .
MVI B,20H
MVI C,16H
MOV A,B
CMP C
JNC PRINT
JNZ EQUAL
JC PRINTS
PRINT: MOV A,C
STA 2012H
HLT
PRINTS: MOV A,B
STA 2012H
HLT
EQUAL: MVI A,0H
STA 2012H
HLT
Output:
9. Write a program to find the sum of two BCD numbers stored in memory.
MVI B,63H
MVI A,88H
MVI C,00H
ADD B
DAA
JNC BACK
INR C
STA 2005H
BACK: STA 2006H
MOV A,C
STA 2007H
HLT
Output:
Minimum Number
MVI C,05H
DCR C
LXI HL,2018H
MOV A,M
BACK: INX HL
CMP M
JC AHEAD
MOV A,M
AHEAD: DCR C
JNZ BACK
INX HL
MOV M,A
HLT
ORG 2018H
DB 12H,10H,67H,80H,90H
(Decrement register C)
(Load data immediately to the address from register pair)
(Comparing Accumulator with data in Memory)
(Jump to AHEAD if carry)
(If not carry move data from memory to accumulator)
(If not zero, jump to back)
(If zero, Increment register pair HL)
(Move data from accumulator to memory)
(Entries in the array)
Output:
Largest Number:
MVI C,05H
DCR C
LXI HL,2018H
MOV A,M
BACK: INX HL
CMP M
JNC AHEAD
MOV A,M
AHEAD: DCR C
JNZ BACK
INX HL
MOV M,A
HLT
ORG 2018H
DB 22H,10H,57H,8H,19H
Output:
Output:
(Decrement register C)
(If C is not zero jump to BACK loop)
(Else, decrement B)
(If B not zero, jump to START loop)
(End of program)
Output:
MVI C,05H
DCR C
LXI HL,2018H
MOV A,M
BACK: INX HL
ADD M
DCR C
JNZ BACK
HLT
ORG 2018H
DB 01H,02H,03H,04H,05H
Output: