Contents. Join the Technical Community Today!

Similar documents
8051 Overview and Instruction Set

Microcontroller Intel [Instruction Set]

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

SN8F5000 Family Instruction Set

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

Module Contents of the Module Hours COs

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

MICROCONTROLLER AND PLC LAB-436 SEMESTER-5

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

8051 Microcontrollers

8051 Microcontroller


UNIT-III ASSEMBLY LANGUAGE PROGRAMMING. The CPU can access data in various ways, which are called addressing modes

1. Write A Program to move a block of data within the internal RAM

Microcontroller. Instruction set of 8051

Principle and Interface Techniques of Microcontroller

8051 Microcontrollers

8051 Microcontroller

Assembly Language programming (2)

ET2640 Microprocessors

Embedded Controller Programming

Question Bank Microprocessor and Microcontroller

C51 Family. Architectural Overview of the C51 Family. Summary

Q. Classify the instruction set of 8051 and list out the instructions in each type.

MODULE-1. Short Answer Questions

Introduction To MCS-51

Programming of 8085 microprocessor and 8051 micro controller Study material

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

Lecture 5. EEE3410 Microcontroller Applications Department of Electrical Engineering Assembly Language Programming (1)

8051 Single Board Monitor Programming. Minmon - Yeralan & Ahluwalia. PaulMon1 & PaulMon2 - Paul Stoffregen

Assembly Language programming (3)

TUTORIAL Assembly Language programming (2)

Microcontroller and Embedded Systems:

Practical Course File For

Digital Blocks Semiconductor IP

8051 Microcontroller Assembly Programming

8085 HOW-TO GUIDE Interfacing 8251 with 8085

EE6502- MICROPROCESSOR AND MICROCONTROLLER

CPEG300 Embedded System Design. Lecture 3 Memory

Digital Blocks Semiconductor IP

Principle and Interface Techniques of Microcontroller

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

Digital Blocks Semiconductor IP

MICROPROCESSOR & MICROCONTROLLER

Chapter Addressing Modes

Lab-Report Microprocessors

DR bit RISC Microcontroller. Instructions set details ver 3.10

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Microcontroller and Applications

EXPERIMENT NO.1. A Microcontroller is a complete computer system built on a single chip.

8051 microcontrollers

ESA 51 USER MANUAL. Electro Systems Associates Pvt Ltd

UNIT MICROCONTROLLER AND ITS PROGRAMMING

Dodatak. Skup instrukcija

VALLIAMMAI ENGINEERING COLLEGE

Control Transfer Instructions Jump, Loop, and Call. ECE473/573 Microprocessor System Design, Dr. Shiue

Three criteria in Choosing a Microcontroller

Instruction Set Of 8051

WINTER 14 EXAMINATION Subject Code: Model Answer Page No: 1/ 26

What Registers are available? Programming in Assembler. Assembler Programming - like early Basic. Assembler Data Movement Instructions

Assembly Language programming (1)

80C51 family programmer s guide and instruction set. 80C51 Family. PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization. Philips Semiconductors

MODEL ANSWER WINTER 17 EXAMINATION Subject Title: Microcontroller and applications

S.J.P.N Trust's. Hirasugar Institute of Technology, Nidasoshi.

Operating Manual Ver 1.1

Dragonchip. Instruction Set Manual

CS 320. Computer Architecture Core Architecture

TUTORIAL. Donal Heffernan University of Limerick May Tutorial D.Heffernan 2000,

~: Simple Programs in 8051 assembly language :~

ELEG3923 Microprocessor Ch.6 Arithmetic and Logics

Module I. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC.

Department of Electronics and Instrumentation Engineering Question Bank

The 8051 Microcontroller and Embedded Systems

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET


SOLUTION MANUAL FOR THE 8051 MICROCONTROLLER 4TH EDITION BY MACKENZIE AND PHAN

Application Brief D-005

8051 Instruction Set

MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller Subject Code:

JUMP, LOOP AND CALL INSTRUCTIONS

MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller and Applications Subject Code:

Vidyalankar T.E. Sem. V [ETRX] Microprocessors and Microcontrollers I Prelim Question Paper Solution

8051 Core Specification

C51 Family. C51 Family Programmer s Guide and Instruction Set. Summary

