Microprocessor

Download as pdf or txt
Download as pdf or txt
You are on page 1of 56

Microprocessor

Basic Concepts of Microprocessors


1. Microprocessor
It is a multipurpose, programmable VLSI chip which includes ALU,
register circuits and control circuits.
Microprocessor is System on Board (SOB). Its can’t work alone. It
should interface with external input / output devices and memories
8085 is pronounced as "eighty-eighty-five" microprocessor.
It is an 8-bit microprocessor designed by Intel in 1977 using NMOS
technology.
It has the following configuration −
• 8-bit data bus
• 16-bit address bus, which can address upto 64KB
• A 16-bit program counter
• A 16-bit stack pointer
• Six 8-bit registers arranged in pairs: BC, DE, HL
• Requires +5V supply to operate at 3.2 MHZ single phase clock
It is used in washing machines, microwave ovens, mobile phones, etc.
2. Microcontroller
Silicon chip which includes microprocessor, memory and I/O in a
single package
Basic Applications
• Medical devices –Blood sugar and pressure monitoring.
• Measuring instruments –Oscilloscope, multimeters and analyzers.
• Music related applications.
• Defense applications –Radar, Satellites.
• Computers.
• House hold devices –Washing machine, Oven, Toys.
Evolution of microprocessors

Processor Introduced Data bus Memory address Clock Signal


in capability
4004 1971 4 bit 1 kB 108 kHz
8008 1972 8 bit, 40 pin 16 kB 200 kHz
8080 1974 8 bit 64 kB 2 MHz
8085 1976 8 bit, 40 pin 64 kB 5-8 MHz
8086 1978 16 bit, 40 pin 1 MB 5-10 MHz
80286 1982 16 bit, 68 pin 16 MB 6-12.5 MHz
80386 1985 32 bit, 132 pin 4 GB 22-33 MHz
80486 1989 32 bit, 168 pin 4 GB 26-100 MHz
Pentium 1993 32 bit, 296 pin 4 GB 100-150 MHz
Pentium Pro 1995 32 bit, 387 pin 64 GB 166-200 MHz
Pentium II 1997 32 bit, 242 pin 64 GB 233-450 MHz
Pentium III 1999 32 bit, 330 pin 64 GB 450-1000 MHz
Pentium 4 2000 32/64 bit, 478 pin 64 GB 1400-3800 MHz
Pentium M 2003 32 bit, 479 pin 64 GB 1300-2130 MHz
Core 2006 32 bit, 479 pin 64 GB 1000-1860 MHz
Core 2duo 2006 32/64 bit, 775 pin 64 GB 1060-3160 MHz
Core i7 2008 32/64 bit, 1366 Pin 64 GB 2660-3330 MHz
Atom 2008 32/64 bit, 441 pin 64 GB- 800-1860 MHz
How does a Microprocessor works
• To execute a program, the microprocessor “reads” each instruction from
memory, “interprets” it, then “executes or perform” it.
• The right name for the cycle is
Fetch - to read the instruction (binary pattern) from the memory
Decode - recognizing which task is to be performed on seeing a
particular bit pattern
Execute – executing the task specified by the instruction
• This sequence is continued until all stop instructions is reached.
Microprocessor Program
A set of instructions are required to perform desired operations.
Word length
The total number of bits that can be processed by a microprocessor simultaneously in
one step.
Definition of the Microprocessor
Microprocessor is a Programmable, Clock driven, Register based,
Electronic device that reads instruction from a storage device, takes the data
from input unit and process the data according to the instructions and provides
the result to the output unit.
• Programmable- Perform Different set operation on the data depending on
the sequence of instructions supplied by the programmer.
• Clock Driven – Whole task is divided into basic operations, are divided
into precise system clock periods.
• Register Based – Storage element
• Electronic Device – fabricated on a chip
 ALU:- Arithmetic and logical operations like add, subtraction, AND & OR.
Not accessible by the user
 Register Array: - Store data during the execution of program.
 Control Unit: Provides necessary timing and control signal. It controls the
flow of data between microprocessor and peripherals.
 Memory: Stores information such as instructions and data in binary
format (0 and 1).
Sub-system” of microprocessor-based system. sub-system includes
the registers inside the microprocessor .
Read Only Memory (ROM): used to store programs that do not need
alterations.
Random Access Memory (RAM) :used to store programs that can
read and altered like programs and data.
 Input/output: Communicates with the outside world.
 System Bus: Communication path between the microprocessor and
