0% found this document useful (0 votes)
19 views

Microprocessor solution

Microprocessor solution

Uploaded by

ramjinish2057
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Microprocessor solution

Microprocessor solution

Uploaded by

ramjinish2057
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

1.

Difference between microprocessor and microcontroller


Microprocessor Microcontroller
1. . It is the Heart of computer system 1. It is the Heart of embedded system
2. It is just processor, Memory and I/O 2. It has a external processor, along with
components have to be connected externally. Memory and I/O components.
3. Since memory and I/O has to be connected 3. Since memory and I/O are present
externally the circuit become large. internally, the small is circuit .
4. Cannot be used in compact systems and 4. Can be used in compact systems and hence
hence inefficient it is inefficient technique.
5. It have less number of registers, hence more 5. It have more number of registers, hence the
operation are memory based. programs are easier to write.
6. Mainly used in person computer. 6. Used Mainly used in washing machine. MP3

2. Draw the basic block diagram of microcomputer system showing


control buses.

Memory

Input ALU Output

Control
Unit

Figure 1.4: General Architecture of microcontroller system

Explanation of Each Block


Arithmetic Logic Unit (ALU):-
The ALU performs arithmetic operations such as addition, subtraction, multiplication and division and
logical operations such as AND, OR, NOT.
Control Unit:- The control unit is responsible for fetching instruction from main memory and
determining their types.

Memory:- The memory unit is used to store instructions and data. The memory unit is divided into
primary and secondary memory.

Primary : RAM, ROM

Secondary : Hard disk, CD-ROM

Input and Output:-


The input unit is used to input the information to be processed from external input devices such as a
mouse, keyboard.

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.

3. Draw the architecture of SAP-1 computer and explain in detail.


SAP-1
SAP can only perform addition and subtraction and no logical operation. These arithmetic operations are
performed by an adder/subtractor unit. SAP-1 includes the following functional units:

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.

4. Instruction Register :- IR contains the instruction (composed of OPCODE+ADDRESS) to be executed by


SAP1 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

7. Adder/Subtractor :- It is a 2's complement adder-subtractor. • This module is asynchronous


(unclocked), which means that its contents can change as soon as the input words change.

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.

 Arithmetic Logic Unit :


The ALU performs the actual numerical and logic operation such as ‘add’,
‘subtract’, ‘AND’, ‘OR’, etc. Uses data from memory and from Accumulator to
perform arithmetic. Always stores result of operation in Accumulator.

 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.

They are described briefly as follows :

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.

 Program Counter (PC) :


This 16-bit register deals with sequencing the execution of instructions. This register is a
memory pointer. Memory locations have 16-bit addresses, and that is why this is a 16-
bit register.

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.

 Stack Pointer (SP) :


The stack pointer is also a 16-bit register used as a memory pointer. It points to a
memory location in R/W memory, called the stack. The beginning of the stack is defined
by loading 16-bit address in the stack pointer. The stack concept is explained in the
chapter “Stack and Subroutines.”
 Instruction Register/Decoder :
Temporary store for the current instruction of a program. Latest instruction sent here
from memory prior to execution. Decoder then takes instruction and ‘decodes’ or
interprets the instruction. Decoded instruction then passed to next stage.

 Memory Address Register :


Holds address, received from PC, of next program instruction. Feeds the address bus
with addresses of location of the program under execution.

 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.

 General Purpose Registers :


uP requires extra registers for versatility. Can be used to store additional data during a
program. More complex processors may have a variety of differently named registers.

 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.

5. Explain instruction and data formats.

·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

(a) One byte (single) instructions.

(b)Two byte instructions.


(c) Three byte instructions.

One–byte instructions: An instruction with only opcode and do not require any dat or
address is called a one byte instruction.

Ex: 1. MOV C, A Hex code = 4FH (one byte)

2. ADD B Hex code = 80H (one byte)

3. CMA Hex code = 2FH (one byte)

Two–byte instructions: A two byte instruction is one which contains an 8-bit op-code
and 8-bit operand (Data).

Ex: 1. MVI A, 09 Hex code = 3E, 09 (two bytes)

2. ADD B, 07 Hex code = 80, 07 (two bytes)

3. SUB A, 05 Hex code = 97, 05 (two bytes)

Three–byte instructions: A three byte instruction contains an opcode plus a 16 – bit


address.

Ex: 1.LXI H, 8509 Hex code = 21, 09, 85 (Three bytes)

2 .LDA 8509 Hex code = 3A, 09, 85 (Three bytes)

3. JMP 9567 Hex code = C3, 67, 95 (Three bytes)

4. STA 3525 Hex code = 32, 35, 25 (Three bytes)

6. Define addressing modes of 8085 microprocessor and explain each


addressing mode with example.

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.

Types of addressing modes –


In 8085 microprocessor there are 5 types of addressing modes:

1. Immediate Addressing Mode –


In immediate addressing mode the source operand is always data. If the data is 8-
bit, then the instruction will be of 2 bytes, if the data is of 16-bit then the
instruction will be of 3 bytes.
Examples:
MVI B 45 (move the data 45H immediately to register B)
LXI H 3050 (load the H-L pair with the operand 3050H immediately)
JMP address (jump to the operand address immediately)

2. Register Addressing Mode –


In register addressing mode, the data to be operated is available inside the
register(s) and register(s) is(are) operands. Therefore the operation is performed
within various registers of the microprocessor.
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)

3. Direct Addressing Mode –


In direct addressing mode, the data to be operated is available inside a memory
location and that memory location is directly specified as an operand. The
operand is directly available in the instruction itself.
Examples:
LDA 2050 (load the contents of memory location into accumulator A)
LHLD address (load contents of 16-bit memory location into H-L register pair)
IN 35 (read the data from port whose address is 35)

4. Register Indirect Addressing Mode –


In register indirect addressing mode, the data to be operated is available inside a
memory location and that memory location is indirectly specified by a register
pair.
Examples:
MOV A, M (move the contents of the memory location pointed by the H-L pair to
the accumulator)
LDAX B (move contents of B-C register to the accumulator)
LXIH 9570 (load immediate the H-L pair with the address of the location 9570)

5. Implied/Implicit Addressing Mode –


In implied/implicit addressing mode the operand is hidden and the data to be
operated is available in the instruction itself.
Examples:
CMA (finds and stores the 1’s complement of the contents of accumulator A in A)
RRC (rotate accumulator A right by one bit)
RLC (rotate accumulator A left by one bit)
7.What is subroutine? Explain stack operation.

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:-

Syntax: PUSH Rp/PSW

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:-

Syntax: POP Rp/PSW

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

8. Define flag. Explain flag register in 8085 microprocessor.

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.

You might also like