UNIT-II MPMC
UNIT-II MPMC
UNIT-II MPMC
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.
OR, Exclusive-OR, and NOT
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
Conditional Jumps
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
7. Search for Smallest data in an array
(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
10. Find the square of given number
(Find the square of the given numbers from memory location 6100H and store the result from
memory location 7000H)
The processor executes initialization section and result section only once, while it
may execute processing section and loop control section many times. Thus, the execution
time of the loop will be mainly dependent on the execution time of the processing section
and loop control section. The flowchart 1 shows typical program loop. The processing
section in this flowchart is always executed at least once. If you position of the processing
and loop control section then it is possible that the processing section may not be executed
at all, if necessary.
LOGIC OPERATIONS : ROTATE AND COMPARE
ROTATE
Rotate accumulator left
RLC none Each binary bit of the accumulator is rotated left by one position.
Bit D7 is placed in the position of D0 as well as in the Carry flag. CY is
modified according to bit D7. S, Z, P, AC are not affected.
Example: RLC
RRC none Each binary bit of the accumulator is rotated right by one position. Bit D0 is
placed in the position of D7 as well as in the Carry flag. CY is modified according to bit
D0. S, Z, P, AC are not affected.
Example: RRC
RAL none Each binary bit of the accumulator is rotated left by one position through the
Carry flag. Bit D7 is placed in the Carry flag, and the Carry flag is placed in the least
significant position D0. CY is modified according to bit D7. S, Z, P, AC are not affected.
Example: RAL
LOGIC OPERATIONS :ROTATE (CONT.)
Rotate accumulator right through carry
RAR none Each binary bit of the accumulator is rotated right by one position
through the Carry flag. Bit D0 is placed in the Carry flag, and the Carry flag is
placed in the most significant position D7. CY is modified according to bit D0. S,
Z, P, AC are not affected.
Example: RAR
LOGICALOPERATIONS
⚫ Compare
⚫ Compare the contents of a register or memory location with the contents of the
accumulator.
⚫ CMP R/M :Compare the contents of the register or memory location to the contents
of the accumulator.
⚫ CPI # : Compare the 8-bit number to the contents of the
accumulator.
The compare instruction sets the flags (Z, Cy, and S).
The compare is done using an internal subtraction that does not change the contents of the
accumulator.
A –(R / M / #)
BRANCHOPERATIONS
Two types:
Unconditional branch: Go to a new location no matter what.
Conditional branch : Go to a new location if the condition is true.
UnconditionalBranch
JMP Address : Jump to the address specified (Go to).
CALL Address: Jump to the address specified but treat it as a
subroutine.
RET : Return from a subroutine.
The addresses supplied to all branch operations must be 16-bits.
CONDITIONAL BRANCH
◾ Go to new location if a specified condition is met.
◾ JZ Address(Jump on Zero)Go to address specified if the Zero
flag is set.
◾ JNZ Address(Jump on NOT Zero)Go to address specified if the Zero flag is not set.
◾ JC Address(Jump on Carry)Go to the address specified if the
Carry flag is set.
◾ JNC Address(Jump on No Carry)Go to the address specified if the Carry flag is not set.
◾ JP Address(Jump on Plus)Go to the address specified if the
Sign flag is not set
◾ JM Address(Jump on Minus)Go to the address specified if the Sign flag is set.
DATAFORMATS
DATAFORMATS
⚫ Assume the accumulator contains the following value: 0100
0001.There are four ways of reading this value: It is an unsigned
integer expressed in binary, the equivalent decimal number would be
65.
⚫ It is a number expressed in BCD (Binary Coded Decimal) format.
That would make it, 41.
⚫ It is an ASCII representation of a letter. That would make it the
letter A.
⚫ It is a string of 0’s and 1’s where the 0th and the 6th bits are set to 1
while all other bits are set to 0.