peripherals. It is a group of wires to carry bits.
Architecture of 8085 μp
Pin diagram of 8085 μp
8085 architecture consists of following blocks:
1. Register Array
2. ALU & Logical Group
3. Instruction decoder and machine cycle encoder
4. Timing and control circuitry
5. Interrupt control Group
6. Serial I/O control Group
Features of 8085 μp
• 8085/ 8085A is an 8 bit general purpose μp, capable of addressing 64 K
memory (Using 16 bit address bus 216 = 65536 =64 K memory locations
can be addressed) .
• It has 40 pins and requires a +5 V single power supply
• Developed by INTEL
• Designed using NMOS (n-channel metal oxide semiconductor)
technology
• 6200 transistors on single chip
• It provides on chip clock generator, hence it does not require external
clock generator.
• Operates on 3MHz clock frequency.
• 8 bit multiplexed address/data bus, which reduce the number of pins.
• 16address lines, hence it can address 216 = 64 K bytes of memory
• It generates 8 bit I/O addresses, hence it can access 28 = 256 I/O ports.
• 5 hardware interrupts i.e. TRAP, RST6.5, RST5.5, RST4.5, and INTR
• It provides DMA (direct memory access).
Register Array

Classified into 4 types


(a) General purpose register: (user accessible)
(b) Special Purpose Register [Accumulator, Instruction Register and Flag]
(c) Temporary Register[ W, Z, Temporary data register]
(d)Pointer Register or special purpose [SP, PC]
(a) General purpose register: (user accessible)
• Intel 8085 has six general purpose registers
• B, C, D, E, H and L are 8 bit register (can be used singly) –they can hold 8-
bit data
• Can also be used for 16-bit register pairs- BC, DE & HL to hold 16 bit data.
• Used to store the intermediate data and result
• H -L pair works as a memory pointer
• A memory pointer hold the address of a particular memory location and can
store 16 bit address a s they work in pairs
(b) Special Purpose Register [Accumulator, Instruction Register and Flag]
• Accumulator (A): (user accessible)
 8 bit register
 It is a part of the ALU
 It is used for arithmetic and logical operations
 Stores one of the operand before any arithmetic and logical
operations and result of operation is again stored back in
Accumulator (A)
 Result of an operation is stored in accumulator (A).
 Store 8 bit data during I/O transfer
• Instruction Register and instruction decoder: (user not accessible)
 When an instruction is fetched from memory, it is loaded in IR.
Then transferred to the decoder for decoding and the corresponding
machine cycle is executed.
 It is not programmable and can not be accessed through any
instruction.
• Flag Register (F): (user accessible)

 8 bit Register
 Intel 8085 has 5 flags
 It is also a part of the ALU
 Indicates the status of the ALU operation.
 ALU includes 5 flip flop, which are set or reset after an operation according to
data conditions of the result in the accumulator. The output of these flip flops
are called flags
CY (Carry) The carry flag is used for carrying and borrowing in case of addition
and subtraction operations. CY is set when an arithmetic operation
generates a carry bit, otherwise it is 0 (reset) . i.e. if the result of an
operation is a number with more than 8 bits , the accumulator can
hold only 8 bits
P (Parity) P= 1; if the result of an ALU operation has an even number of 1’s in
A; P= 0; if number of 1 is odd.
AC (Auxiliary used only in BCD operations. Similar to CY, AC= 1 if there is a carry
carry) from D3 to D4 Bit, AC= 0 if there is a no carry from D3 to D4 Bit
(not available for the user)
Z(zero) The zero flag is set if the result of an ALU operation is zero, Z = 1; if
result in A is 00H otherwise it is reset Z=0
S(Sign) If the accumulator holds a negative number after an operation, then
sign flag is set, S=1 if D7 bit of the A is 1(indicate the result is -ve)
S= 0 if D7 bit of the A is 0(indicate the result is +ve)

These flags have critical importance in the decision making process of the μp. The conditions
(set or reset) of the flags are tested through program instructions.
• Temporary Register [ W, Z, Temporary data register]

 Internally used by the μp (user not accessible)


 W and Z are 8 bit temporary registers
 Used to hold temporary addresses during the execution of some
instructions
 Temporary data register: 8 bit register which is used to hold temporary
