0% found this document useful (0 votes)
60 views18 pages

FMM Unit-4 (8051 Microcontroller)

The 8051 microcontroller is an 8-bit device known for its versatility, low power consumption, and Harvard architecture, featuring timers, interrupt handling, and serial communication interfaces. It includes 128 bytes of internal RAM, 4kB of on-chip ROM, and supports up to 64kB of external RAM, making it suitable for various applications in embedded systems, automotive, medical devices, and consumer electronics. The architecture consists of functional blocks like the CPU, memory, I/O ports, and a serial communication interface, with advantages such as low cost and high reliability, but limitations in processing power and memory capacity.

Uploaded by

sravanrocks19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views18 pages

FMM Unit-4 (8051 Microcontroller)

The 8051 microcontroller is an 8-bit device known for its versatility, low power consumption, and Harvard architecture, featuring timers, interrupt handling, and serial communication interfaces. It includes 128 bytes of internal RAM, 4kB of on-chip ROM, and supports up to 64kB of external RAM, making it suitable for various applications in embedded systems, automotive, medical devices, and consumer electronics. The architecture consists of functional blocks like the CPU, memory, I/O ports, and a serial communication interface, with advantages such as low cost and high reliability, but limitations in processing power and memory capacity.

Uploaded by

sravanrocks19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Unit-IV : 8051 Microcontroller

The 8051 microcontroller is a widely used 8-bit microcontroller known for its
versatility and low power consumption. Its architecture is based on Harvard
architecture and includes a range of features such as timers, interrupt handling,
and serial communication interfaces.

It has two memory spaces, one for program memory and the other for data
memory. The program counter can access up to 64K of program memory, while
the data memory has 128 bytes of internal RAM and up to 64K of external RAM.

1.8051 Microcontroller Architecture


The 8051 microcontroller is a tiny computer developed by Intel in the 1980s. It is
used in many electronic systems like cars, medical devices, etc. It comes with
many built-in tools that can be used to interface with other devices, making it an
excellent choice for many embedded system applications.

The microcontroller has four functional blocks: the CPU, memory, input/output
ports, and serial communication interface.

The 8051 Microcontroller Architecture consists of the following major


components:
 Interrupt control: It supports five interrupt sources, which can interrupt the
normal program execution to handle specific events.
 Central Processing Unit (CPU): This is the brain of the microcontroller,
which is responsible for executing instructions and performing arithmetic
and logical operations. The 8051 CPU consists of an ALU, accumulator,
registers, and a program counter.
 Oscillator: It requires an external oscillator to provide a clock signal to the
microcontroller
 Bus control: The 8051 microcontroller includes a bus controller that
manages data transfer between the CPU and peripheral devices, such as
memory or input/output devices.
 4k byte ROM: The 8051 microcontroller architecture includes a 4 kilobyte
(4k) read-only memory (ROM) for storing the program instructions that are
executed by the CPU.
 128-byte RAM: The 8051 microcontroller also has a 128-byte random-
access memory (RAM) for storing data that is used by the program
instructions during runtime.
 Input/output Ports: They have four 8-bit input/output (I/O) ports that can
be configured as either input or output.
 Timers and Counters: They have two 16-bit timers/counters that can be
used for a variety of tasks such as measuring time intervals, generating
PWM signals, and counting external events.
 Serial Communication Interface (SCI): It has a built-in serial port that can
be used for asynchronous serial communication.

(or)

Internal Architecture of 8051 Microcontroller

The Internal architecture is shown in Figure below and the various Registers and
units are described below.

Accumulator (Acc):

•Operand register

• Implicit or specified in the instruction

•Has an address in on chip SFR bank

B Register:

Used to store one of the operands for multiplication and division, otherwise,
scratch pad considered as a SFR.
Stack Pointer (SP): 8 bit wide register. Incremented before data is stored on to
the stack using PUSH or CALL instructions. Stack defined anywhere on the 128
byte RAM.