ENE 334 Microprocessors

ESA 31 USER MANUAL. Electro Systems Associates Pvt Ltd

EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER

MICROPROCESSOR LABORATORY MANUAL

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

8051 Microcontroller

MCS-51 Serial Port A T 8 9 C 5 2 1


CONTENTS. 1.0 Introduction Description of the Circuit Installation Connection of Power Supply 4

Timer-1 can be run using the internal clock, fosc/12 (timer mode) or from any external source via pin T1 (P3.5) (Counter mode).

Transcription:

Contents CHAPTER 1: INTRODUCTION... 5 1. WELCOME... 5 1.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... 17 3.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

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)... 35 4.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

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

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)

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 16 characters LCD display or from the PC (using the Terminal Emulation Software). PS 8051 is equipped with

powerful software monitor in 27C256 EPROM. Keyboard and LCD display. The board has 32KB CMOS static RAM (type 62256). PS 8051 works on +9V DC at 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 FRC connector for system bus expansion.

7. 20 pin FRC connector 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

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 LCD display is directly connected to the bus like a memory device. Serial communication is

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 transmit pins 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.

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 :

The 50 Pin FRC connector is used to interconnect with the Interface cards like 8255, 8279, 8253/8251,8259, 8257 and the pin details are given below

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. Pin details are given below

3) KEYBOARD CONNECTOR :

4) 9PIN D TYPE (FEMALE) : 5) LCD CONNECTOR

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).

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.

CHAPTER 4 OPERATING INSTRUCTIONS 4.1 POWER ON Connect the PS 8051 board to the power having the following specifications. +9V DC 1 Amp

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 into assembler from where the user program gets stored.

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.

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

Typing sequence, I N C 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.

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 Assembler entry 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

EDITING During the entry of mnemonics if any wrong entry is made 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:

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.

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 wait s 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.

EXAMPLE: Thus it is possible to load the program/data in memory and verify it using M (MDFY), UP and DOWN key.

4.6 G (GO COMMAND) This command is used to execute user program from the specified address. EXAMPLE: EXAMPLE: G8850

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 specified in 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).

NOTE: Space bar key doesn t select the baud rate and it s 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.

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. Termination of 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 enter new value.

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 33 and R0 to 66. EXAMPLE:

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.

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

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 from 8500 to 85FF. This will show hex bytes in the location

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-8051kit 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 key Type 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

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

1) Depress M starting address of the program for Ex: M8500 For ex: M8500 press enter Type 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 staring address for Ex: G8500.

4) To see the result depress M result address for Ex: M8600. 5) To view the output in the Register depress R and press 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

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 programmer s 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.

Program counter is 16 bit register capable of addressing from 0000-FFFF Stack pointer is an 8-bit register. It is initialized a value 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 program variables). Internal RAM : 8000 8500 (for monitor : 256 bytes RAM 128 bytes used by 8051 itself. Area from 40 to 6F is available for user.

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 CS7 CS8 CS9 CS10 4040 405F 4060 407F 4080 409F 40A0 40BF 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

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 SUBROUTINE ADDRESS 00BB It is possible to continue the program execution just by depressing G and enter in local mode. BREAK POINT DISPLAY IN LOCAL MODE:

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 one by 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:

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 Key. Press ENTER

Then enter the data and press space bar from keyboard for entering the next data EX: i0040 FIRST DATA : address : 40 TO 43 MSB IN 40 40 EX: i0050 SECOND DATA : 50 address : 50 TO 53 MSB IN 50 EX: i0060 RESULT DATA : 60 address : 60 TO 63 MSB IN 60 PROGRAM: ADDRES S 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 53 8505 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 ACC 8509 35 52 ADDC A, 52 Add ACC with 2nd Mid Lowest data in ADDR 52 850B F5 62 MOV 62, A Store the Mid Lowest data from ACC to ADDR 62 850D E5 41 MOV A, 41 Move the 1st Mid Highest data from ADDR 41 to ACC 850F 35 51 ADDC A, 51 Add ACC with 2nd Mid Highest data in ADDR 51 8511 F5 61 MOV 61, A Store the Mid Highest data from ACC to

ADDR 61 8513 E5 40 MOV A, 40 Move the 1st MSB data from ADDR 40 to ACC 8515 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 SUBTRACTION FLOW CHART:

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 IN 40 EX: i0050 SECOND DATA : 50 address : 50 TO 53 MSB IN 50 EX: i0060 RESULT DATA : 60 address : 60 TO 63 MSB IN 60 PROGRAM:

6.3 32 BIT BCD ADDITION FLOW CHART:

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.

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:

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.

Input = number of elements to be generate in the series. Output =elements of the series is stored in the memory. 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 Beg = 8F00 Input count location Output buffer start address

PROGRAM: ADDR OPCOD MNEMONICS COMMENTS ESS E 8500 A8 60 MOV R0, 60 Move the no. of Fibonacci data into R0 8502 79 01 MOV R1, #01 Initialize 1 to R1 8504 7A 01 MOV R2, #01 Initialize 1 to R2 8506 74 00 MOV A, #00 Initialize 0 to ACC 8508 90 8F 00 MOV DPTR,#8F00 Load output data to DPTR 850B B8 00 03 CJNE R0, #00, 8511 If R0 is not equal to 0 then jump into 8511 850E 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 DPTR 8513 FA MOV R2, A Load the ACC value into R2 8514 29 ADD A, R1 Add ACC with R1 8515 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 DPTR 8519 A3 INC DPTR Increment DPTR 851A D8 F7 DJNZ R0, 8513 If the count isn t equal to Zero, jump back 851C 12 00 BB LCALL 00BB Break point address 6.5 HEX TO ASCII CONVERSION

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).