data during ALU operations.
• Pointer Register or special purpose [SP, PC] –Memory Pointers

 Stack Pointer (SP)


 16 bit register
 Acts as a memory pointer which points to a memory location in the
stack area of the read-write memory, i.e., it holds the address of the data
present at the top of the stack memory
 It is a reserved area of the memory in the RAM to store and retrieve the
temporary information.
 When there is a subroutine call or on an interrupt. ie. pushing the return
address on a jump, and retrieving it after the operation is complete to
come back to its original location.
 Program Counter (PC)
 16 bit register
 Stores the 16 bit address used for the execution of program
 Contain the 16 bit address of the memory location from where the next
byte of instruction to be executed is to be read
 After fetching the instruction, the contents of the PC is automatically
incremented by 1.
 Acts as a memory pointer
 Not much use in programming, but as an indicator to user only.
In addition to register, μp contains some latches and buffer
• Increment and decrement address latch
 16 bit register
 Used to increment or decrement the content of PC and SP
• Address buffer
 8 bit unidirectional buffer
 Used to drive high order address bus(A8 to A15)
 When it is not used under such as reset, hold and halt etc. this buffer is used
tristate high order address bus.
• Data/Address buffer
 8 bit bi-Directional buffer
 Used to drive the low order address (A0 to A7) and data (D0 to D7) bus.
 Under certain conditions such as reset, hold and halt etc. this buffer is used
tristate low order address bus.
• Timing and control circuitry
 works as the brain of the μp
 For proper sequence and synchronization of all the operations of μp, this unit
generates all the timing and control signals necessary for communication
between microprocessor and peripherals.
• Interrupt Control group
 Interrupt:- Occurrence of an external disturbance
 The μp can be interrupted during the execution of one program and can be
asked to perform an interrupt service routine
 After servicing the interrupt, 8085 resumes its normal working sequence
 Transfer the control to special routines
 Five interrupts: - TRAP, RST7.5, RST6.5, RST5.5, INTR
 On receiving such an interrupt request, responds to this in an interrupt
acknowledge signal INTA.
 The interrupt control unit handles these various interrupt signals
• Serial I/O control Group
 The 8085 is a parallel device, i.e., it transmits 8 bit data simultaneously over 8
data lines. This parallel transmission is called parallel I/O mode
 But if data are to be transmitted over long distances or to slow peripherals,
this parallel transmission can be very expensive. In these situations, serial
transmission is preferred
 In this method, there is a single line to carry data bits and data bits are
transmitted one by one serially through the single line. This is called the serial
I/O mode
 Serial data is entered through SID(serial input data) input (received)
 Serial data is outputted on SOD(serial output data) input (send)
Introduction to 8085 Assembly Language Programming
• The physical components of this system are called hardware.
• The microprocessor (μp) interacts or communicates with all these
components. It communicates and operates in the binary numbers (bits) 0
and 1 , which is represented as voltages LOW or HIGH.
• Each μp has its own instruction set formed of binary pattern and this is
called the machine language.
• Since it is difficult for us humans to communicate in 0’s and 1’s , the binary
instructions are given abbreviated names called mnemonics. The
instructions written in terms of these mnemonics form the assembly
language program for that particular μp.
• Thus each μp has its own instruction set, machine language and assembly
language.
• That is, the machine language and assembly language are machine
dependent, they are not portable, which means that the assembly language
program / machine language program written for one μp cannot be used for
another μp
• A set of instructions written for a given μp to perform a certain task is
called a program and the group of such programs form the software of
that μp
Introduction to 8085 Assembly Language Programming
• An Instruction is a command to the microprocessor to perform a given task on
specified data.
• Each instruction has two parts: the first part specifies the task (operation) to be
performed called the operation code or the opcode and the second part specifies
the data to be operated on called the operand.
• Operand can be specified in various ways it can be of 8 bit or 16 bit data, and
internal register, a memory location, or an 8 bit or 16 bit address or it can be
implicit. These different ways of specifying the operand is called addressing
modes
An instruction is a binary pattern designed inside a μp to perform a specified task.
The entire group of such instruction for a μp is called its instruction set. The
instruction set determines what all functions a μp can perform.
The 8085 instruction set is classified into five different groups:
1. Data transfer (copy) operations
2. Arithmetic operations
3. Logical operations
4. Branch operations
5. Machine control operations
1. Data transfer (copy) operations