Data Pointer (DPTR): 16 bit register contains DPH and DPL Pointer to external
RAM address. DPH and DPL allotted separate addresses in SFR bank

Port 0 To 3 Latches & Drivers: Each I/O port allotted a latch and a driver
Latches allotted address in SFR. User can communicate via these ports P0, P1, P2,
and P3.

Serial Data Buffer: Internally had TWO independent registers, TRANSMIT


buffer (parallel in serial out – PISO) and RECEIVE buffer (serial in parallel out –
SIPO) identified by SBUF and allotted an address in SFR.

Program Status Word (PSW): Set of flags contains status information as detailed
below in the Figure

Timer Registers: for Timer0 (16 bit register – TL0 & TH0) and for Timer1 (16 bit
register – TL1 & TH1) four addresses allotted in SFR

Control Registers: Control registers are IP, IE, TMOD, TCON, SCON, and
PCON. These registers contain control and status information for interrupts,
timers/counters and serial port. Allotted separate address in SFR.

Timing and Control Unit: This unit derives necessary timing and control signals
for internal circuit and external system bus.
Oscillator: generates basic timing clock signal using crystal oscillator.

Instruction Register: Decodes the opcode and gives information to timing and
control unit.

Figure 4.1.4 8051 Architecture Block diagram

EPROM & program address Register: provide on chip EPROM and mechanism
to address it. All versions don’t have EPROM.
RAM & RAM Address Register: provide internal 128 bytes RAM and a
mechanism to address internally

ALU: Performs 8 bit arithmetic and logical operations over the operands held by
TEMP1 and TEMP 2.User cannot access temporary registers.

SFR Register Bank: set of special function registers address range: 80 H to FF H.


Interrupt, serial port and timer units control and perform specific functions under
the control of timing and control unit.

2. 8051 Pin Diagram:

The 8051 microcontroller has a total of 40 pins arranged in four groups, namely
Port 0, Port 1, Port 2, and Port 3. Here’s a brief explanation of each group:

 Port 0: Pins 32-39 are designated as Port 0 and are used for both input and
output operations. Port 0 can also be used for external memory interfacing.
 Port 1: Pins 1-8 are designated as Port 1 and are used for both input and
output operations. Port 1 also has built-in pull-up resistors that can be
activated by writing a 1 to the corresponding bit.
 Port 2: Pins 21-28 are designated as Port 2 and are used for both input and
output operations. Port 2 can also be used for external memory interfacing,
and some of its pins have alternate functions, such as being used as a serial
communication interface.
 Port 3: Pins 10-17 are designated as Port 3 and are used for both input and
output operations. Port 3 can also be used for external memory interfacing,
and some of its pins have alternate functions, such as being used as a
timer/counter input.
 Vcc: This pin is used to supply power to the microcontroller and is typically
connected to a +5V power source.
 GND: This pin is used as the ground reference for the microcontroller and is
typically connected to the ground.
 XTAL1 and XTAL2: These pins are used to connect an external crystal
oscillator that provides the clock signal for the microcontroller.
 Reset: This pin is used to reset the microcontroller and is typically
connected to a push-button switch.
 ALE: This pin is used as the Address Latch Enable signal and is used to
latch the address from the program counter onto the external memory bus.
 PSEN1: This pin is used as the Program Store Enable signal and is used to
select the external ROM for program execution.
 EA1: This pin is used to enable/disable external memory interfacing. If this
pin is connected to Vcc, the microcontroller will fetch the program from the
external memory. if it is connected to GND, the microcontroller will fetch
the program from the internal ROM.
(or)

Pins 1 to 8 − these pins are known as Port 1. This port doesn’t serve any
other functions. It is internally pulled up, bi-directional I/O port.

Pin 9 − It is a RESET pin, which is used to reset the microcontroller to its


initial values.

Pins 10 to 17 − These pins are known as Port 3. This port serves some
alternate functions like interrupts, timer input, control signals, serial
communication signals RxD and TxD, etc.