INPUT : Enter the HEX value in external memory location 8600. OUTPUT : Result is stored in Accumulator and also in R1 register. PROGRAM: 6.6 PORT BITS SELECTION FLOW CHART:

In this port -1bit (p1.0) is set and cleared after specific interval Using bit wise operators User can view the output on the first pin of 8051(i.e., bit 0 of port1) in oscilloscope. PROGRAM:

6.7 CHARACTER TRANSMISSION Baud calculation Baud rate = (1/32) * (OSCILATOR FREQ/ (12*256))

0089 = tmod: equ 89h 008d = th1: equ 8dh 008b = tl1: equ 8bh 088e = tr1: equ 8eh 0098 = scon: equ 98h 0099 = sbuf equ 99h PROGRAM:

OUTPUT: connect the Cross cable between PC and KIT execute the program and verify the result in HyperTerminal 6.8) ADDITIONAL PROGRAMS ON 8051 TRAINER KIT EX1 programming using Arithmetic, Logical and Bit Manipulation instruction of 8051 1. 8-BIT ADDITION: INPUT: 8501 = 12 8503 = 12 RESULT: 8600 = 24.

2. 8-BIT SUBTRACTION: INPUT: 8501 = 20 8503 = 10 RESULT: 8600 = 10. 3. 8-BIT MULTIPLICATION:

INPUT: 8501 = 0A 8504 = 88 RESULT: 8600 = 50 (LSB) 8601 = 05 (MSB) 4. SETTING BITS IN AN 8-BIT NUMBER: INPUT: 8501 = 2F 8503 = 45 RESULT: 8600 = 6F.

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.

THEORY: As there is only one 16-bit Register in 89C51, 16-bit addition 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

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 check result in 8600, 8601.

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

RESULT: 8700 MSB 8701 LSB PROCEDURE 1. Enter the input data in memory location 8600 to 8603.

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. 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

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.

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 data s. GIVE INPUT TO THIS LOCATION: 8600 - Dividend. 8601 - Divisor. RESULT: 8700 & 8701

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:

To find factorial of a given number. PROGRAM PROCEDURE

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