• This group of instructions copies (transfers) data from a location called source
to another location called destination.
• This operation is only a copying operation and hence data is not lost from the
source location after the operation (i.e. after the operation data is available both
at the source and destination locations)
• The various types of data transfer are :

Types Examples
Between registers Copy the contents of
register B to register D
Specific data byte to a Load 28 H into register C
register or memory location
Between a memory location Load the byte in memory
and a register location 2005 H to register
D
Between an I/O device and From an input keyboard to
the accumulator the accumulator
Data Transfer Instructions
• These instructions move data between registers, or between memory and
registers.
• These instructions copy data from source to destination.
• While copying, the contents of source are not modified.

Direct
LHLD 16 bit address of Load H and L register direct
memory location
OUT 8 bit port address Out data from accumulator to
an external port
2. Arithmetic operations
These instructions perform arithmetic operations such as addition, subtraction,
increment and decrement
• Addition
 One of the operands is stored in the accumulator
 The contents of a register or the contents of the memory location can be
added to the contents of the accumulator and the sum is stored in the
accumulator.
 No two registers can be added directly (E.g.., B and C).
 The instruction DAD is an exception; it adds 16 bit data directly in the
register pairs.
• Subtraction
 Subtraction is performed through 2’s complement method.
 For this, the minuend is to be stored in the accumulator. From this number,
any 8 bit number or the contents of a register or the contents of a memory
location can be subtracted and the result is stored in the accumulator
 The contents of any two registers cannot be subtracted directly
• Increment/Decrement
 The 8 bit contents of the accumulator or any register or a memory location
can be incremented or decremented by 1.
 Similarly, the 16 bit contents of register pair (such as BC) can be
incremented or decremented by 1
 These operations differ from addition and subtraction- for addition and
subtraction, the accumulator is to be involved. But increment/decrement
operation can be done without the help of the accumulator
Arithmetic Instructions
These instructions perform arithmetic operations such as addition, subtraction,
increment, and decrement.
SBI 8 bit data Subtract immediate with
borrow
3. Logical Operations
These instructions perform various logical operations with the contents of the
accumulator
• AND, OR, X-OR
 Any 8 bit number or the contents of a register or the contents of a memory
location are logically ANDed, ORed or X-ORed with the contents of the
accumulator and the result is stored in the accumulator
• Rotate - Each bit in the accumulator can be shifted to left or right
• Compare- Any 8 bit number or the contents of a register or the contents of a
memory location can be checked (compared) with the contents of the
accumulator
• Complement-The contents of the accumulator can be complemented, i,.e, all 0’s
can be replaced by 1’s and vice versa
Logical Instructions
These instructions perform various logical operations with the contents of
the accumulator.
CMA No operand Complement accumulator
CMC No operand Complement carry
4. Branching Operations
This group of instructions alter the sequence of program execution either
conditionally or unconditionally
• Jump
 There are conditional jumps and unconditional jumps
 Conditional jumps plays critical role in decision making process in
programming. They test for a certain condition (flag status: whether zero or
carry flag is set or reset) and if the condition is met, it alters the program
sequence as specified.
 The unconditional jump instruction simply alters the sequence without
having to check for a condition
• Call, Return, and Restart
 These instructions change the sequence of a program either by calling a
subroutine or returning from a subroutine.
 Restart instruction is to begin execution right from the beginning
Branching Instructions
This group of instructions alters the sequence of program execution either
conditionally or unconditionally.

Opcode Operand Description Flag


Status
JMP 16 bit address Jump unconditionally none
JC 16 bit address Jump on carry CY =1
JNC 16 bit address Jump on No carry CY =0
JP 16 bit address Jump on positive S=0
JM 16 bit address Jump on Minus S=1
JPE 16 bit address Jump on Parity Even P=1
JPO 16 bit address Jump on Parity odd P=0
JZ 16 bit address Jump on Zero Z=1
JNZ 16 bit address Jump on Not zero Z=0
5. Machine Control Instructions
These instructions control machine functions such as Halt, Interrupt, or do
nothing.
Classification based on length
• Instruction Word Size
Instruction set is classified into three groups based on byte size or
word size. However, instructions are commonly referred to in terms of bytes
rather than words.
 One byte instructions
 Two byte instructions
 Three byte instructions
1. One-byte instructions: Instruction having one byte in machine code.

Opcode Operand Machine code/Hex code