Figure: Port 3 Alternate Functions

Pins 18 & 19 − These pins are used for interfacing an external crystal to get
the system clock.

Pin 20 − This pin provides the power supply to the circuit.

Pins 21 to 28 − These pins are known as Port 2. It serves as I/O port. Higher
order address bus signals are also multiplexed using this port.

Pin 29 − This is PSEN pin which stands for Program Store Enable. It is used
to read a signal from the external program memory.

Pin 30 − This is EA pin which stands for External Access input. It is used to
enable/disable the external memory interfacing.

Pin 31 − This is ALE pin which stands for Address Latch Enable. It is used
to demultiplex the address-data signal of port.

Pins 32 to 39 − These pins are known as Port 0. It serves as I/O port. Lower
order address and data bus signals are multiplexed using this port.
Pin 40 − This pin is used to provide power supply to the circuit.

3. Application for 8051 Microcontroller

The 8051 microcontroller architecture has various applications, including:

 It is commonly used in embedded systems, such as in home appliances,


security systems, and industrial automation systems.
 This is used in automotive applications, such as in engine control units,
airbag control units, and anti-lock braking systems.
 It is used in medical devices, such as heart rate monitors, blood pressure
monitors, and insulin pumps.
 It is used in robotics applications, such as in controlling robot arms and
movements.
 They are used in various consumer electronics products, such as in remote
controls, digital cameras, and smart home devices.
 This is used in communication systems, such as modems, routers, and
switches.
 These are used in security systems, such as access control systems and alarm
systems.

*Advantages for 8051 Microcontroller Architecture

Here, the advantages of the 8051 microcontroller architecture include:

 It is a cheaper option, which makes it a popular choice for low-cost


applications.
 Designed to consume very low power for applications.
 8051 Microcontroller Architecture is known for its high reliability.
 It is easy to program, has a simple instruction set, and has easy-to-use
development tools.
 It can be used in a wide variety of applications.

*Disadvantages of 8051 Microcontroller Architecture

Here, are the disadvantages of 8051 Microcontroller Architecture:

 It has limited processing power compared to microcontrollers


 Memory is limited for applications it requires a lot of data storage.
 It highly requires advanced peripherals such as USB or Ethernet
connectivity.
 The instruction set makes it challenging to program and optimize code.
 The development tools are not as advanced, and it is difficult to develop and
debug code.

Note: * Indicates, not in syllabus, but for Knowledge only.

4. Memory organization of 8051:

The 8051 microcontroller has128 bytes of Internal RAM and 4kB of on chip
ROM. The RAM is also known as Data memory and the ROM is known as
program memory. The program memory is also known as Code memory .This
Code memory holds the actual 8051 program that is to be executed. In 8051 this
memory is limited to 64K.Code memory may be found on-chip, as ROM or
EPROM. It may also be stored completely off-chip in an external ROM or, more
commonly, an external EPROM. The 8051 has only 128 bytes of Internal RAM
but it supports 64kB of external RAM. As the name suggests, external RAM is
any random access memory which is off-chip. Since the memory is off-chip it is
not as flexible in terms of accessing, and is also slower. For example, to
increment an Internal RAM location by1,it requires only 1 instruction and 1
instruction cycle but to increment a 1-byte value stored in External RAM
requires 4 instructions and 7 instruction cycles. So, here the external memory is 7
times slower.

Internal RAM OF 8051:


