7/25/2019 LCM AND HCF.pdf
1/87
7/25/2019 LCM AND HCF.pdf
2/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Contents CHAPTER 1: INTRODUCTION ............................................. 5
1. WELCOME ................................................................... 51.2 PS 8051 BOARD OVERVIEW ................................... 6
1.3 PS 8051 SPECIFICATIONS ....................................... 7
CHAPTER 2: SYSTEM DESCRIPTION ................................ 9
2.1 HARDWARE ............................................................... 9
2.2 MAPPING OF DEVICES............................................. 11
2.2.1 CONNECTOR DETAILS ........................................ 11
2.3 POWER SUPPLY DETAILS ......................................... 16
2.4 KEYBOARD DETAILS................................................. 16
CHAPTER 3 COMMANDS AND KEYS ............................. 173.1 RESET ...................................................................... 17
3.2 H (Help Menu) ........................................................ 17
CHAPTER 4 OPERATING INSTRUCTIONS ....................... 18
4.1 POWER ON .............................................................. 18
4.2 PROGRAM ENTRY USING ASSEMBLER: ................... 19
4.3 ENTERING MNEMONICS ......................................... 20
4.4 DISASSEMBLER ........................................................ 24
7/25/2019 LCM AND HCF.pdf
3/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4.5 M (MODIFY EXTERNAL MEMORY): ......................... 26
4.6 G (GO COMMAND) ................................................. 28
4.7 B (BAUD RATE) ........................................................ 29
4.8 R (REGISTER DISPLAY/MODIFY) .............................. 30
4.9 I (Modify internal memory) .................................... 33
4.10 T (TRANSFER COMMAND) .................................... 33
4.11 N (LOCAL MODE) ................................................... 35
4.12 E (EXAMINE / DUMP MEMORY) ............................ 354.13 PROGRAMMING THE 8051 TRAINER KIT: ............. 36
PROCEDURE 1: TO ENTER THE MNEMONICS ................ 36
PROCEDURE 2: TO ENTER THE OPCODE ..................... 37
CHAPTER 5 PROGRAMMING DETAILS .......................... 40
5.1 REGISTERS: .............................................................. 40
5.2 MONITOR PROGRAM: ............................................. 41
5.3 BREAKPOINT: .......................................................... 42
CHAPTER 6: EXAMPLE PROGRAMS ................................. 44
6.1 32 BIT ADDITION .................................................. 44
6.2 32 BIT SUBTRACTION .............................................. 47
6.3 32 BIT BCD ADDITION ............................................. 49
6.4 FIBONACCI SERIES ................................................... 52
7/25/2019 LCM AND HCF.pdf
4/87
Join the Technical Community Today!
http://www.pantechsolutions.net
6.5 HEX TO ASCII CONVERSION .................................... 54
6.6 PORT BITS SELECTION ............................................. 56
6.7 CHARACTER TRANSMISSION ................................... 58
6.8) ADDITIONAL PROGRAMS ON 8051 TRAINER KIT ... 60
1. 8-BIT ADDITION: ..................................................... 60
2. 8-BIT SUBTRACTION: .............................................. 61
4. SETTING BITS IN AN 8-BIT NUMBER: ...................... 62
5. MASKING BITS IN AN 8-BIT NUMBER: .................... 63
7/25/2019 LCM AND HCF.pdf
5/87
Join the Technical Community Today!
http://www.pantechsolutions.net
CHAPTER 1: INTRODUCTION
1. WELCOME
Thank you for purchasing PS-8051 Board from
Pantech Solutions Pvt Ltd . The PS-8051 board which
demonstrates the capabilities of the 40-pin 8051 (various
families) Sample programs are provided to demonstrate
the unique features of the supported devices.
The PS-8051 Board Kit comes with the following:
1) PS-8051 Board
2) Sample device (NXP 89V51RD2)
3) Cross cable ( RS232)
4) CD-ROM, which contains:
Sample programs
User and Technical Reference Manual
5) User and Technical Reference Manual
6) Keyboard (101 keys)
7/25/2019 LCM AND HCF.pdf
6/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Note : If you are missing any part of the kit, please
contact our support executive
1.2 PS 8051 BOARD OVERVIEW
The PS 8051 board in based on Intel 8051
Microcontroller which operates at 11.0592 MHZ . the
board can operate using the 101/104 PC keyboard
supplied along with the trainer kit and 2 line by 16characters LCDdisplay or from the PC (using the Terminal
Emulation Software). PS 8051 is equipped with
7/25/2019 LCM AND HCF.pdf
7/87
Join the Technical Community Today!
http://www.pantechsolutions.net
powerful software monitor in 27C256 EPROM. Keyboard
and LCDdisplay. The board has 32KB CMOS static RAM
(type 62256 ). PS
8051 works on +9V DCat 1 Amp.
1.3 PS 8051 SPECIFICATIONS
The PS 8051 board has the following hardware
features:
1. 8051 Microcontroller operating at 11.0592MHZ .
2. 32KB powerful software monitor in 27C256
EPROM.
3. 64KB on chip Flash memory (partially used by
Firmware).
4. Two 16 bit programmable on chip Timer.
5. 30 Programmable I/O pins (24 from 8255 and 6
(P1.0 to P1.5) from Port 1 of 8051).
6. 50 pin FRCconnector for system bus expansion.
7/25/2019 LCM AND HCF.pdf
8/87
Join the Technical Community Today!
http://www.pantechsolutions.net
7. 20 pin FRCconnector for user interface from
8255.
8. 9 pin D type connector for RS 232C interface.9. Six different selectable baud rates from 150 to
9600.
10. One timer and external interrupt.
11. 101 PC type keyboard for entering user
address/data and for commands.
12. Built in line by line Assemble and
Disassemble .
13. User friendly software monitor for loading and
executing programs with break point facility.
14. Facility to connect to PC.
15. PS-8051 board supports Assembly and C
language
7/25/2019 LCM AND HCF.pdf
9/87
Join the Technical Community Today!
http://www.pantechsolutions.net
CHAPTER 2: SYSTEM DESCRIPTION
2.1 HARDWARE
PS 8051 Microcontroller board designed around
8051 is ideal for learning about Microcontroller. The
Microcontroller operates at 10 MHZ using a 11.0592
MHZ crystal. Lower bytes of address and data are
multiplexed as in 8085 and hence a decoder is necessary
to separates address and data. IC 74LS373 is used for
this purpose.
Firmware is stored in 27C256 EPROM . User
data/program can be stored in 32KB COMS static RAM of
type 62256. The board uses an 8255 totally available to
the user.
2X16 character LCDdisplay is directly connected to the
bus like a memory device. Serial communication is
7/25/2019 LCM AND HCF.pdf
10/87
Join the Technical Community Today!
http://www.pantechsolutions.net
achieved using 8051 . This is possible when the
Microcontroller is operating in alternate mode. In this
mode, port pins 3.0 and 3.1 act as receive and transmitpins respectively.
Timer 1 is used for generating the baud clock. IC Max 232
convert TTL transmit and receive signals to RS 232 levels.
These signals are brought to a 9 pin D type connector
(female). 8051 has built in 16 bit counter/timer called
timer 0 and 1.
Timer 1 is used internally by the system for generating
the baud clock. Timer 0 is free and hence can be used by
the user.
8051 has following interrupt :
Timer 0 and 1 interrupts.
7/25/2019 LCM AND HCF.pdf
11/87
Join the Technical Community Today!
http://www.pantechsolutions.net
External interrupts 0 and 1.
Serial interrupt.
Out of the 5 interrupts listed above external interrupt 0
and timer 0 are available to the user.
2.2 MAPPING OF DEVICES
2.2.1 CONNECTOR DETAILS
1) 50 PIN EXPANSION CONNECTOR :
7/25/2019 LCM AND HCF.pdf
12/87
Join the Technical Community Today!
http://www.pantechsolutions.net
The 50 Pin FRC connector is used to interconnect withthe Interface cards like 8255, 8279, 8253/8251,8259,8257 and the pin details are given below
7/25/2019 LCM AND HCF.pdf
13/87
Join the Technical Community Today!
http://www.pantechsolutions.net
2) 20 PIN EXPANSION CONNECTORS :
The 20 Pin FRC connector is used to interconnect with the
Interface cards like ADC, DAC, SWITCH/LED,RELAY buzzer
Interfaces etc. P in details are given below
7/25/2019 LCM AND HCF.pdf
14/87
Join the Technical Community Today!
http://www.pantechsolutions.net
3) KEYBOARD CONNECTOR :
7/25/2019 LCM AND HCF.pdf
15/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4) 9PIN D TYPE (FEMALE) :
5) LCD CONNECTOR
7/25/2019 LCM AND HCF.pdf
16/87
Join the Technical Community Today!
http://www.pantechsolutions.net
2.3 POWER SUPPLY DETAILS
PS trainer kit will work at 0 9v (1 amp) from the PS
power supply. Provision is made in PS power supply to
bring out on the front panel DC regulated voltage output
for interfacing with add-on cards.
+9V 1 amp
2.4 KEYBOARD DETAILS
101 PC type keyboard is interfaced to Microcontroller
through its port pin. Communication between
keyboard and Microcontroller takes place using 2 wires
one for serial clock and serial data (P1.6 and P1.7).
7/25/2019 LCM AND HCF.pdf
17/87
Join the Technical Community Today!
http://www.pantechsolutions.net
CHAPTER 3 COMMANDS AND KEYS
3.1 RESET
This key is located in the main PS board. On depressing
this key the program starts executing from the beginning
i.e. at reset address 0000. On power on reset message PS
8051 is displayed in local LCD display.
3.2 H (Help Menu)
This key is used in PS 51/31 to get into help menu and
it will display the following commands.
7/25/2019 LCM AND HCF.pdf
18/87
Join the Technical Community Today!
http://www.pantechsolutions.net
CHAPTER 4 OPERATING INSTRUCTIONS
4.1 POWER ON
Connect the PS 8051 board to the power having the
following specifications.
+9V DC 1 Amp
7/25/2019 LCM AND HCF.pdf
19/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Switch on the power supply after ensuring the correct
voltages. Following message will appear on the LCD
display.
On power on or after reset the display shows PANTECH
8051 as a sign on message. The prompt character is
displayed in the next line informing the user, that the
board is ready to accept the commands.
4.2 PROGRAM ENTRY USING ASSEMBLER:
PS 8051 is ready to accept the assembler entry
command after power on or after reset. Commands can
be entered in the second line of display and to enter intoassembler from where the user program gets stored.
7/25/2019 LCM AND HCF.pdf
20/87
Join the Technical Community Today!
http://www.pantechsolutions.net
In PS 8051, the user may enter the program from
8000H FFFFH(if 32KB RAM is installed).
EXAMPLE:
A8500 Press ENTER Key
On typing this line PS-8051B is ready to store the user
program from start address 1100. Following message
shows in local LCD.
4.3 ENTERING MNEMONICS
As mentioned before, each instruction of Microcontroller
can be entered by specific set of characters generally
2/3/4 letters followed by respective operands.
List of instruction and mnemonics are given in the
Appendix A.
7/25/2019 LCM AND HCF.pdf
21/87
Join the Technical Community Today!
http://www.pantechsolutions.net
EXAMPLE:
MOV A, R0 (ENTER key = )
Sequence for entering the above instruction is as follows.Typing sequence,
M
O
V
Space bar
A
,
R
0
Enter key
EXAMPLE:
INC A Press ENTER Key
7/25/2019 LCM AND HCF.pdf
22/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Typing sequence,
I
NC
Space bar
A
Enter key (ENTER Key )
As per the above procedure mnemonics are entered. On
completion of one line address, display in the first line
automatically gets incremented by respective value
depending on the instruction.
Line by line assembler converts the entered mnemonics
to equivalent opcode and stores it in the displayed
address. If any wrong mnemonics or operands are
entered ERROR message is displayed.
7/25/2019 LCM AND HCF.pdf
23/87
Join the Technical Community Today!
http://www.pantechsolutions.net
On completion of one line of entry, the user may repeat
the above sequence of operation till the program is over
or till the end of memory. Termination of Assemblerentry is by depressing enter key.
IMPORTANT INSTRUCTIONS
1. When immediate addressing mode is used before
entering the data, # symbol should be entered for
instruction like,
MOV A, #12
MOV DPTR, #1234
2. When register indirect addressing mode is used @
symbol to entered for instruction like,
MOV A, @DPTR
MOV A, @R0
7/25/2019 LCM AND HCF.pdf
24/87
Join the Technical Community Today!
http://www.pantechsolutions.net
EDITING
During the entry of mnemonics if any wrong entry ismade it is possible to edit it before depressing Enter key.
Use the Backspace key in the keyboard to erase the
previous character and this process may be repeated till
the first character. Once a character is erased, retype the
correct character.
4.4 DISASSEMBLER
Disassemble converts the hex byte stored in the memory
into equivalent mnemonics. To enter into disassemble
mode, type D in the command mode followed by the
memory address.
EXAMPLE:
7/25/2019 LCM AND HCF.pdf
25/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Assume the following data is stored in the memory
address 8500.
To disassemble the above data is,
D8500 [Enter]
On completion of this command, the display is as follows,
8500 74 AA MOV A, #AA
To see the next line depress space bar key. Display is,
8502 00 NOP
In similar manner, the above sequence may be repeated
and depressing the enter key can terminate this
command.
7/25/2019 LCM AND HCF.pdf
26/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4.5 M (MODIFY EXTERNAL MEMORY):
Using this command the user can display/modify any
external memory address.
ENTERING ADDRESS
After depressing this key, the system is ready to accept
from the keyboard and the board displays the data of the
selected memory address. Depressing any other non-hex
key results in error and the current command and once
again waits for new command.
ENTERING DATA
Now, if required, entering the new data can modify data
at the desired address. Entry of data is also similar to that
of address. Terminator for data is cursor up key or cursor
down key or space or enter key. Thus it is possible to load
the opcode/data in memory and verify it using M
(MDFY), UP and DOWN keys.
7/25/2019 LCM AND HCF.pdf
27/87
Join the Technical Community Today!
http://www.pantechsolutions.net
EXAMPLE:
Thus it is possible to load the program/data in memoryand verify it using M (MDFY), UP and DOWN key.
7/25/2019 LCM AND HCF.pdf
28/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4.6 G (GO COMMAND)
This command is used to execute user program from thespecified address.
EXAMPLE:
EXAMPLE:G8850
7/25/2019 LCM AND HCF.pdf
29/87
Join the Technical Community Today!
http://www.pantechsolutions.net
The above command starts the program execution from
address 8850. If enter key is depressed immediately after
G, the program starts executing from the value specifiedin PC of R command. Thus all register values displayed in
R command are initial values for user program address.
4.7 B (BAUD RATE)
When this key is depressed it displays the currently
selected baud rate. Default baud rate is 2400 baud and
this will be selected during power on or hardware reset
and displayed in the first line. Second line display shows
150 baud. By depressing the space bar key the baud
display can be changed from 150 to 300 and so on till
9600. The system permits following baud rates.
{9600 2400 1200 600 300 and 150}
By depressing the enter key, the currently displayed baud
rate is selected fir future serial communication
(however,this will be modified if reset key is depressed).
7/25/2019 LCM AND HCF.pdf
30/87
Join the Technical Community Today!
http://www.pantechsolutions.net
NOTE: Space bar key doesnt select the baud rate and its
used to display the succeeding baud value only.
4.8 R (REGISTER DISPLAY/MODIFY)
When this key is depressed it displays current register
contents one after another. After depressing this key the
board waits for the register number and enter key from
the user.
If for example, key R2 depressed and then enter key the
system will display R2 contents.
As in the case of Modify, it is possible change the
displayed register contents. The entry is similar to that of
data filed entry. The termination for register data entry is
by space bar key.
7/25/2019 LCM AND HCF.pdf
31/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Entering space bar key increments register number and
its data is displayed once again. Thus it is possible to
display and modify all the sixteen registers. Terminationof this command is by enter key.
EXAMPLE:
If after depressing R, A is typed followed by enter this
command displays A value and waits for the user to enternew value.
7/25/2019 LCM AND HCF.pdf
32/87
Join the Technical Community Today!
http://www.pantechsolutions.net
If succeeding registers are to be modified use space key
to advance. Enter terminates the command. In the
following example, A register value to be changed to 33and R0 to 66.
EXAMPLE:
7/25/2019 LCM AND HCF.pdf
33/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4.9 I (Modify internal memory)
This command is similar to that of modify external except
it displays/modifies internal 128 bytes of 8051
Microcontroller. Use of UP, DOWN and ENTER keys are
also as described above. The example program is given
in chapter 6
Note: This command is one of the important command
used to Modify the internal memory of controller.
4.10 T (TRANSFER COMMAND)
This command is useful for transferring data from one
area to another. The user has to specify the source start
address, source end address and Destination start
address.
7/25/2019 LCM AND HCF.pdf
34/87
Join the Technical Community Today!
http://www.pantechsolutions.net
User can key in source start address and its delimiter
with space bar key. Source end address is also keyed in
similar way with space bar key as delimiter.
Next enter the Destination start address and is moved
from one area to another.
EXAMPLE:
T9000 90FF 9800 Press ENTER Key.
The above command transfer the memory content
starting from source start address 9000 to destination
start address 9800 till source end address 90FF is
reached.
Starting address 9000 End address 90FF End address 9800
7/25/2019 LCM AND HCF.pdf
35/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4.11 N (LOCAL MODE)
When this key is depressed on PC keyboard, the PS 8051 Kit starts working through local 101 keyboard.
Serial communication is disabled. Following message will
appear in the LCD display.
! NORMAL MODE !
4.12 E (EXAMINE / DUMP MEMORY)
This command will show the hex byte on the console
from the memory. This command requires start address
and end address. Its operates only the serial mode.
EXAMPLE:
E8500 85FF This will show hex bytes in the location
from 8500 to 85FF.
7/25/2019 LCM AND HCF.pdf
36/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4.13 PROGRAMMING THE 8051 TRAINER KIT:
PROCEDURE 1: TO ENTER THE MNEMONICS
1) Initially connect the 9V adaptor to J2 connector
2) Switch ON the PS-8051 kit using slide Switch SW1
3) PANTECH- 8051 will be displayed on the LCD 4) Connect the Keyboard in PS/2 connector
5) Depress A starting address of the program for
Ex: A8500
For ex: A8500 enter keyType the mnemonics MOV A,#12 press Enter key
Type the mnemonics ADD A,#12 press Enter key
and continue the same procedure till the end of
the Program
7/25/2019 LCM AND HCF.pdf
37/87
Join the Technical Community Today!
http://www.pantechsolutions.net
6) To verify the code depress D starting address and
depress space bar to see next memory location
For Ex: D8500 and press spacebar till the end of
the program
7) To execute the program Depress G staring
address for Ex: G8500.
8) To see the result depress M result address for
Ex: M8600.
9) To view the output in the Register depress R and
press enter key in keyboard.
PROCEDURE 2: TO ENTER THE OPCODE
Follow the same procedure till step 4
7/25/2019 LCM AND HCF.pdf
38/87
Join the Technical Community Today!
http://www.pantechsolutions.net
1) Depress M starting address of the program for Ex:
M8500
For ex: M8500 press enterType the opcode 74 space bar
Type the opcode 12 space bar and continue the
same till the end of the program
2) To view the code depress D starting address and
depress space bar to see next memory location
For Ex: D8500 and press spacebar till the end of
the program
3) To execute the program Depress G staringaddress for Ex: G8500.
7/25/2019 LCM AND HCF.pdf
39/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4) To see the result depress M result address for
Ex: M8600.
5) To view the output in the Register depressR
andpress enter key in keyboard
Note: 1) M is used for displaying the result, for Ex:
M8500
2) M is used to entering the Opcode.
3) M is used for entering the data.
Note : There are two ways to enter the program
1) Mnemonics method
2) Opcode method
Sample program is given to enter the program in both
the methods
7/25/2019 LCM AND HCF.pdf
40/87
Join the Technical Community Today!
http://www.pantechsolutions.net
CHAPTER 5 PROGRAMMING DETAILS
This chapter describes the technique for developing
program in PS 8051 board. For the development of
program it is essential to get familiar with the machine
code of 8051 Microcontroller or mnemonics of
instruction set.
5.1 REGISTERS:
From the programmers point of view 8051 has the
following register:
A or Accumulator used for all logical and arithmetical
operations.
B register (8 bit) used in multiply/divides instructions
only.
R0, R1, R2, R3, R4, R5, R6, and R7 register are
general-purpose registers.
7/25/2019 LCM AND HCF.pdf
41/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Program counter is 16 bit register capable of
addressing from 0000-FFFF
Stack pointer is an 8-bit register. It is initialized avalue of 70, please note the value of SP is
incremented by 1 or 2 (whereas SP decrements 1 or
2 in 8085 or Z80) depending on the type of
instructions. Also stack uses only internal 128 bytes
of memory.
Status/Flag register keeps track of flags.
5.2 MONITOR PROGRAM:
Monitor the program uses following areas:
Program EPROM : 0000 7FFF
External user RAM : 8000 8500 (for monitor
program variables).
Internal RAM : 256 bytes RAM 128 bytes
used by 8051 itself. Area from
40 to 6F is available for user.
7/25/2019 LCM AND HCF.pdf
42/87
Join the Technical Community Today!
http://www.pantechsolutions.net
User Interrupts : Timer 0 interrupt vectors to
address 800b.
External interrupt 0 vector to address 8003.(The user has to enable desired interrupts in his
program).
Chip select signals for user:
CS6 4040 405F CS7 4060 407F CS8 4080 409F CS9 40A0 40BF CS10 40C0 40DF
5.3 BREAKPOINT:
When writing program it is essential to debug them and
for this break points are necessary. Normally these are
achieved by using software Break points. However 8051
does not have any such facility. Other conventional
7/25/2019 LCM AND HCF.pdf
43/87
Join the Technical Community Today!
http://www.pantechsolutions.net
methods require extra hardware and hence these are
avoided in PS 8051 board.
Wherever break points are required they can be called
like subroutines. As soon as break point are called all the
register values are saved and displayed on the console or
in local display.
BREAK POINT SUBROUTINEADDRESS 00BB
It is possible to continue the program execution just by
depressing G and enter in local mode.
BREAK POINT DISPLAY IN LOCAL MODE:
7/25/2019 LCM AND HCF.pdf
44/87
Join the Technical Community Today!
http://www.pantechsolutions.net
When break point is encountered, all the register values
are saved and the Acc. Value is displayed in the LCD
display. Now use SPACE key to check register values oneby one.
BREAK POINT DISPLAY IN SERIAL MODE:
When break point is encountered, all the register values
are saved and all the register value will be displayed on
the console.
CHAPTER 6: EXAMPLE PROGRAMS
6.1 32 BIT ADDITION
FLOW CHART:
7/25/2019 LCM AND HCF.pdf
45/87
Join the Technical Community Today!
http://www.pantechsolutions.net
This program adds two 32 bit numbers.
First number is from 40h to 43h.
Second number is from 50h to 53h.
Result is from 60h to 63h.
NOTE: To enter the data in the internal memory, press
i and address then data.
Reset the kit and then enter, i0040 Press ENTER
Key.
7/25/2019 LCM AND HCF.pdf
46/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Then enter the data and press space bar from
keyboard for entering the next data
EX: i0040 FIRST DATA :40
address : 40 TO 43 MSB IN 40
EX: i0050 SECOND DATA : 50 address : 50 TO 53 MSB IN50
EX: i0060 RESULT DATA : 60 address : 60 TO 63 MSB IN60
PROGRAM:
ADDRESS
OPCODE MNEMONICS COMMENTS
8500 C3 CLR C Clear Carry flag 8501 E5 43 MOV A, 43 Move the 1st LSB data from ADDR 43 to
ACC
8503 35 53 ADDC A, 53 Add ACC with 2nd LSB data in ADDR 538505 F5 63 MOV 63,A Store the LSB data from ACC to ADDR 63 8507 E5 42 MOV A, 42 Move the 1st Mid Lowest data from ADDR
42 to ACC8509 35 52 ADDC A, 52 Add ACC with 2nd Mid Lowest data in
ADDR 52850B F5 62 MOV 62, A Store the Mid Lowest data from ACC to
ADDR 62850D E5 41 MOV A, 41 Move the 1st Mid Highest data from
ADDR 41 to ACC850F 35 51 ADDC A, 51 Add ACC with 2nd Mid Highest data in
ADDR 518511 F5 61 MOV 61, A Store the Mid Highest data from ACC to
7/25/2019 LCM AND HCF.pdf
47/87
Join the Technical Community Today!
http://www.pantechsolutions.net
ADDR 618513 E5 40 MOV A, 40 Move the 1st MSB data from ADDR 40 to
ACC8515 35 50 ADDC A, 50 Add ACC with 2nd MSB data in ADDR 50
8517 F5 60 MOV 60, A Store the MSB data from ACC to ADDR 60 8519 12 00 BB LCALL 00BB Break point
6.2 32 BIT SUBTRACTIONFLOW CHART:
7/25/2019 LCM AND HCF.pdf
48/87
Join the Technical Community Today!
http://www.pantechsolutions.net
This program subtracts two 32 bit numbers.
First number is from 40h to 43h.
Second number is from 50h to 53h.Result is from 60h to 63h.
NOTE: To enter the data in the internal memory, press
i and address then data.
Reset the kit and then enter, i0040 Press ENTER
Key.
Then enter the data and press space bar from
keyboard for entering the next data
EX: i0040 FIRST DATA : 40 address : 40 TO 43 MSB IN40
EX: i0050 SECOND DATA : 50 address : 50 TO 53 MSB IN50
EX: i0060 RESULT DATA : 60 address : 60 TO 63 MSB IN60
PROGRAM:
7/25/2019 LCM AND HCF.pdf
49/87
Join the Technical Community Today!
http://www.pantechsolutions.net
6.3 32 BIT BCD ADDITION
FLOW CHART:
7/25/2019 LCM AND HCF.pdf
50/87
Join the Technical Community Today!
http://www.pantechsolutions.net
This program adds 32 bit BCD numbers.
First BCD number is from 40h to 43h.
Second BCD number is from 50h to 53h.
Result is from 60h to 63h.
7/25/2019 LCM AND HCF.pdf
51/87
Join the Technical Community Today!
http://www.pantechsolutions.net
NOTE: To enter the data in the internal memory, press
i and address then data.
For Example: Reset the kit and then enter, i0040 Press
ENTER Key.
PROGRAM:
7/25/2019 LCM AND HCF.pdf
52/87
Join the Technical Community Today!
http://www.pantechsolutions.net
6.4 FIBONACCI SERIES
FLOW CHART
FIBONACCI SERIES (0, 1, 1, 2, 3, 5, 8, 13 ..) This program will generate the Fibonacci series
This will take input from the internal memory, 60h.
7/25/2019 LCM AND HCF.pdf
53/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Input = number of elements to be generate in the
series.
Output =elements of the series is stored in thememory.
Starting from 8F00h.
NOTE: To enter the data in the internal memory, press
i and address then data.
For Example: Reset the kit and then enter, i0060 Press
ENTER Key.
No = 40 Input count location Beg = 8F00 Output buffer start address
7/25/2019 LCM AND HCF.pdf
54/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROGRAM:
ADDRESS
OPCODE
MNEMONICS COMMENTS
8500 A8 60 MOV R0, 60 Move the no. of Fibonacci data into R08502 79 01 MOV R1, #01 Initialize 1 to R18504 7A 01 MOV R2, #01 Initialize 1 to R28506 74 00 MOV A, #00 Initialize 0 to ACC8508 90 8F 00 MOV DPTR,#8F00 Load output data to DPTR850B B8 00 03 CJNE R0, #00, 8511 If R0 is not equal to 0 then jump into
8511850E 02 85 1C LJMP 851C Long Jump into 851C 8511 F0 MOVX @DPTR, A Store ACC value into DPTR 8512 A3 INC DPTR Increment the DPTR8513 FA MOV R2, A Load the ACC value into R28514 29 ADD A, R1 Add ACC with R18515 85 02 01 MOV R1,R2 Copy value from R2(addr2) to R1 (addr1)8518 F0 MOVX @DPTR, A Store the new value from ACC to DPTR8519 A3 INC DPTR Increment DPTR851A D8 F7 DJNZ R0, 8513 If the count isnt equal to Zero, jump
back851C 12 00 BB LCALL 00BB Break point address
6.5 HEX TO ASCII CONVERSION
7/25/2019 LCM AND HCF.pdf
55/87
Join the Technical Community Today!
http://www.pantechsolutions.net
This program takes one HEX number (0 to F) then it will
convert that in to ASCII byte.user has entered any one of
the HEX number ( 0 to F).
7/25/2019 LCM AND HCF.pdf
56/87
Join the Technical Community Today!
http://www.pantechsolutions.net
INPUT : Enter the HEX value in external memory
location 8600.
OUTPUT : Result is stored in Accumulator and also inR1 register.
PROGRAM:
6.6 PORT BITS SELECTION
FLOW CHART:
7/25/2019 LCM AND HCF.pdf
57/87
Join the Technical Community Today!
http://www.pantechsolutions.net
In this port -1bit (p1.0) is set and cleared afterspecific intervalUsing bit wise operators
User can view the output on the first pin of 8051(i.e.,bit 0 of port1) in oscilloscope.
PROGRAM:
7/25/2019 LCM AND HCF.pdf
58/87
Join the Technical Community Today!
http://www.pantechsolutions.net
6.7 CHARACTER TRANSMISSION
Baud calculation
Baud rate = (1/32) *(OSCILATOR FREQ/(12*256))
7/25/2019 LCM AND HCF.pdf
59/87
Join the Technical Community Today!
http://www.pantechsolutions.net
0089 = tmod:equ 89h 008d = th1:
equ 8dh 008b = tl1:equ 8bh 088e = tr1:equ 8eh 0098 = scon:equ 98h 0099 = sbufequ 99h
PROGRAM:
7/25/2019 LCM AND HCF.pdf
60/87
7/25/2019 LCM AND HCF.pdf
61/87
7/25/2019 LCM AND HCF.pdf
62/87
Join the Technical Community Today!
http://www.pantechsolutions.net
INPUT:
8501 = 0A8504 = 88
RESULT:
8600 = 50 (LSB)
8601 = 05 (MSB)
4. SETTING BITS IN AN 8-BIT NUMBER:
INPUT:
8501 = 2F
8503 = 45
RESULT:
8600 = 6F.
7/25/2019 LCM AND HCF.pdf
63/87
Join the Technical Community Today!
http://www.pantechsolutions.net
5. MASKING BITS IN AN 8-BIT NUMBER:
INPUT:
8501 = 87
8503 = 7E
RESULT:
8600 = 06.
1) 16-BIT ADDITION of two numbers:
OBJECTIVE:
To perform 16-bit addition of two 16-bit data using
indirect addressing and store the result in Memory.
7/25/2019 LCM AND HCF.pdf
64/87
Join the Technical Community Today!
http://www.pantechsolutions.net
THEORY:
As there is only one 16-bit Register in 89C51, 16-bitaddition is performed by using ADDC Instruction twice,
i.e. adding LSB first and MSB next.
GIVE INPUT TO THIS LOCATION:
8500 - F5; MSB of first 16 bit data 8501 - D5; LSB of
first 16 bit data
8502 - 43; MSB of second 16 bit data 8503 - 55; LSB of
second 16 bit data
RESULT:
8600 - MSB of result 8601 - LSB of result
PROGRAM
7/25/2019 LCM AND HCF.pdf
65/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROCEDURE
1. Enter the input data in memory location 8500 to 8503.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8600 & 8601. Change data and checkresult in 8600, 8601.
7/25/2019 LCM AND HCF.pdf
66/87
Join the Technical Community Today!
http://www.pantechsolutions.net
2) 16-BIT SUBTRACTION Of Two Numbers:
OBJECTIVE:
To perform 16-bit Subtraction of two 16-bit data using
indirect addressing and store the result in memory.
THEORY:
As there is only one 16-bit Register in 89C51, 16-bit
subtraction is performed by using subb Instruction.
GIVE INPUT TO THIS LOCATION:
8600 - MSB of first operand 8601 - MSB of second
operand
8602 - LSB of first operand 8603 - LSB of second
operand
7/25/2019 LCM AND HCF.pdf
67/87
Join the Technical Community Today!
http://www.pantechsolutions.net
RESULT:
8700 MSB 8701 LSB
PROCEDURE
1. Enter the input data in memory location 8600 to 8603.
7/25/2019 LCM AND HCF.pdf
68/87
Join the Technical Community Today!
http://www.pantechsolutions.net
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8700 & 8701. Change data and checkresult in 8700, 8701.
3) 8-BIT MULTIPLICATION of two numbers:
OBJECTIVE:
To perform 8-bit Multiplication of two 8-bit data using
indirect addressing and store the result In memory.
THEORY:
Using indirect addressing Multiply two 8-bit data.
GIVE INPUT TO THIS LOCATION:
8600 - Multiplicand
7/25/2019 LCM AND HCF.pdf
69/87
Join the Technical Community Today!
http://www.pantechsolutions.net
8601 - Multiplier
RESULT:
8700
PROCEDURE
1. Enter the input data in memory location 8600 to 8601.
2. Enter the above opcodes from 8500.
3. Execute the program.
7/25/2019 LCM AND HCF.pdf
70/87
Join the Technical Community Today!
http://www.pantechsolutions.net
4. Result stored in 8700 & 8701. Change data and check
result in 8700, 8701.
4) 8-BIT DIVISION of two numbers:
OBJECTIVE:
To perform 8-bit Division of two 8-bit data using indirect
addressing and store the result in memory.
THEORY:
Using indirect addressing divide two 8- bit datas.
GIVE INPUT TO THIS LOCATION:
8600 - Dividend.
8601 - Divisor.
RESULT:
8700 & 8701
7/25/2019 LCM AND HCF.pdf
71/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROGRAM
PROCEDURE
1. Enter the input data in memory location 8600 to 8601.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8700 & 8701. Change data and check
result in 8700, 8701
5) FACTORIAL OF A GIVEN NUMBER:
OBJECTIVE:
7/25/2019 LCM AND HCF.pdf
72/87
Join the Technical Community Today!
http://www.pantechsolutions.net
To find factorial of a given number .
PROGRAM
PROCEDURE
7/25/2019 LCM AND HCF.pdf
73/87
Join the Technical Community Today!
http://www.pantechsolutions.net
1. Enter the input data in memory location 8600.
2. Enter the above opcodes from 8500.3. Execute the program.
4. Result stored in 8600. Change data and check result in
8600.
6) MULTIPLY BY SHIFT AND ADD METHOD
OBJECTIVE:
Multiple of two 8-bit numbers using repeat addition
method.
PROGRAM
7/25/2019 LCM AND HCF.pdf
74/87
Join the Technical Community Today!
http://www.pantechsolutions.net
7/25/2019 LCM AND HCF.pdf
75/87
Join the Technical Community Today!
http://www.pantechsolutions.net
MEMORY DDRESS OPCODES MNEMONICS
8500 90 86 00 MOV DPTR,#8600H8503 E0 MOVX A,@DPTR8504 F8 MOV R0,A
8505 90 86 01 MOV DPTR,#8601H8508 E0 MOVX A,@DPTR8509 F9 MOV R1,A850A 7A 00 MOV R2,#00H850C 7B 08 MOV R3,#08H850E E9 LOOP: MOV A,R1850F 54 01 ANL A,#01H8511 FC MOV R4,A8512 BC 01 03 CJNE R4,#01H,LOOP18515 EA MOV A,R28516 28 ADD A,R08517 FA MOV R2,A8518 E8 LOOP1: MOV A,R0 8519 23 RL A851A F8 MOV R0,A 851B E9 MOV A,R1851C 03 RR A851D F9 MOV R1,A851E DB EE DJNZ R3,LOOP8520 90 87 00 MOV DPTR,#8700H8523 EA MOV A,R28524 F0 MOVX @DPTR,A8525 80 FE E: SJMP E
PROCEDURE
1. Enter the input data in memory location 8600 & 8601.
2. Enter the above opcodes from 8500.
7/25/2019 LCM AND HCF.pdf
76/87
Join the Technical Community Today!
http://www.pantechsolutions.net
3. Execute the program.
4. Result stored in 8700. Change data and check result in
8700.
7) LCM of a given numberOBJECTIVE
To find LCM of a given number.
PROGRAM
ORG 8500H
MEMORY ADDRESS OPCODES MNEMONICS8500 90 86 00 MOV DPTR,#8600H8503 E0 MOVX A,@DPTR 8504 F8 MOV R0,A8505 90 86 01 MOV DPTR,#8601H
8508 E0 MOVX A,@DPTR8509 F9 MOV R1,A850A 7D 00 MOV R5,#00H850C 7A 01 MOV R2,#01H850E C3 TOP1: CLR C850F EA MOV A,R28510 98 SUBB A,R08511 60 1B JZ TOPY8513 EA MOV A,R28514 99 SUBB A,R18515 60 17 JZ TOPY8517 E8 MOV A,R08518 8A F0 MOV B,R2851A 84 DIV AB851B E5 F0 MOV A,B
7/25/2019 LCM AND HCF.pdf
77/87
Join the Technical Community Today!
http://www.pantechsolutions.net
851D B4 00 0B CJNE A,#00H,TOPX8520 E9 MOV A,R18521 8A F0 MOV B,R28523 84 DIV AB8524 E5 F0 MOV A,B8526 B4 00 02 CJNE A,#00H,TOPX8529 EA MOV A,R2852A FD MOV R5,A852B 0A TOPX: INC R2852C 80 E0 SJMP TOP1852E ED TOPY: MOV A,R5852F 90 87 00 MOV DPTR,#8700H8532 F0 MOVX @DPTR,A8533 80 FE E: SJMP E
PROCEDURE
1. Enter the input data in memory location 8600 & 8601.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored in 8700. Change data and check result in
8700
8) HCF of a given number
OBJECTIVE
To find HCF of a given number.
7/25/2019 LCM AND HCF.pdf
78/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROGRAM
ORG 8500H
PROCEDURE
7/25/2019 LCM AND HCF.pdf
79/87
Join the Technical Community Today!
http://www.pantechsolutions.net
1. Enter the input data in memory location 8600 & 8601.
2. Enter the above opcodes from 8500.
3. Execute the program.4. Result stored in 8700 & 8701. Change data and check
result in 8700 & 8701.
9) MATRIX ADDITION
PROGRAM
ORG 8500H
MEMORY ADDRESSOPCODES
MNEMONICS
8500 90 86 00 MOV DPTR,#8600H
8503 E0 MOVX A,@DPTR8504 F5 F0 MOV B,A8506 90 86 50 MOV DPTR,#8650H8509 E0 MOVX A,@DPTR850A 25 F0 ADD A,B850C 90 87 00 MOV DPTR,#8700H850F F0 MOVX @DPTR,A8510 90 86 01 MOV DPTR,#8601H8513 E0 MOVX A,@DPTR8514 F5 F0 MOV B,A8516 90 86 51 MOV DPTR,#8651H8519 E0 MOVX A,@DPTR851A 25 F0 ADD A,B851C 90 87 01 MOV DPTR,#8701H851F F0 MOVX @DPTR,A
7/25/2019 LCM AND HCF.pdf
80/87
Join the Technical Community Today!
http://www.pantechsolutions.net
8523 E0 MOVX A,@DPTR8524 F5 F0 MOV B,A8526 90 86 52 MOV DPTR,#8652H8529 E0 MOVX A,@DPTR852A 25 F0 ADD A,B852C 90 87 02 MOV DPTR,#8702H852F F0 MOVX @DPTR,A8530 90 86 03 MOV DPTR,#8603H8533 E0 MOVX A,@DPTR8534 F5 F0 MOV B,A8536 90 86 53 MOV DPTR,#8653H8539 E0 MOVX A,@DPTR853A 25 F0 ADD A,B853C 90 87 03 MOV DPTR,#8703H853F F0 MOVX @DPTR,A8540 80 FE E: SJMP E
PROCEDURE
1. Enter the input data in memory location 8600 & 8603.
2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored from 8700 & 8703.Change data and
check result in 8700 & 8703
10) FIBONACCI SERIES OF A NUMBER
OBJECTIVE:
7/25/2019 LCM AND HCF.pdf
81/87
7/25/2019 LCM AND HCF.pdf
82/87
Join the Technical Community Today!
http://www.pantechsolutions.net
11) SQUARE OF A GIVEN NUMBER
OBJECTIVE:
To find Square of a given number.
PROGRAM
12) SQUARE ROOT OF A GIVEN NUMBER
OBJECTIVE
To find Square root of a given number.
PROGRAM
7/25/2019 LCM AND HCF.pdf
83/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROCEDURE
1. Enter the input data in memory location 8600.2. Enter the above opcodes from 8500.
3. Execute the program.
4. Result stored from 8700 . Change data and check
result in 8700
7/25/2019 LCM AND HCF.pdf
84/87
Join the Technical Community Today!
http://www.pantechsolutions.net
13) LARGEST ELEMENT IN AN ARRAY:
OBJECTIVE:
To find the biggest number in an array of 8-bit unsigned
numbers of predetermined length.
EXAMPLE:
The length of the array is specified in the Register R5. The
array itself starts at 8600. The largest number of the
array is stored at location 860A.
Data : [8600] = 05
[8601] = 67 [8602] = 76
[8603] = 89 [8604] = 98
[8605] = 49 [8606] = 45
[8607] = 9F [8608] = 57
[8609] = 7A
Result :[860A] = 9F
7/25/2019 LCM AND HCF.pdf
85/87
Join the Technical Community Today!
http://www.pantechsolutions.net
PROGRAM
7/25/2019 LCM AND HCF.pdf
86/87
Join the Technical Community Today!
http://www.pantechsolutions.net
Pantech solutions creates information packedtechnical documents like this one every month. Andour website is a rich and trusted resource used by a
vibrant online community of more than 1,00,000members from organization of all shapes and sizes.
Did you enjoy the read?
7/25/2019 LCM AND HCF.pdf
87/87
What do we sell?Our products range from Various
Microcontroller development boards, DSP Boards,FPGA/CPLD boards, Communication Kits, Powerelectronics, Basic electronics, Robotics, Sensors,Electronic components and much more . Our goal isto make finding the parts and information you need
easier and affordable so you can create awesomeprojects and training from Basic to Cutting edgetechnology.