Microprocessor
Microprocessor
Flow chart
The thinking process described here and the steps necessary to write the program can be
represented in a pictorial format, called a flowchart.
Generally, a flowchart is used for two purposes: to assist and clarify the thinking process
and to communicate the programmer's thoughts or logic to others
Symbols commonly used in flowcharting are shown in Figure
IN: Input from Port -Read a data byte from an input device.
The term copy is equally valid for input/output functions because the contents of the
source are not altered.
However, the term data transfer is used so commonly to indicate the data copy function
that, these terms are used interchangeably when the meaning is not ambiguous.
In addition to data copy instructions, it is necessary to introduce two machinecontrol
operations to execute programs.
-------------
DATA MANIPULATIONOPERATIONS:
1. ARITHMETIC OPERATIONS
Addition
The 8085 performs addition with 8-bit binary numbers and stores the sum in the
accumulator.
If the sum is larger than eight bits (FFH), it sets the Carry flag.
Addition can be performed either by adding the contents of a source register (B, C, D, E,
H, L, or memory) to the contents of the accumulator (ADD) or by adding the second byte
directly to the contents of the accumulator (ADI).
Subtraction
2. LOGIC OPERATIONS
A microprocessor is basically a programmable logic chip.
It can perform all the logic functions of the hard-wired logic through its instruction set.
The 8085 instruction set includes such logic functions as AND, OR, Ex OR, and NOT
(complement). The opcodes of these operations are as follows:*
All logic operations are performed in relation to the contents of the accumulator.
The instruction ORA (and ORI) simulates logic ORing with eight 2-input OR gates; this process
is similar to that of AND ing. The instruction XRA (and XRI)performsExc1usive-ORingof eight
bits and the instruction CMA invert the bits of the accumulator.
BRANCH OPERATIONS
The branch instructions are the most powerful instructions because they allow the
microprocessor to change the sequence of a program, either unconditionally or under
certain test conditions.
These instructions are the key to the flexibility and versatility of a computer.
The microprocessor is a sequential machine; it executes machine codes from one memory
location to the next.
Branch instructions instruct the microprocessor to go to a different memory location, and
the microprocessor continues executing machine codes from that new location.
The address of the new memory location is either specified explicitly or supplied by the
microprocessor or by extra hardware.
The branch instructions are classified in three categories:
1. Jump instructions
2. Call and Return instructions
3. Restart instructions
They are 3-byte instructions: one byte for the operation code, followed by a 16-bit
memory address.
Jump instructions are classified into two categories: Unconditional Jump and
Conditional Jump.
Unconditional Jump
The 8085 instruction set includes one unconditional Jump instruction. The unconditional Jump
instruction enables the programmer to set up continuous loops.
Example:
JMP 8500
Description
This is a 3-byte instruction
The second and third bytes specify the 16 bit memory address. However, the second byte
specifies the low-order and the third byte specifies the high-order memory address
1. 8 bit – Addition
3. 8 bit – Multiplication
5. Ascending order
(Write an program to sort on array of data in the Ascending order. The array is stored in
the memory starting from 4200H the first element of the array gives the count value for
the number of elements in the array)
6. Descending order
(Write an program to sort on array of data in the Descending order. The array is stored in
the memory starting from 4200H the first element of the array gives the count value for
the number of elements in the array)
LABLE MNEMONICS COMMENT
LDA 4200H Load the count value in A-register.
MOV B, A Set count for N-1 repetition
DCR B of N-1comparison
LOOP 2 LXI H,4200H Set pointer for array
MOV C, M Setv count for N-1 comparisons
DCR C
INX H Increment the pointer
LOOP 1 MOV A, M get one data of array in A-register.
INX H
CMP M Compare the next data of array with the content of A-
register.
JNC AHEAD If content of A is greater than content of memory
addressed by HL pair, then go to AHEAD
MOV D, M If the content of A is less than content of memory
addressed by HL pair, then exchange content of
memory pointed by HL and previous memory location
MOV M,A
DCX H
MOV M , D
INX H
AHEAD DCR C
JNZ LOOP 1 Repeat comparison until C- count is zero
DCR B
JNZ LOOP 2 Repeat N-1 comparison until B- count is zero
HLT halt program execution
(Write an assembly language program to search the smallest data in an array of N data stored
in memory from 4200H to (4200H+N). The first element of the array gives the number of
data in the array)
(Write an assembly language program to find the Square root of an 8-bit binary number.The
binary number is stored in memory location 4200H and store the square root in 4201H.)
;division subroutine
DIV MVI D, 00H Clear the D- register for quotient
NEXT SUB C Subtract the divisor from dividend
INR D Increment the quotient
CMP C Repeat subtraction until the divisor is less than
JNC NEXT dividend.
RET Return to main program
(Find the square of the given numbers from memory location 6100H and store the result from
memory location 7000H)