This Internal RAM is found on-chip on the 8051.So it is the fastest RAM
available, and it is also the most flexible in terms of reading, writing, and
modifying it’s contents. Internal RAM is volatile, so when the 8051 is reset this
memory is cleared.The128bytes of internal RAM is organized as below.
(i) Four register banks (Bank0, Bank1, Bank2 and Bank3) each of 8-bits
(total32 bytes). The default bank register is Bank0. The remaining Banks
are selected with the help of RS0 and RS1 bits of PSW Register.
(ii) 16bytes of bit addressable area and
(iii) 80 bytes of general purpose area (Scratch pad memory) as shown in
the diagram below. This area is also utilized by the microcontroller as a
storage area for the operating stack.
The 32 bytes of RAM from address 00 H to 1FH are used as working
registers organized as four banks of eight registers each. The registers are named
as R0-R7.Each register can be addressed by its name or by its RAM address.
EX: MOVA,R7 or MOVR7,#05H
Figure3.3.1Internal RAM memory of 8051Microcontroller
Internal ROM (On–chip ROM):
The 8051 microcontroller has 4kB of on chip ROM but it can be extended
up to 64kB.This ROM is also called program memory or code memory. The
CODE segment is accessed using the program counter (PC) for op code fetches
and by DPTR for data. The external ROM is accessed when the EA(active
low)pin is connected to ground or the contents of program counter exceeds
0FFFH.When the Internal ROM address is exceeded the 8051 automatically
fetches the code bytes from the external program memory.
Figure3.3.2External ROM memory of 8051Microcontroller

5. I/O ports of 8051:-

8051 microcontrollers have 4 I/O ports each of 8-bit, which can be configured as
input or output. Hence, total 32 input/output pins allow the microcontroller to be
connected with the peripheral devices.

Port 0 − The P0 (zero) port is characterized by two functions −


When the external memory is used then the lower address byte (addresses A0-A7)
is applied on it, else all bits of this port are configured as input/output.
In order to apply logic 1 (5V) on this output pin, it is necessary to build an
external pullup resistor.

Port 1

P1 is a true I/O port as it doesn’t have any alternative functions as in P0, but this
port can be configured as general I/O only. It has a built-in pull-up resistor and is
completely compatible with TTL circuits.

Port 2

P2 is similar to P0 when the external memory is used. Pins of this port occupy
addresses intended for the external memory chip. This port can be used for higher
address byte with addresses A8-A15. When no memory is added then this port can
be used as a general input/output port similar to Port 1.

Port 3

In this port, functions are similar to other ports except that the logic 1 must be
applied to appropriate bit of the P3 register. Port 3 Alternate Functions shown in
below table.

Table: Port 3 Alternate Functions

6. 8051 Interrupts

Interrupts are the events that temporarily suspend the main program, pass the
control to the external sources and execute their task. It then passes the control to
the main program where it had left off.

Types of interrupt in 8051 Microcontroller

There are five sources of interrupts in 8051 Microcontroller:

 Timer 0 overflow interrupt - TF0


 External hardware interrupt - INT0
 Timer 1 overflow interrupt - TF1
 External hardware interrupt - INT1
 Serial communication interrupt - RI/TI

The priority of Interrupts is: INT0, TFO, INT1, TF1, RI/TI (Highest to Lowest).

The timer and serial interrupts are internally produced by the microcontroller,
whereas the external interrupts are produced by additional interfacing devices or
switches that are externally connected with the microcontroller. These external
interrupts can be level triggered or edge triggered.

Each interrupt can be enabled or disabled by setting bits of the IE register and the
whole interrupt system can be disabled by clearing the EA bit of the same register.

When interrupt occur then the microcontroller executes the interrupt service
routine. Therefore the memory location corresponds to interrupt enables it.
Consider the interrupt corresponding to the memory location is shown in the
interrupt vector table below.
7. Instruction Set of 8051:-

Based on the operation they perform, all the instructions in the 8051
Microcontroller Instruction Set are divided into five groups. They are:
 Data Transfer Instructions
 Arithmetic Instructions
 Logical Instructions
 Boolean or Bit Manipulation Instructions
 Program Branching Instructions
Data Transfer Instructions
The Data Transfer Instructions are associated with transfer of data between
registers or external program memory or external data memory. The Mnemonics
associated with Data Transfer are given below.
 MOV
 MOVC
 MOVX
 PUSH
 POP
 XCH
 XCHD

