Cl11 Notes Mod4
Cl11 Notes Mod4
MODULE IV
THE 8085 MICRPROCESSOR
Architecture of 8085
o ALU
The Arithmetic and Logic Unit, ALU performs the arithmetic and logical
operations: Addition, Subtraction, Logical AND, Logical OR, Logical
MODULE – 4- CA PROF. ANJALI SOMAN
PKM Educational Trust
It is used to generate timing and control signals which are necessary for the
execution of instructions. It is used to control data flow between CPU and peripherals
(including memory). It is used to provide status, control and timing signals which are
required for the operation of memory and I/O devices. It is used to control the entire
operations of the microprocessor and peripherals connected to it. Thus, we can see
that the control unit of the CPU acts as the brain of the computer system.
o Registers
Registers are used for temporary storage and manipulation of data and
instructions by the microprocessor. Data remain in the registers till they are sent to the
I/O devices or memory. Intel 8085 microprocessor has the following registers:
A flag is a flip-flop which indicates some conditions which arises after the
execution of an arithmetic or logical instruction.
1. Accumulator (ACC): The accumulator is an 8-bit register associated with the
ALU. The register 'A' is an accumulator in the 8085. It is used to hold one of
the operands of an arithmetic and logical operation.
The final result of an arithmetic or logical operation is also placed in the
accumulator.
2. General-Purpose Registers: The 8085 microprocessor contains six 8-bit
general purpose registers. They are: B, D, C, E, H and L register.
To hold data of 16-bit a combination of two 8-bit registers can be employed.
The combination of two 8-bit registers is called register pair. The valid register
pairs in the 8085 are: D-E, B-C and H-L. The H-L pair is used to act as a
memory pointer.
3. Program Counter (PC): It is a 16-bit special purpose register. It is used to hold
the address of memory of the next instruction to be executed. It keeps the track
of the instruction in a program while they are being executed.
MODULE – 4- CA PROF. ANJALI SOMAN
PKM Educational Trust
The microprocessor increments the content of the next program counter during
the execution of an instruction so that at the end of the execution of an
instruction it points to the next instruction’s address in the program.
4. Stack Pointer (SP): It is a 16-bit special function register used as memory
pointer. A stack is nothing but a portion of RAM. In the stack, the contents of
only those registers are saved, which are needed in the later part of the
program.
The stack pointer (SP) controls the addressing of the stack. The Stack Pointer
contains the address of the top element of data stored in the stack.
5. Instruction Register: The instruction register holds the opcode (operation code
or instruction code) of the instruction which is being decoded and executed.
6. Temporary Register: It is an 8-bit register associated with the ALU. It holds
data during an arithmetic/logical operation. It is used by the microprocessor. It
is not accessible to programmer.
7. Flags: The Intel 8085 microprocessor contains five flip-flops to serve as a
status flags. The flip-flops are reset or set according to the conditions which
arise during an arithmetic or logical operation.
The Intel 8085 is an 8-bit microprocessor. Its data bus is 8-bit wide and therefore, 8
bits of data can be transmitted in parallel from or to the microprocessor. The Intel 8085
requires an address bus of 16-bit wide as the memory addresses are of 16-bits. The 8
most significant bits of the address are transmitted by the address bus, A-bus (pins
A8 to A15). The 8 least significant bits of the address are transmitted by data/address
bus, AD-bus (pins AD0 to AD7).
Pin Configuration
o A8 to A15 (Output): These are address bus and are used for the most significant bits
of the memory address or 8-bits of I/O address.
o AD0 to AD7 (Input/output): These are time multiplexed address/data bus i.e. they
serve dual purpose. They are used for the least significant 8 bits of the memory
address or I/O address during the first cycle. Again, they are used for data during 2nd
and 3rd clock cycles.
o ALE (Output): ALE stands for Address Latch Enable signal. ALE goes high during
first clock cycle of a machine cycle and enables the lower 8-bits of the address to be
latched either into the memory or external latch.
o IO/M (Output): It is a status signal which distinguishes whether the address is for
memory or I/O device.
o S0, S1 (Output): These are status signals sent by the microprocessors to distinguish
the various types of operation given in table below:
S1 S0 Operations
0 0 HALT
0 1 WRITE
1 0 READ
1 1 FETCH
o HOLD (INPUT): HOLD indicates that another device is requesting for the use of the
address and data bus.
o HLDA (OUTPUT): HLDA is a signal for HOLD acknowledgement which indicates
that the HOLD request has been received. After the removal of this request the HLDA
goes low.
o INTR (Input): INTR is an Interrupt Request Signal. Among interrupts it has the
lowest priority. The INTR is enabled or disabled by software.
o INTA (Output): INTA is an interrupt acknowledgement sent by the microprocessor
after INTR is received.
o RST 5.5, 6.5, 7.5 and TRAP (Inputs): These all are interrupts.
o When any interrupt is recognized, the next instruction is executed from a fixed
location in the memory as given below:
TRAP 0024
RST 7.5, RST 6.5 and RST 5.5 are the restart interrupts which cause an internal restart to
be automatically inserted.
The TRAP has the highest priority among interrupts. The order of priority of interrupts is
as follows:
o TRAP (Highest priority)
o RST 7.5
o RST 6.5
o RST 5.5
o INTR (Interrupt Request - Lowest priority).
o INTA (Interrupt Acknowledgement)
Reset Signals
o RESET IN (Input): It resets the program counter (PC) to 0. It also resets interrupt
enable and HLDA flip-flops. The CPU is held in reset condition till RESET is not
applied.
o RESET OUT (Output): RESET OUT indicates that the CPU is being reset.
Clock Signals
Power Supply
o Vcc: +5 Volts supply
o Vss: ground reference
o Vpp: for connecting EPROM
Accumulator:
Accumulator is an 8-bit register. For processing the numbers, 8085 assumes that one of the
numbers is in
accumulator. After processing, the result is accumulated in accumulator. The usage of the
accumulator is given below in assembly language format:
MOVA, M
MOV B, C
; this instruction moves the content of a memory location into accumulator It moves the
content of register C into register B.
ADD B; it adds the content of Accumulator(A) and B and saves the result in
Accumulator(A). AB A+B
STA 2020H
; This instruction saves the content of accumulator at memory location given in HL pair.
All these registers are 8-bits each. These registers can also be used in pair as BC, DE and
HL for use as 16-bit data operations. The above registers when used in pair act as follows:
BC: 8-bit B and 8-bit C registers can be used as one 16-bit BC register pair. When used as
a pair register C contains the low-byte. Some instructions use register pair BC as a data
pointer.
DE: 8-bit D and 8-bit E registers can be used as one 16-bit DE register pair. When used as
a pair register E contains the low-byte. Some instructions use register pair DE as a data
pointer.
HL: 8-bit H and 8-bit L registers can be used as one 16-bit HL register pair. When used as
a pair register L contains the low-byte. Some instructions use register pair HL as a memory
pointer.
Flag Register:
ALU of 8085 contains a special register called a "Flag register" and is an 8-bit register. At
the time of design of 8085 only five flags of this register were used and the rest three were
reserved. These flags 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; 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.
o Parity Flag - Parity flag is used to indicate whether the parity of the number
has changed or not. The parity flag ('P') is set to one if the number of '1's in the
result is odd. The flag is reset to 'O' if the number '1' in the result is even. In
figure (a) the result of 'A+B' = 1010111. Here number of 1's is five i.e. odd
number of bits are high ('1'), so the parity flag gets set to "1.
o Auxiliary Carry Flag - This flag is set or reset depending on whether there is a
carry out as result of addition of the lower nibble data of an eight-bit number.
o Zero Flag - The zero flag is an indication of whether the result of addition or
subtraction is zero or non-zero. If the addition or subtraction of two numbers
result in zero, the zero (Z) flag is set to "1', in case of a non-zero result the flag
will be reset to zero.
o Sign Flag - The MSB of the number indicates its sign, and is of interest when
dealing with signed numbers. For processing the unsigned numbers, we simply
ignore the sign bit. The sign (S) flag will be set to '1' if the result of addition or
subtraction results in a negative answer. For the positive result the sign flag
will be reset to '0'.
In the above figure, +ve numbers is represented by taking the sign bit as '0'
and negative number is represented by taking the sign-bit as '1. Negative
number (-7) is represented as 11111000 in 1's complement representation. So,
the addition of +6 ("00000110") and -7(11111000") results in "11111110". In
the example above the MSB of the result is "1", it indicates that the result is
negative, and this sets the sign (S) flag to 1. For the positive result i.e. when
the MSB of the result is '0', the sign (S) flag is reset to '0'.
Instruction Classification
A binary command that is used to perform a function in the microprocessor over
provided data is known as instruction. A set of instructions is known as an instruction
set that decides the microprocessor function. Every instruction includes two parts like
Opcode & the Operand where Opcode is used to specify the function to be executed &
operand gives the data to be functioned on.
o Data Transfer Instruction - An instruction that is used to transfer the data from one
register to another is known as data transfer instruction. So, the data transfer can be
done from source to destination without changing the source contents. Data transfer
mainly occurs from one register to another register, from memory location to register,
register to memory, and between an I/O device & accumulator.
Mov r, M - This data transfer instruction is used to transfer data present within the
memory (M) to the register (r). But the memory location address must be there within
the HL register. Example: MOV R, 1020H
Mov M, Data - This type of instruction specifies the data transfer immediately to a
location of memory. This memory location address can be specified at the H-L
registers. Example: MOV M, 28H
MVI r, Data (Move Immediate) - In this type of instruction, the transmission of data
can be done immediately toward the particular register. E.g.: MVI R, 32H
ADD r - This arithmetic instruction adds the data which is available in the register
to the data available within the accumulator & the final result will be stored in the
accumulator. Example: ADD C
ADD M - This type of instruction is mainly used to add the date in the memory
address data denoted at the operand to the data available at the accumulator. So, the
addition result will be stored within the accumulator. Example: ADD 28H
ADI Data (Add Immediate) - In this instruction, the 8-bit data is specified as an
operand is added immediately to the data available at the accumulator & the result
is stored at the accumulator. Example: ADI 24 H
ANA R/M (Logical AND register or memory with the accumulator) - This
instruction executes the AND operation of the data available within the
MODULE – 4- CA PROF. ANJALI SOMAN
PKM Educational Trust
accumulator to the data available in the memory or register. After the operation of
AND, S, P, Z will be changed to show the outcome of the comparison. Example:
ANA C
CALL address - This instruction shifts the control of a series of current programs
toward the memory address available at the operand. However, the PC gets
decreased before transferring. Example: CALL 2400H
RET (Return from the Subroutine) - This type of instruction can cause the
unconditional return of the sub-routine to the actual program.
NOP (No operation) - NOP stands for no operation. Once the 8085
microprocessor gets this instruction, then it does not perform any operation based
on execution.
HLT (Halt & Enter Wait State) - Once the HLT interrupt is decoded through the
microprocessor, it stops the current operation and waits for further instruction. To
escape from the halt condition either a reset or an interrupt is necessary.
Each personal computer has a microprocessor that manages the computer's arithmetical,
logical, and control activities. Each family of processors has its own set of instructions for
handling various operations such as getting input from keyboard, displaying information
on screen and performing various other jobs. These set of instructions are called 'machine
language instructions'.
A processor understands only machine language instructions, which are strings of 1's and
0's. However, machine language is too obscure and complex for using in software
development. So, the low-level assembly language is designed for a specific family of
processors that represents various instructions in symbolic code and a more
understandable form.
Use a text editor (e.g., Notepad, Vim, or an IDE like Visual Studio Code) to write
your assembly language program.
Save the file with the appropriate extension for the assembler you are using
(e.g., .asm).
Use an assembler to convert the assembly code into machine code (object code).
Popular assemblers include:
o NASM (Netwide Assembler) for x86 or x86-64 assembly.
o MASM (Microsoft Macro Assembler) for Windows development.
o GAS (GNU Assembler) for Unix/Linux systems.
Steps:
Link the object file to produce an executable. A linker combines object files and
resolves external references.
Command:
5. Debugging (Optional)
If your program doesn’t work as expected, use a debugger to step through the
instructions and identify issues.
o Linux: Use gdb (GNU Debugger).
o Windows: Use Debug or Visual Studio's debugging tools.
1. Open GNUSim8085.
2. In the editor, write the 8085 assembly program. For example:
Assembly
Examples:
MOV A, B (move the contents of register B to register A)
ADD B (add contents of registers A and B and store the result in register A)
INR A (increment the contents of register A by one)
ADD A,R0
JMP AGAIN
In this example, the instruction JMP AGAIN uses the Relative Addressing Mode. The
instruction jumps to the label AGAIN by adding the contents of the program counter with
the specified constant value. The constant value is calculated based on the distance
between the current instruction and the label AGAIN.
In this case, the instruction JMP AGAIN is executing a loop that loads the accumulator
with the value 55H, adds the contents of the register R0 to the accumulator, and then
jumps back to the label AGAIN to repeat the loop.