MOV A, B 78
ADD M 86
2. Two-byte instructions: Instruction having two byte in machine code.
Opcode Operand Machine Byte Description
code/Hex code
MVI A, 7F H 3E First byte
7F Second Byte
ADI 0F H C6 First byte
0F Second Byte

3. Three-byte instructions: Instruction having three byte in machine code.

Opcode Operand Machine Byte Description


code/Hex code
JMP 9050 H C3 First byte
50 Second Byte
90 Third Byte
LDA 8850 H 3A First byte
50 Second Byte
88 Third Byte
No Instruction Hexcode No.of Bytes
1 ADD B 80 H 1
ADD C 81 H 1
ADD D 82 H 1
ADD E 83 H 1
ADD H 84 H 1
ADD L 85 H 1
ADD M 86 H 1
ADD A 87 H 1
2 ADI C6 H 2
3 CMA 2F H 1
4 CMC 3F H 1
5 CMP B B8 H 1
CMP C B9 H 1
CMP D BA H 1
CMP E BB H 1
CMP H BC H 1
CMP L BD H 1
CMP M BE H 1
6 CPI FE H 2
7 DCR B 05 H 1
DCR C 0D H 1
DCR D 15 H 1
DCR E 1D H 1
DCR H 25 H 1
DCR L 2D H 1
DCR M 35 H 1
DCR A 3D H 1
8 DCX Register
pair
DCX B 0B H 1
DCX D 1B H 1
DCX H 2B H 1
DCX SP 3B H 1
9 DI F3 H 1
10 EI FB H 1
11 HLT 76 H 1
12 IN DB H 2
13 INR B 04 H 1
INR C 0C H 1
INR D 14 H 1
INR E 1C H 1
INR H 24 H 1
INR L 2C H 1
INR M 34 H 1
INR A 3C H 1
14 INX register
pair
INX B 03 H 1
INX D 13 H 1
INX H 23 H 1
INX SP 33 H 1
15 JMP C3 3
16 Jump
conditionally
JC DA H 3
JNC D2 H 3
JP F2 H 3
JM FA H 3
JPE EA H 3
JPO E2 H 3
JZ CA H 3
JNZ C2 H 3
17 LDA 3A H 3
18 LDAX B/D
register pair
LDAX B 0A H 1
LDAX D 1A H 1
19 LHLD 2A H 3
20 LXI Register
pair
LXI B 01 H 3
LXI D 11 H 3
LXI H 21 H 3
LXI SP 31 H 3
21 MOV Rd, 1
Rs
MOV M, Rs 1
MOV Rd, M 1
Hex Code
Source location
B C D E H L M A
B 40 41 42 43 44 45 46 47
Destination location

C 48 49 4A 4B 4C 4D 4E 4F
D 50 51 52 53 54 55 56 57
E 58 59 5A 5B 5C 5D 5E 5F
H 60 61 62 63 64 65 66 67
L 68 69 6A 6B 6C 6D 6E 6F
M 70 71 72 73 74 75 76 77
A 78 79 7A 7B 7C 7D 7E 7F
22 MVI Reg,
Data
MVI M, Data
MVI B 06 H 2
MVI C 0E H 2
MVI D 16 H 2
MVI E 1E H 2
MVI H 26 H 2
MVI L 2E H 2
MVI M 36 H 2
MVI A 3E H 2
23 STA 32 H 3
24 STAX B/D
reg pair
STAX B 02 H 1
STAX D 12 H 1
25 STC 37 H 1
26 SUB B 90 H 1
SUB C 91 H 1
SUB D 92 H 1
SUB E 93 H 1
SUB H 94 H 1
SUB L 95 H 1
SUB M 96 H 1
SUB A 97 H 1
27 SUI D6 H 2
28 OUT 8 bit
port address
OUT D3 H 2
How to recognize the number of bytes in an instruction
1. A mnemonic followed by one or 2 letters that designate the registers (A, B, C, D,
E, H, L, SP) is an one-byte instruction
Eg. ADD C ,
MOV B,D, etc.
Instructions in which the registers are implicit are also one-byte instructions

2. A mnemonic followed by an 8 bit address is a two byte instruction.


eg. MVI B, 8 bit data
ADI 8 bit data
IN 8 bit port address
OUT 8 bit port address, etc. are two byte instructions

3. A mnemonic followed by a 16-bit address or 16 bit data is a 3 byte


