Microprocessor solution
Microprocessor solution
Memory
Control
Unit
Memory:- The memory unit is used to store instructions and data. The memory unit is divided into
primary and secondary memory.
Output unit is used to output the processed results of computer to the external output device such as a
printer, monitor, 7-segment display and LEDs.
Control buses:- The control buses are used to transmit the control signal such as read, write and
interrupt signals.
1. Program Counter • It counts from 0000 to 1111. • It stores the memory address of next instruction to
be fetched and executed.
2. Input and MAR • During a computer run, the address in PC is latched into Memory Address Register
(MAR).
3. RAM :- The program code to be executed and data for SAP1 computer is stored here. • During a
computer run, the RAM receives 4-bit addresses from MAR and a read operation is performed. Hence,
the instruction or data word stored in RAM is placed on the W bus for use by some other part of the
computer.
5. Controller Sequencer :- It generates the control signals for each block so that actions occur in desired
sequence. CLK signal is used to synchronize the overall operation of the SAP1 computer. • A 12-bit word
comes out of the Controller bit word comes out of the Controller-Sequencer block. This Sequencer
block. This control word determines how the registers will react to the next positive CLK edge.
6. Accumulator :- it is a 8-bit buffer register that stores intermediate results during a computer run. • It
is always one of the operands of ADD, SUB and OUT instructions
8. B-Register :- It is 8-bit buffer register which is primarily used to hold the other operand (one operand
is always accumulator) of mathematical operations.
9. Output Register :- This registers hold the output of OUT instruction. 10. Binary Display • It is a row of
eight LEDs to show the contents of output register. • Binary display unit is the output device for the SAP-
1 microprocessor.
4. Draw the architecture of 8085 microprocessor and explain only Arithmetic
and logic unit.
Registers :
The 8085/8080A-programming model includes six registers, one accumulator, and one
flag register, as shown in Figure. In addition, it has two 16-bit registers: the stack pointer
and the program counter.
The 8085/8080A has six general-purpose registers to store 8-bit data; these are
identified as B,C,D,E,H, and L as shown in the figure. They can be combined as register
pairs – BC, DE, and HL – to perform some 16-bit operations. 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 id larger than eight bits, the flip-flop uses to indicate a carry —
called the Carry flag (CY) — is set to one. When an arithmetic operation results in zero,
the flip-flop called the Zero(Z) flag is set to one. The first Figure shows 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.
The microprocessor uses this register to sequence the execution of the instructions.
The function of the program counter is to point to the memory address from which the
next byte is to be fetched. When a byte (machine code) is being fetched, the program
counter is incremented by one to point to the next memory location.
Control Generator :
Generates signals within uP to carry out the instruction which has been decoded. In
reality causes certain connections between blocks of the uP to be opened or closed, so
that data goes where it is required, and so that ALU operations occur.
Register Selector :
This block controls the use of the register stack in the example. Just a logic circuit which
switches between different registers in the set will receive instructions from Control Unit.
Microprogramming :
How does the µP knows what an instruction means, especially when it is only a binary
number? The microprogram in a uP/uC is written by the chip designer and tells the
uP/uC the meaning of each instruction uP/uC can then carry out operation.
·The format of a typical instruction is composed of two parts: an operation code or op-
code and an operand.
Every instruction needs an op-code to specify what the operation of the instruction is
and then an operand that gives the appropriate data needed for that particular operation
code.
·According to the word or byte size the 8085 instructions are classified into three types.
They are
One–byte instructions: An instruction with only opcode and do not require any dat or
address is called a one byte instruction.
Two–byte instructions: A two byte instruction is one which contains an 8-bit op-code
and 8-bit operand (Data).
Addressing modes are used to specify the data to be operated with the help of instructions. Addressing
Modes of 8085 are divided into five groups. The instructions are used to transfer the data from one
register to another register, from the memory to the register, and from the register to the memory
without any change in the content. Instructions are nothing but binary patterns which are designed to
perform some specific functions. The microprocessor supports an entire group of instructions called an
instruction set.
A Subroutine is Used to modularize the main program .it is a set of function that are written
separately from the main program to perform tasks that repeatedly occurring tasks .8085 has two
instructions call and ret for calling the subroutine and returning from the subroutine
Stack Operations
1. The stack in an 8085 microcomputer system can be described as a set of memory
location in the R/W memory, specified by a programmer in a main program.
2. These memory locations are used to store binary information temporarily during the
execution of a program.
3. The beginning of the stack is defined in the program by using the instruction LXI SP,
which loads a 16-bit memory address in the stack pointer register of the
microprocessor.
4. Storing of data bytes begins at the memory address that is one less than the address in
the stack pointer register
5. Therefore, the stack is initialized at the highest available memory location to prevent
the program from being destroyed by the stack information.
6. The data bytes in the register pairs of the microprocessor can be stored in the stack
(two at a time) in reverse order by using the instruction PUSH.
7. Data bytes can be transferred from the stack to respective registers by using the
instruction POP.
8. Two data bytes are being stored at a time, the 16- bit memory address in the stack
pointer register is decremented by two, when data bytes are retrieved, the address is
incremented by two
PUSH:-
e.g. PUSH B
Copies the contents of specified register pair or program status word (accumulator and flag) on the
stack. Stack pointer is decremented and content of high order register is copied. Then it is again
decremented and content of lower order register is copied.
POP:-
e.g. POP D
Copies the contents of the top two memory locations of the stack into specified register pair or
program status word. A content of memory location indicated by SP is copied into lower order register
and SP is incremented by 1. Then the content of next memory location is copied into high order register
and SP is incremented by 1
Flag:- The Flag register is a Special Purpose Register. Depending upon the value of
result after any arithmetic and logical operation the flag bits become set (1) or reset
(0). In 8085 microprocessor, flag register consists of 8 bits and only 5 of them are
useful
1. Sign Flag (S) – After any operation if the MSB (B(7)) of the result is 1, it indicates
the number is negative and the sign flag becomes set, i.e. 1. If the MSB is 0, it
indicates the number is positive and the sign flag becomes reset i.e. 0.
from 00H to 7F, sign flag is 0
from 80H to FF, sign flag is 1
1- MSB is 1 (negative)
0- MSB is 0 (positive)
Example:
MVI A 30 (load 30H in register A)
MVI B 40 (load 40H in register B)
SUB B (A = A – B)
These set of instructions will set the sign flag to 1 as 30 – 40 is a negative
number.
MVI A 40 (load 40H in register A)
MVI B 30 (load 30H in register B)
SUB B (A = A – B)
These set of instructions will reset the sign flag to 0 as 40 – 30 is a positive
number.
2. Zero Flag (Z) – After any arithmetical or logical operation if the result is 0 (00)H,
the zero flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.
00H zero flag is 1.
from 01H to FFH zero flag is 0
1- zero result
0- non-zero result
Example:
MVI A 10 (load 10H in register A)
SUB A (A = A – A)
These set of instructions will set the zero flag to 1 as 10H – 10H is 00H
3. Auxiliary Carry Flag (AC) – This flag is used in BCD number system(0-9). If after
any arithmetic or logical operation D(3) generates any carry and passes on to B(4)
this flag becomes set i.e. 1, otherwise it becomes reset i.e. 0. This is the only flag
register which is not accessible by the programmer
1-carry out from bit 3 on addition or borrow into bit 3 on subtraction
0-otherwise
Example:
MOV A 2B (load 2BH in register A)
MOV B 39 (load 39H in register B)
ADD B (A = A + B)
These set of instructions will set the auxiliary carry flag to 1, as on adding 2B and
39, addition of lower order nibbles B and 9 will generate a carry.
4. Parity Flag (P) – If after any arithmetic or logical operation the result has even
parity, an even number of 1 bits, the parity register becomes set i.e. 1, otherwise it
becomes reset i.e. 0.
1-accumulator has even number of 1 bits
0-accumulator has odd parity
Example:
MVI A 05 (load 05H in register A)
This instruction will set the parity flag to 1 as the BCD code of 05H is 00000101,
which contains even number of ones i.e. 2.
5. Carry Flag (CY) – Carry is generated when performing n bit operations and the
result is more than n bits, then this flag becomes set i.e. 1, otherwise it becomes
reset i.e. 0.
During subtraction (A-B), if A>B it becomes reset and if (A<B) it becomes set.
Carry flag is also called borrow flag.
1-carry out from MSB bit on addition or borrow into MSB bit on subtraction
0-no carry out or borrow into MSB bit
Example:
MVI A 30 (load 30H in register A)
MVI B 40 (load 40H in register B)
SUB B (A = A – B)
These set of instructions will set the carry flag to 1 as 30 – 40 generates a
carry/borrow.
MVI A 40 (load 40H in register A)
MVI B 30 (load 30H in register B)
SUB B (A = A – B)
These set of instructions will reset the sign flag to 0 as 40 – 30 does not generate
any carry/borrow.