Arithmetic Instructions
Using Arithmetic Instructions, you can perform addition, subtraction,
multiplication and division. The arithmetic instructions also include increment by
one, decrement by one and a special instruction called Decimal Adjust
Accumulator.The Mnemonics associated with the Arithmetic Instructions of the
8051 Microcontroller Instruction Set are:
 ADD
 ADDC
 SUBB
 INC
 DEC
 MUL
 DIV
 DA A
Logical Instructions
The next group of instructions are the Logical Instructions, which perform
logical operations like AND, OR, XOR, NOT, Rotate, Clear and Swap. Logical
Instruction are performed on Bytes of data on a bit-by-bit basis.Mnemonics
associated with Logical Instructions are as follows:
 ANL
 ORL
 XRL
 CLR
 CPL
 RL
 RLC
 RR
 RRC
 SWAP
Boolean or Bit Manipulation Instructions
As the name suggests, Boolean or Bit Manipulation Instructions deal with bit
variables. We know that there is a special bit-addressable area in the RAM and
some of the Special Function Registers (SFRs) are also bit addressable.The
Mnemonics corresponding to the Boolean or Bit Manipulation instructions are:
 CLR ,SETB ,MOV ,JC, JNC, JB, JNB ,JBC, ANL, ORL,CPL
Program Branching Instructions
The last group of instructions in the 8051 Microcontroller Instruction Set are the
Program Branching Instructions. These instructions control the flow of program
logic. The mnemonics of the Program Branching Instructions are as follows.
 LJMP ,AJMP, SJMP, JZ, JNZ, CJNE, DJNZ, NOP, LCALL, ACALL, RET,
RETI, JMP

8. Table 1. Similarities and the differences of 8085 microprocessors and 8051


microcontroller

S. In 8085 microprocessors In 8051 microcontroller
No.
1 RAM, ROM, timers, serial port and four CPU, 128 bytes of RAM, 4K bytes of on
ports (each 8 chip ROM, two
bits wide) all are connected externally to timers, one serial port and four ports (each 8
the CPU. Therefore it is a general purpose bits wide) all on a single chip. Therefore it a
microprocessor microcontroller.
2 8- bit processor 8- bit processor
3 The total addressing capability of a CPU The total addressing capability of a CPU is
is 216 bytes = 64 Kilo bytes, 1 Kilo = 216 bytes = 64 Kilo bytes, 1 Kilo = 1024 in
1024 in computers. The address computers. The address are
locations are from 0000 to FFFFH from 0000 to FFFFH

4 8-bit Accumulator, which is associated 8-bit Accumulator is closely associated with