MEMORY DDRESS OPCODES MNEMONICS 8500 90 86 00 MOV DPTR,#8600H 8503 E0 MOVX A,@DPTR 8504 F8 MOV R0,A 8505 90 86 01 MOV DPTR,#8601H 8508 E0 MOVX A,@DPTR 8509 F9 MOV R1,A 850A 7A 00 MOV R2,#00H 850C 7B 08 MOV R3,#08H 850E E9 LOOP: MOV A,R1 850F 54 01 ANL A,#01H 8511 FC MOV R4,A 8512 BC 01 03 CJNE R4,#01H,LOOP1 8515 EA MOV A,R2 8516 28 ADD A,R0 8517 FA MOV R2,A 8518 E8 LOOP1: MOV A,R0 8519 23 RL A 851A F8 MOV R0,A 851B E9 MOV A,R1 851C 03 RR A 851D F9 MOV R1,A 851E DB EE DJNZ R3,LOOP 8520 90 87 00 MOV DPTR,#8700H 8523 EA MOV A,R2 8524 F0 MOVX @DPTR,A 8525 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. 7) LCM of a given number OBJECTIVE To find LCM of a given number. PROGRAM ORG 8500H MEMORY ADDRESS OPCODES MNEMONICS 8500 90 86 00 MOV DPTR,#8600H 8503 E0 MOVX A,@DPTR 8504 F8 MOV R0,A 8505 90 86 01 MOV DPTR,#8601H 8508 E0 MOVX A,@DPTR 8509 F9 MOV R1,A 850A 7D 00 MOV R5,#00H 850C 7A 01 MOV R2,#01H 850E C3 TOP1: CLR C 850F EA MOV A,R2 8510 98 SUBB A,R0 8511 60 1B JZ TOPY 8513 EA MOV A,R2 8514 99 SUBB A,R1 8515 60 17 JZ TOPY 8517 E8 MOV A,R0 8518 8A F0 MOV B,R2 851A 84 DIV AB 851B E5 F0 MOV A,B

851D B4 00 0B CJNE A,#00H,TOPX 8520 E9 MOV A,R1 8521 8A F0 MOV B,R2 8523 84 DIV AB 8524 E5 F0 MOV A,B 8526 B4 00 02 CJNE A,#00H,TOPX 8529 EA MOV A,R2 852A FD MOV R5,A 852B 0A TOPX: INC R2 852C 80 E0 SJMP TOP1 852E ED TOPY: MOV A,R5 852F 90 87 00 MOV DPTR,#8700H 8532 F0 MOVX @DPTR,A 8533 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.

PROGRAM ORG 8500H 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 & 8701. Change data and check result in 8700 & 8701. 9) MATRIX ADDITION PROGRAM ORG 8500H MEMORY ADDRESS MNEMONICS OPCODES 8500 90 86 00 MOV DPTR,#8600H 8503 E0 MOVX A,@DPTR 8504 F5 F0 MOV B,A 8506 90 86 50 MOV DPTR,#8650H 8509 E0 MOVX A,@DPTR 850A 25 F0 ADD A,B 850C 90 87 00 MOV DPTR,#8700H 850F F0 MOVX @DPTR,A 8510 90 86 01 MOV DPTR,#8601H 8513 E0 MOVX A,@DPTR 8514 F5 F0 MOV B,A 8516 90 86 51 MOV DPTR,#8651H 8519 E0 MOVX A,@DPTR 851A 25 F0 ADD A,B 851C 90 87 01 MOV DPTR,#8701H 851F F0 MOVX @DPTR,A

8523 E0 MOVX A,@DPTR 8524 F5 F0 MOV B,A 8526 90 86 52 MOV DPTR,#8652H 8529 E0 MOVX A,@DPTR 852A 25 F0 ADD A,B 852C 90 87 02 MOV DPTR,#8702H 852F F0 MOVX @DPTR,A 8530 90 86 03 MOV DPTR,#8603H 8533 E0 MOVX A,@DPTR 8534 F5 F0 MOV B,A 8536 90 86 53 MOV DPTR,#8653H 8539 E0 MOVX A,@DPTR 853A 25 F0 ADD A,B 853C 90 87 03 MOV DPTR,#8703H 853F F0 MOVX @DPTR,A 8540 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:

To find Fibonacci series of a given number. PROGRAM 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 8601. Change data and check result in 8601

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

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

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

PROGRAM

Did you enjoy the read? Pantech solutions creates information packed technical documents like this one every month. And our website is a rich and trusted resource used by a vibrant online community of more than 1,00,000 members from organization of all shapes and sizes.

What do we sell? Our products range from Various Microcontroller development boards, DSP Boards, FPGA/CPLD boards, Communication Kits, Power electronics, Basic electronics, Robotics, Sensors, Electronic components and much more. Our goal is to make finding the parts and information you need easier and affordable so you can create awesome projects and training from Basic to Cutting edge technology.