instruction
Eg. JMP 16 bit address
LXI Register, 16 bit data
JNZ 16 bit address, etc. are 3 byte instructions
In writing assembly language program, we can assign memory addresses in a
sequence once we know the no. of bytes in an instruction. For eg. A 3 byte
instruction has 3 hex codes and requires 3 successive locations for storing etc.
Addressing Modes in 8085
These are the instructions 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 alteration in the
content. Addressing modes in 8085 is classified into 5 groups −
1. Immediate addressing mode
In this mode, the 8/16-bit data is specified in the instruction itself as one of its operand.
For example: MVI B, 20H: means 20H is copied into register B.
2. Register addressing mode
In this mode, the data is copied from one register to another.
For example: MOV C, B: means data in register B is copied to register C.
3. Direct addressing mode
In this mode, the data is directly copied from the given address to the register.
For example: LDA 5000H: means the data at address 5000H is copied to Accumulator.
4. Indirect addressing mode
In this mode, the data is transferred from one register to another by using the address pointed
by the register.
For example: MOV K, B: means data is transferred from the memory address
pointed by the register to the register K.
5. Implied addressing mode
This mode doesn’t require any operand; the data is specified by the opcode itself.
For example: CMP.
Interrupts in 8085
Interrupts are the signals generated by the external devices to request the microprocessor to
perform a task. There are 5 interrupt signals, i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and
INTR.
 Maskable interrupt − In this type of interrupt, we can disable the interrupt by writing some
instructions into the program. For example:RST7.5, RST6.5, RST5.5.
 Non-Maskable interrupt − In this type of interrupt, we cannot disable the interrupt by
writing some instructions into the program. For example: TRAP.
Note − INTA is not an interrupt, it is used by the microprocessor for sending
acknowledgement.
TRAP has the highest priority, then RST7.5 and so on.
Interrupt Service Routine (ISR)
A small program or a routine that when executed
Decimal Number Binary Number
00 0000
01 0001
02 0010
03 0011
04 0100
05 0101
06 0110
07 0111
08 1000
09 1001
10 1010
11 1011
12 1100
13 1101
14 1110
15 1111
Write an 8085 program to add two numbers

Let the two decimal numbers be 05 and 10 and store the result in memory location 9000 H

Memory Location Opcode Remarks


5000 H MVI A, 05 H Move immediate
05 to the
accumulator
5002 H MVI B, 10 H Move immediate
10 to register B
5004 H ADD B Add contents of
accumulator with
contents of register
B (A=A+B)
5005 H STA 9000 H Store the result of
accumulator in
memory location
9000 H
5008 H HLT Terminate the
program
Write an 8085 program to add two numbers stored at memory locations 9000 and 9001 H
and store the result in successive memory location
Let the two numbers be 05 H and 10 H and store the result in memory location 9002 H

Memory Location Opcode Remarks


5000 H LDA, 9000 H Move contents of memory location
9000 H to accumulator
5003 H MOV B, A Move contents of Accumulator to
register B
5004 H LDA, 9001 H Move contents of memory location
9001 H to accumulator
5007 H ADD B Add contents of accumulator with
contents of register B (A=A+B)
5008 H STA 9002 H Store the result of accumulator in
memory location 9002 H
5011 H HLT Terminate the program
Write an 8085 program to subtract two numbers (Subtraction is performed by 2’s
complement method)
Let the two decimal numbers be 10 and 05 and store the result in memory location 9000 H
For proper subtraction

Memory Location Opcode Remarks


5000 H MVI A, 10 H Move immediate
10 H to the
accumulator
5002 H MVI B, 05 H Moveimmediate
05 H to register B
5004 H SUB B Subtract contents
of accumulator
with contents of
register B (A=A-B)
5005 H STA 9000 H Store the result of
accumulator in
memory location
9000 H
5008 H HLT Terminate the
program
For improper subtraction

Let the two decimal numbers be 05 and 10 and store the result in memory location 9000 H

Memory Location Opcode Remarks


5000 H MVI A, 05 H Move immediate 05 H to the
accumulator
5002 H MVI B, 10 H Move immediate 10 H to register B
5004 H SUB B Subtract contents of accumulator
with contents of register B (A=A-B)
5005 H JC LOOP Jump on carry to LOOP
5008 H CMA Complement the content of the
accumulator
5009 H ADI 01 H Add 01 to the contents of the
accumulator
500A H LOOP: Store the result of accumulator in
STA 9000 H memory location 9000 H
500D H HLT Terminate the program

You might also like