with ALU. Bit ALU. Its
accessible registers are not available in location is E0H of RAM. It is also a bit
8085. accessible register
5 Six 8-bit general purpose registers. They It has four banks of registers and each bank
are B, C, D, E, H and L. To hold a 16-bit has eight 8-bit registers R0, R1, R2, R3, R4,
data a combination of two 8-bit registers R5, R6 and R7. Data bits D4 and D3 of
can be employed. The valid register pairs PSW are used to select the desired register
are BC, DE and HL. The system monitor bank.
utilizes RAM locations 8F90H to 8FFFH First 32 bytes of 128 bytes of RAM are set
for Stack and variables. aside for the register banks and the stack.
6 Size of Program Counter is 16 bits. It Size of Program Counter is 16 bits. It keeps
keeps track of memory addresses of the track of memory addresses of the instructions
instructions in a program. in a program.
7 Size of Stack Pointer is 16 bits. Generally Size of Stack Pointer is 8 bits. By default,
highest addresses of the memory can be 07th location of RAM is acts as SP. 30H-7FH
used as stack. of RAM can be used as stack.
8 The HL pair is used to act as memory The 16 bit data pointer (DPTR) to hold 16-
pointer and it holds the 16 bit address of a bit address. It consists of DPH and DPL to
memory location hold 8-bit data.
9 The five status flags are available in 8 bit 8-bit Program status word (PSW) register
Flag register as shown below. They are contains program status information as
Carry, Parity, Axiallary Carry, Zero and shown below:
Sign Flags.
C A F0 RS RS O - P
S Z X A X P X C Y C 1 0 V -
C Y
Program status word is the combination of Only 4 flag bits Carry, Axiallary Carry,
Flag register and Accumulator. It is a 16 bit Overflow and Parity flags and RS1&RS0
register and it is used to store the flag bits are used to select the bank of
conditions in the Stack memory. registers. PSW is a bit accessible register
and its bits are accessed as PSW.0 –
PSW.7
10 Instruction register holds the opcode of There are number of special function
the instruction which is decoded and registers (SFRs). The locations of SFRs
executed. Temporary register associated are from 80H – FFH of RAM. A, B, PSW
with ALU holds data during an and DPTR are part of SFRs. The SFRs
arithmetic / can be accessed by
logical operation. It is used by the their names or by their addresses. Some
processor and not accessible to of the SFRs have the capability of single
programmer. bit accessibility.
11 Interrupts: The five interrupts with their The six interrupts and their interrupt
service routines on their priority are service routines on their priority are as
TRAP → 0024H; RST 7.5→ 003CH; RST follows: Reset →
6.5→ 0034H; RST 5.5→ 002C, 0000H, External hardware interrupt 0
INTR→ It is sampled by the (INT0) → 0003H
microprocessor in the last state of the last
machine cycle of each instruction. The Timer 0 interrupt (TF0) → 000BH,
RST n instructions are used for software External hardware interrupt 1 (INT1)
interrupt.
→ 0013H, Timer 1 interrupt (TF1) →
001BH, Serial COM interrupt (RI and TI)
→ 0023H

12 The device has 40 pins requires +5V Available in 40 pin, in which 32 pins are
single power supply, operate with a 3 reserved for 4 multiplexed address and
MHz single phase clock. All signals data ports (Port 0. Port 1, Port 2 and
classified in 6 groups(i) Address bus (ii) Control port) and 2 pins for power supply,
Multiplexed data bus (iii) Control and 2 pins for XTAL oscillator, 1 ALE pin to
status signals select address or data
(iv) Power supply&frequency signals (v) through ports, 𝐸̅ 𝐴̅ for external access, 𝑃̅ ̅𝑆̅𝐸̅
̅𝑁̅ for external program memory and RST
External initiated signals and (vi) Serial for resetting the device
input and output ports.

9. SIMILARITIES AND DIFFERENCES IN ASSEMBLY LANGUAGE


PROGRAMS OF 8085 AND 8051:
The assembly language program of 8085 microprocessor is appeared in five
field format (7). The address field, opcode field, Label field, mnemonic field and
the comments/ description field. But the assembly language program of 8051 can
be appeared as four field format only.

The Assembly language program for 16 bit addition and multiplication of two
hexa-decimal numbers for both 8085 and 8051 were given Table 4.
Table 4. The similarities and differences in assembly language programs of
8085 and 8051

Assembly language programs of 8085 Assembly language programs of 8051


microprocessors microcontroller
1. To write and execute an ALP of 8085 1. To write and execute an ALP of 8051 to add
microprocessor to add two 16 bit data, stored two 16 bit data, stored from the RAM memory
from the memory locations 8050H using locations 50H and store the result in next
Double Addition (DAD) instruction. The memory. The program is given below: ORG
program is given below: 8000 ; origin address of the program
Addre Opc Lbl Mnemonic Comment Addr Lbl Mnemonic Comments
ss ode s
8000 2A,5 LHLD (HL) = 8000H MOV ;(R3) = 00
H 0,80 8050H (8050H) 8002H ;(R0)=50H=LB of
8003 EB XCHG (DE) ↔ R3,#0
H (HL) 8004H MOV D1
8004 2A,5 LHLD (HL) = 8005H ; (A)= LB of D1
H 2,80 8052H (8052H) R0,#50H
8007 0E,0 MVI C,00 (C) = 00, 8006H MOV ;(R0)=51H= LB
H 0 8007H of D2
8009 19 DAD D (HL)=(HL 8008H A,@R0
H ) + (DE) INC R0 ; (A) = (A) +
800A D2,0 JNC NEXT If CY=0, 8009H
H E,80 to nxt ADD (51H)
800AH ; (R2) = Sum of
800D 0C INR C If A,@R0
H CY=1,stor 800BH LBs
e in C 800CH MOV ;(R0)=52H=HB of
800E 22,0 SHLD (HL) R2,A INC D1
H E,80 8054H stor 800EH
ed in R0 MOV ; (A)= HB of
8054H & 800FH
A,@R0 Data1
8055H 8010H
8011 79 NEXT: MOV A,C (A) = (C) INC R0 ;(R0)=53H=HB of
H = CY 8011H
ADDC D2
8012 32,5 STA 8056H (A)=(805 8012H
H 6,80 6H)= CY A,@R0 ;(A)=(A) + (53H)
8015 76 HLT Halt the 8013H
8014H JNC NXT + CY
H program
8015H NXT: INC ;If CY=0, jump to
In the 8085 program, the first 16 bit data is R3 nxt
stored in 8050H & 8051H ; If CY=1, store in
and second 16 bit data is stored in 8052H & INC
8053H locations. R0 R3
In the 8051 program, LB stands for Lower byte ;(R0) = 54H
and HB stands for MOV
Higher byte. The lower bytes of two 16 bit data @R0,R2 ; (54H) = Sum of
are stored in 50H and LBs
51H and higher bytes are stored in 52H and INC R0
53H. If the instruction MOV ;(R0) = 55H
MOV @R0,RX is not working, first transfer ; (54H) = Sum of
RX to A and then @R0,A
transfer to the RAM memory and vice versa. INC R0 HBs
MOV ;(R0) = 56H
; (56H) = CY
@R0,R3 condition
LCALL ; End of the
0003 program
2. To write and execute an ALP of 8085 2. To write and execute an ALP of 8051 to
microprocessor to multiply two 8 bit data’s multiply two 8 bit data’s stored in 50H the
stored in 8050H the program is given below: program is given below:
Addre Op Label Mnemonic Comment Address Lab Mnemonic Comments
ss code s el
8000 LXI (HL)=(80 8000H MOV ;(R0)=50H=
H H,8050H 50H) R0,#50H Data1
8003 MVI B,00 (B) = 00, 8002H MOV ; (A)= Data1
H for CY A,@R0
8005 MOV A,B (A) = 00 8003H INC R0 ;(R0)=51H=
H Data2
8006 MOV C,M (C) = 8004H MOV ; (B)= Data2
H Data 1 0F0,@R0
8007 INX H (HL)=(80 8006H MUL AB ; (A) = (A) x (B)
H 51H)
8008 MOV D,M (D) = 8007H INC R0 ;(R0)=52H
H Data 2
8009 BCK: ADD D (A) = (A) 8008H MOV ;(52H) = LB of
H + (D) @R0,A product
800A JNC NXT If CY=0, 8009H INC R0 ;(R0)=53H
H to NXT
800DH INR If 800AH MOV ;(53H) = HB of
@R0,0F0
800EH NXT: B CY=1,st 800CH LCALL product
DCR ore in B 0003 ; End of the
program
C Decreme
nt C
800FH JNZ BCK If C≠0, to
BCK
Because of MUL AB instruction, the execution
8012 INX H (HL) = of multiplication program is easier with 8051
H 8051H
8013 MOV M,A (8051H) = microcontroller than 8085 microprocessor. It
H Product
8014 INX H (HL) = saves the memory space of the central processing
H 8052H unit
8015 MOV M,B (8052H) =
H CY
8016 HLT Halt the
H program

You might also like