You are on page 1of 42

Nirma University Institute Of Technology B.Tech. SEM.

VI (EC)

2EC314 Microcontroller Laboratory

Electronics & Communication Engineering Section Electrical Engineering Department

INSTITUTE OF TECHNOLOGY NIRMA UNIVERSITY, Ahmedabad

Laboratory Evaluation Method

Sr. No. 1. 2.

Type of Activity Practicals Lab Exam/Viva

No of Event 11 -

Evaluation Method Continuous evaluation Performance

Weightage 0.75* 0.25

* In continuous evaluation (10) practical carry 70% and project carry 30% of
the total .075 weigtage of continuous evaluation.

Text / Reference Books:


1. 2. The 8051 Micro controller Architecture Programming & Application, by K. J. Ayala, Penram International Publications. 8051 Micro controller and Embedded System, by MAZIDI &MAZIDI Pearson Education Publications.

2EC314 Microcontroller Laboratory

Page 2 of 42

2EC314 Microcontroller Laboratory

Index
Sr. No. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11 Title Study of 8051 microcontroller and Keil IDE. Write an Assembly language program for different addressing modes of 8051. Write an Assembly language program to perform Data Transfer and Memory Data/code fetching Operations. Write an Assembly language program to perform data manipulation using arithmetic Instructions. Write an Assembly language program to perform operation based on logical and compare instructions. Write an Assembly language program to perform Branching, Looping and Subroutine Operation. Write an Assembly language program to perform operation using Timer/Counter. Write an Assembly language program to toggle LED using Input Output Programming Write an Assembly language program to counter and display on 7-segment LED. (Use Timer/Counter) Write an Assembly language program to perform Serial Communication using UART Module. Develop a Microcontroller based project. Date Sign Grade

2EC314 Microcontroller Laboratory

Page 3 of 42

Exp No: 1
Aim: Study of 8051 microcontroller and Keil IDE.

Date:

Objective To understand basic architecture of 8051 microcontroller. To learn operating flow of Keil IDE. a) 8051 Architecture Intel introduced 8051, referred as MCS-51, in 1981.The 8051 is an 8-bit processor i.e. The CPU can work on only 8 bits of data at a time n Specifications of 8051 128 bytes of RAM 4K bytes of on-chip ROM Two timers One serial port Four I/O ports, each 8 bits wide 6 interrupt sources I/O pins 32 n The 8051 became widely popular after allowing other manufactures to make and market any flavor of the 8051, but remaining code-compatible. n 8051 follows Harvard architecture. Basic Block diagram of 8051

2EC314 Microcontroller Laboratory

Page 4 of 42

Architecture of 8051

8051 architecture contains the following o 8 bit CPU with registers A and B o 16 bit program counter (PC) and data pointer (DPTR) o 8 bit Program Status Word (PSW) o 8 bit Stack Pointer o Internal ROM of 0(8031) to 4K(8051) o Internal RAM of 128 Bytes n 4 register banks 00-1f (RB0 to RB3) n 16 bytes (bit addressable) 20-2f
2EC314 Microcontroller Laboratory Page 5 of 42

o o o o o o Registers o o o o

n 80 bytes of general purpose data memory 30-7f 32 I/O pins arranged as four 8 bit ports (P0 P3) Two 16-bit timer/counters: T0 and T1 Full duplex serial data receiver/ transmitter: SBUF Control registers: TCON, TMOD, SCON, PCON, IP and IE 2 external and 3 internal interrupt sources Oscillator and clock circuits 8 or 16 bit Each register (except PC) has internal 1 byte address assigned to it IP, IE, TCON, A, B, SCON, PSW, Port 0-4 are bit/byte addressable Specified with address/symbolic name

Special Function Registers (SFRs) o The Special Function Registers (SFRs) are used for special tasks o They should not be used for general purpose tasks o Each SFR occupies internal RAM from 0x80 to 0xFF (but some areas are empty!) o SFRs which are also bit addressable o A, B, IP, IE, TCON, SCON, PSW, P0, P1, P2, P3 o Other SFRs o TMOD, THO, TLO, TH1, TL1, SBUF, PCON, SP, DPTR o PC is not SFR 16 bit Program Counter (PC) and Data Pointer (DPTR) PC o Has memory address of next byte to be fetched o Incremented by 1 after each instruction DPTR o Two 8-bit registers DPH and DPL o Has memory address of internal/external code access and external data access o Under control of instructions, referred as DPTR/DPH/DPL (each has different address) A and B CPU Registers A (accumulator) o ALU operations and external moves B (general purpose) o With A for multiplication and division operation o Temporary storage

2EC314 Microcontroller Laboratory

Page 6 of 42

PSW and Flags

Internal ROM o For internal program code 0000h-0FFFh o PC goes from 0000h-FFFFh o Address higher than 0FFFh 8051 automatically fetches from external program memory (EA pin 31 to Gnd)

2EC314 Microcontroller Laboratory

Page 7 of 42

Internal RAM

Port Operations o Total 4 ports o Port 0 may serve as inputs, outputs, or as a low order address and data bus for external memory o Port 1 may be used as input/output port o Port 2 may be used as input/output or high order address byte o Port 3 may be used as an input/output and for some alternate function. Timers and Counters o Two timers, which can be controlled, set, read, and configured individually o The 8051 timers functions: n Count internal clk pulses-timer n Count external pulses-counter n Generating baud rates for the serial port

2EC314 Microcontroller Laboratory

Page 8 of 42

Addressing Modes o o o o o Immediate Register Direct Register Indirect Indexed

Pin Diagram of the 8051

2EC314 Microcontroller Laboratory

Page 9 of 42

b) Introduction of Keil IDE To write and run program in keil, follow the given steps. 1. Click on Vision from the Start menu and following window will open.

2. Select New Vision Project from the Project Menu.

2EC314 Microcontroller Laboratory

Page 10 of 42

3. Select New Vision Project from the Project Menu. Name that new project (here toggle has been selected as name) and save it as shown in following window.

4. Once you click on save button, select device for target window will pop up. Now select the device on which one want to write program. First one has to select manufacturer of IC and then select particular device. Here Atmel s part AT89V51 has been selected as shown in figure below.

2EC314 Microcontroller Laboratory

Page 11 of 42

5. After selecting particular IC, press ok, then following window will open and press No.

6. Create Source file to write program in Keil. To do that click on File menu and Select New as shown in figure below.

After selecting new, program editor will open as shown in figure below .

2EC314 Microcontroller Laboratory

Page 12 of 42

Now write your program in program window. For example, Program to toggle port 1 and port 2 with delay has been taken here.

7. After writing program, Click on File Menu and select Save As by giving .a51 extension. Here program has been saved with Toggle.a51. This is shown figure below.

2EC314 Microcontroller Laboratory

Page 13 of 42

8. Next step is to add the toggle.a51 to the project. Expand the Target 1 in the Tree menu, right click on Source Group 1 in the Tree menu and select Add files to Group Source Group 1.

Change file type to Asm Source File (*.a; *.src) then Select file (toggle.a51) and add it.

2EC314 Microcontroller Laboratory

Page 14 of 42

9. Expand the Source Group 1in the Tree menu to ensure that the file was added to the project.

Creating HEX File 1. Click on Target 1 in Tree menu. 2. Click on Project Menu and select Options for Target 1 as shown in figure.

2EC314 Microcontroller Laboratory

Page 15 of 42

3. Select Target Tab and Change Xtal (MHz) from 33.0 to 11.0592 as shown in figure below.

4. Now Select Output Tab from same window and click on create Hex file check box and press ok as shown in below.

2EC314 Microcontroller Laboratory

Page 16 of 42

5. Click on Project Menu and select Rebuild all Target Files. 6. In the Build Window it should report 0 Errors (s), 0 Warnings.

Testing Program in Debugger 1. Click on Debug Menu and Select Start/Stop Debug Session.

2EC314 Microcontroller Laboratory

Page 17 of 42

2.

If you use a free version of Keil the dialog appears. Click OK.

3. The Keil Debugger should be now running.

2EC314 Microcontroller Laboratory

Page 18 of 42

4. Click on Peripherals. Select I/O Ports, Select Port 1.

5. A new window should port will pop up. This represents the Port and Pins.

6. Step through the code by pressing F11 on the Keyboard. The Parallel Port 1 Box should change as one completely step through the code.

2EC314 Microcontroller Laboratory

Page 19 of 42

7. To exit, Click on Debug Menu and Select Start/Stop Debug Session. Learning Outcomes:

2EC314 Microcontroller Laboratory

Page 20 of 42

Exp No: 2

Date:

Aim: Write a Assembly language program for different addressing modes of 8051. Objective: To understand different types of addressing modes in 8051. Example Write a program to copy the value 55h into RAM location from 40h to 43h using different addressing mode of 8051. Immediate
ORG 0000H MOV 40H,#55H MOV 41H,#55H MOV 42H,#55H MOV 43H,#55H END

Direct
ORG 0000H MOV A,#55H MOV 40H,A MOV 41H,A MOV 42H,A MOV 43H,A END

Indexed
ORG 0000H MOV DPTR,#40H CLR A MOVC A,@A+DPTR MOV 40H,A CLR A INC DPTR MOVC A,@A+DPTR MOV 41H,A CLR A INC DPTR MOVC A,@A+DPTR MOV 42H,A CLR A INC DPTR MOVC A,@A+DPTR MOV 43H,A END

Register
ORG 0000H MOV R0,#55H MOV 40H,R0 MOV 41H,R0 MOV 42H,R0 MOV 43H,R0 END

Register Indirect
ORG 0000H MOV A,#55H MOV R1,#40H MOV @R1,A INC R1 MOV @R1,A INC R1 MOV @R1,A INC R1 MOV @R1,A END

Exercise: 1. Write a program to clear 16 RAM locations starting at RAM address 60H. 2. Transfer the contents of the register A, R0 and R1 respectively of bank 0 to the register B, R0 and R1; of bank 1 using stack operation. 3. The result of a signed arithmetic operation is stored in RAM location 27H. Verify if the stored result is positive or negative. If it is negative send a high value to P1.7, otherwise send a low value.
2EC314 Microcontroller Laboratory Page 21 of 42

Exp No: 3

Date:

Aim: Write an Assembly language program to perform Data Transfer and Memory Data/code fetching Operations. Objective To learn instructions to transfer data between register and memory and register to register. Exercise: 1. Write Instructions to use the registers of bank 3, and load the same value 05H in the registers R0 toR3. 2. Copy the data in internal RAM location 0123h to TL0 and the data in external RAM Location 0234h to TH0. 3. Exchange contents of memory location 21H and 22H using PUSH and POP. 4. Exchange the both the lower nibbles of R0 and R1; put the low nibble of R0 in R1 and low nibble of R1 in R0. 5. Copy the contents of external Code memory address 0040 to 1E.

2EC314 Microcontroller Laboratory

Page 22 of 42

Exp No: 4

Date:

Aim: Write an Assembly language program to perform data manipulation using arithmetic Instructions. Objective: To learn the instructions for arithmetic operations. Exercise: 1. Find the sum of the values 79H, F5H, E2H. Put the sum in registers R0 (low byte) and R5 (high byte). 2. Add the BCD number found in internal RAM locations 25h, 26h and 27h together and put the result in RAM locations 30h (MSB) and 31(LSB). 3. Multiply the unsigned number in register R3 by the unsigned number on port 2 and put the result in the external RAM locations 10h (MSB) and 11h (LSB). 4. Square the content of R5 and put the result in R0 (High Byte) and R1(low byte). 5. Divide the number in RAM location 15h by the data in RAM location 16h; put the result in external RAM location 7Ch.

2EC314 Microcontroller Laboratory

Page 23 of 42

Exp No: 5

Date:

Aim: Write program to perform operation based on logical and compare Instructions. Objective: To learn instruction related logic operation. To learn instructions to rotate data. Exercise: 1. OR the content of port 1 and port 2; put the result in external RAM location 0100h. 2. Count the number of ones in any number in register B and put the count in R5. 3. Write a program to check if the character string of length 7 stored in RAM location 50H onwards is a palindrome. If it is, output Y to P1. 4. If lower nibble of any number in A is larger than upper nibble set the Carry flag to 1, otherwise clear it.

2EC314 Microcontroller Laboratory

Page 24 of 42

Exp No: 6

Date:

Aim: Write an Assembly language program to perform operation based on logical and compare instructions. Objective: To learn instruction related branch and loop operation. Exercise: 1. Put a random number in R2 and another in R5. Increment R2 and decrement R5 until both become equal. 2. Random unsigned numbers are stored in register R0 to R4. Find the largest number and put it in R6. 3. Assume that register A has packed BCD. Write a program to convert packed BCD to two ASCII numbers and place them in R2 and R6.

2EC314 Microcontroller Laboratory

Page 25 of 42

Exp No: 7
Aim: Write an Assembly Timer/Counter. language program to

Date:
perform operation using

Objective: To To To To

understand different timer/Counter mode. learn the function of TCON (Timer Control) Register. be familiar with 8051 kit. learn loading of HEX file and Test program on 8051 kit.

Theory: 8051 has two timers/counters. They can be used as either Timers to generate a time delay or as event counter to count events happening outside the microcontroller. Both of them are 16 bits wide. Since 8051 has an 8-bit architecture, each 16-bits timer is accessed as two separate registers of low bytes and high bytes. The low byte register is called as TL0/TL1 and high byte register is called as TH0/TH1 as per selection of Timer0 or Timer1. Both timer 0 and 1 use the same register, called TMOD (timer mode), to set the various time operation mode. The construction of TMOD is given below:

2EC314 Microcontroller Laboratory

Page 26 of 42

. Example: Create a square wave of 50% duty cycle (with equal portions high and low) on the P1.5 bit. Timer 0 is used to generate the time delay. Analyze the program MOV TMOD,#01 HERE: MOV TL0,#0F2H MOV TH0,#0FFH CPL P1.5 ACALL DELAY SJMP HERE DELAY: AGAIN: SETB TR0 JNB TF0,AGAIN CLR TR0 CLR TF0 RET ;start the timer 0 ;monitor timer flag 0 ;until it rolls over ;stop timer 0 ;clear timer 0 flag ;Timer 0, mode 1(16-bit mode) ;TL0=F2H, the low byte ;TH0=FFH, the high byte ;toggle P1.5

In the above program notice the following step. 1. TMOD is loaded. 2. FFF2H is loaded into TH0-TL0. 3. P1.5 is toggled for the high and low portions of the pulse.
2EC314 Microcontroller Laboratory Page 27 of 42

4. The DELAY subroutine using the timer is called. 5. In the DELAY subroutine, timer 0 is started by the SETB TR0 instruction. 6. Timer 0 counts up with the passing of each clock, which is provided by the crystal oscillator. As the timer counts up, it goes through the states of FFF3, FFF4, FFF5, FFF6, FFF7, FFF8, FFF9, FFFA, FFFB, and so on until it reaches FFFFH. One more clock rolls it to 0, raising the timer flag (TF0=1). At that point, the JNB instruction falls through.

7. Timer 0 is stopped by the instruction CLR TR0. The DELAY subroutine ends, and the process is repeated. Notice that to repeat the process, we must reload the TL and TH registers, and start the process is repeated

How to calculate the amount of time delay in the DELAY with XTAL = 11.0592MHz ? Solution: The timer works with a clock frequency of 1/12 of the XTAL frequency; therefore, we have 11.0592 MHz / 12 = 921.6 kHz as the timer frequency.

As a result, each clock has a period of T = 1/921.6kHz = 1.085us. In other words, Timer 0 counts up each 1.085us resulting in delay = number of counts 1.085us. The number of counts for the roll over is FFFFH FFF2H = 0DH (13 decimal). However, we add one to 13 because of the extra clock needed when it rolls over from FFFF to 0 and raise the TF flag. This gives 14 1.085us = 15.19us for half the pulse. For the entire period it is T = 2 15.19us = 30.38us as the time delay generated by the timer.

2EC314 Microcontroller Laboratory

Page 28 of 42

Follow the given steps to load HEX file on board. 1. Open Flash Magic from the start menu. Following window will open.

2. Select Baud Rate 9600, then select device 89V51. 3. Click on Tools and select Terminal

2EC314 Microcontroller Laboratory

Page 29 of 42

3. After selecting that, following Terminal Setting window will open.

4. In the terminal in the Input section keep pressing U from the keyboard and reset the 8051 board, the input will be displayed in the output window thereafter. Now the board is in program mode and one can close this window. It is shown in following figure.

OR Do not connect peripheral until board will be programmed.

5. Now click on Browse in Flash Magic Utility, select hex file of relevant program and press start. It will dump the program on the board. Again press reset on the board the program will run in the board.
2EC314 Microcontroller Laboratory Page 30 of 42

Example: Write a program TO TURN ON LED CONNECTED TO P2.4. Program: ORG 00h SJMP MAIN ORG 0Bh acall ok sjmp here clr p1.1 clr p1.7 ret end

MAIN: here: ok:

Exercise: 1. WAP to generate a square wave of 2 kHz frequency on pin 1.4, use TIMER 1 to generate the time delay. (Draw Control word selection) 2. Find the delay generated by timer 0 in the following code. Do not include the overhead due to instruction.

2EC314 Microcontroller Laboratory

Page 31 of 42

HERE:

AGAIN:

CLR P2.3 MOV TMOD,#01 MOV TL0,#3EH MOV TH0,#0B8H SETB P2.3 SETB TR0 JNB TF0,AGAIN CLR TR0 CLR TF0 CLR P2.3

;Clear P2.3 ;Timer 0, 16-bitmode ;TL0=3Eh, the low byte ;TH0=B8H, the high byte ;SET high timer 0 ;Start the timer 0 ;Monitor timer flag 0 ;Stop the timer 0 ;Clear TF0 for next round

2EC314 Microcontroller Laboratory

Page 32 of 42

Exp No: 8

Date:

Aim: Write an Assembly language program to toggle LED using Input Output Programming Objective: To understand concept of Interrupt Enable Register. To test the program on 8051 kit

Theory:

Exercise: 1. WAP to to toggle LED connected to pin P1.5 continuously every 250 ms. Use Timer 0, mode 2 (8-bit auto-reload) to create the delay. 2. To generate square wave with frequency 100 kHz using interrupt.

2EC314 Microcontroller Laboratory

Page 33 of 42

Exp No: 9

Date:

Aim: Write an Assembly language program to to counter and display on 7segment LED. (Use Timer/Counter) Objective: To interface seven segments led with 8051 kit. Example: Program to interface one no of 7-segment led.
Org 00 sjmp MAIN org 0B MAIN: mov p1,#0x00 mov p2,#0xff mov p2,#0xfe mov p1,#0xbf acall delay mov p1,#0x00 mov p2,#0xfd mov p1,#0x86 acall delay mov p1,#0x00 mov p2,#0xfb mov p1,#0xdb acall delay mov p1,#0x00 mov p2,#0xf7 mov p1,#0xcf acall delay sjmp MAIN delay: nop nop nop nop nop ret END

Exercise: 1. WAP to interface 4-7 segment LEDS to 8051 & displa7 0, 1, 2, & 3 ON respective 7 segment LEDS.

2EC314 Microcontroller Laboratory

Page 34 of 42

Exp No: 10

Date:

Aim: Write an Assembly language program to perform Serial Communication using UART Module. Objective: To understand functionality of Serial Control Register. Theory: Serial transmission is used to transfer to a device located many meters away. The data is sent one bit at a time. At the transmitting end, the byte of data must be converted to serial bits using parallel-in-serial-out shift register. At the receiving end, there is a serial-in - parallel-out shift register to receive the serial data and pack them into byte. When the distance is short, the digital signal can be transferred as it is on a simple wire and requires no modulation If data is to be transferred on the telephone line, it must be converted from 0s and 1s to audio tones This conversion is performed by a device called a modem, Modulator/demodulator. Serial data communication uses two methods: Synchronous method transfers a block of data at a time o Block-oriented data transfers use the synchronous method. The start bit is always one bit, but the stop bit can be one or two bits Asynchronous method transfers a single byte at a time o widely used for character-oriented transmissions. Each character is placed in between start and stop bits, this is called framing.

2EC314 Microcontroller Laboratory

Page 35 of 42

There are special IC chips made by many manufacturers for communications. UART (universal asynchronous Receiver-transmitter) USART (universal synchronous-asynchronous Receiver-transmitter)

serial

One need to configure Serial Control (SCON) register for serial communication using 8051. SCON register detail is given below.

Exercise: 1. WAP to transfer the message YES serially at 2400 buadrate, 8-bit data, 1 stop bit. Do this continuously. (Draw Control word selection) .

2EC314 Microcontroller Laboratory

Page 36 of 42

Exp No: 11
Aim: Develop a microcontroller based project. Instructions:

Date:

1. You must design project based on either PIC Controller or AVR Controller. (Material related both controllers available on course website). 2. Project should be carried out in the group of two students. (preferable from same batch) 3. Project title should be selected after consulting your lab Mentor. Sample project title is available on course website. 4. project title must be entered in spread sheet by end of 3rd 2014. 5. Final Submission Deadline: 1st Week of April, 2014. 6. Submission includes: Hardware module of project. Project Report week of Jan-

2EC314 Microcontroller Laboratory

Page 37 of 42

Appendix
8051 Instruction Set Summary Mnemonic Description Arithmetic operations ADD A,Rn Add registertoaccumulator ADD A,direct ADD A,@Ri ADD A,#data ADDC A,direct ADDC A,@Ri ADDC A,#data SUBB A,Rn SUBB A,direct SUBB A,@Ri SUBB A,#data INC A INCRn INCdirect INC @Ri DEC A DEC Rn DECdirect DEC @Ri INC DPTR MUL AB DIV AB DAA CLR A CPLA RL A RLC A Add direct byte toaccumulator Add indirect RAMtoaccumulator Add immediate datatoaccumulator Add direct byte toAwithcarryflag Add indirect RAMtoA with carryflag Add immediate datatoA with carryflag Subtractregisterto accumulator with borrow Subtractdirectbyte to A with carry borrow Subtract indirect RAM toAwithcarryborrow Subtract immediate data toA with carryborrow Increment accumulator Increment register Increment direct byte Incrementindirect RAM Decrement accumulator Decrement register Decrement direct byte Decrement indirect RAM Increment data pointer MultiplyA and B->[B hi]:[A lo] Divide A byB ->A=result, B=remainder Decimal adjust accumulator Clear accumulator Complement accumulator Rotateaccumulatorleft Rotateaccumulatorleftthrough carry Bytes 1 2 1 2 2 1 2 1 2 1 2 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 Cycles 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 4 4 1 1 1 1 1

2EC314 Microcontroller Laboratory

Page 38 of 42

RR A RRC A SWAP A ANL A,Rn ANL A,direct ANL A,@Ri ANL A,#data ANL direct,A ANL direct,#data ORL A,Rn ORL A,direct ORL A,@Ri ORL A,#data ORL direct,A ORL direct,#data XRL A,Rn XRL A,Rn XRL A,Rn XRL A,@Ri XRL A,#data XRL direct,A XRL direct,#data CLR C CLR bit SETB C SETBbit CPL C CPL bit

Rotateaccumulatorright Rotateaccumulatorright through carry Swap nibbles withinthe accumulator Logic operations AND registertoaccumulator ANDdirect byte toaccumulator AND indirect RAM toaccumulator ANDimmediate datatoaccumulator ANDaccumulatorto direct byte ANDimmediate datatodirect byte OR registerto accumulator OR direct byte toaccumulator OR indirect RAM toaccumulator ORimmediate data to accumulator OR accumulatortodirect byte ORimmediate data to direct byte Exclusive OR registerto accumulator Exclusive OR registerto accumulator Exclusive OR registerto accumulator ExclusiveOR indirect RAM toaccumulator Exclusive ORimmediate data to accumulator Exclusive ORaccumulatortodirect byte Exclusive OR immediate data to direct byte Boolean Variable Manipulation Clear carry flag Clear direct bit Set carry flag Set direct bit Complement carry flag Complement direct bit

1 1 1 1 2 1 2 2 3 1 2 1 2 2 3 1 1 1 1 2 2 3 1 2 1 2 1 2

1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1

2EC314 Microcontroller Laboratory

Page 39 of 42

ANL C,bit ANL C,/bit ORL C,bit ORL C,/bit MOV C,bit MOV bit,C ACALL addr11 LCALL addr16 RET RETI AJMPaddr11 LJMPaddr16 SJMP rel JMP @A+DPTR JZ rel JNZ rel JC rel JNC rel JB bit,rel JNB bit,rel JBC bit,rel CJNE A,direct,rel CJNE A,#data,rel CJNE Rn,#data,rel CJNE @Rn,#data,rel DJNZ Rn,rel DJNZ direct,rel

AND direct bit to carry flag AND complement of direct bit to carry OR direct bit to carry flag OR complement of direct bit to carry Move direct bit to carry flag Move carry flag to direct bit Program and machine control Absolutesubroutine call Longsubroutine call Return from subroutine Return from interrupt Absolute jump Long jump Jump(relative address) Jumpindirectrelativetothe DPTR Jump if accumulator is zero Jumpifaccumulator is not zero Jump if carry flag is set Jump if carry flag is not set Jump if bit is set Jumpifbitis not set Jumpifdirectbit isset and clear bit Compare directbyte toA and jumpif not equal Compare immediate toA and jumpif not equal Compare immed. toreg. and jump if not equal Compare immed. to ind. and jumpif not equal Decrement register and jump in not zero Decrement direct byte and jumpin not zero

2 2 2 2 2 2 2 3 1 1 2 3 2 1 2 2 2 2 3 3 3 3 3 3 3 2 3

2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

2EC314 Microcontroller Laboratory

Page 40 of 42

Data transfer MOV A,Rn MOV A,direct*) MOV A,@Ri MOV A,#data MOV Rn,A MOV Rn,direct MOV Rn,#data MOV direct,A MOV direct,Rn MOV direct,direct MOV direct,@Ri MOV direct,#data MOV @Ri,A MOV @Ri,direct MOV @Ri,#data MOV DPTR,#data16 MOVC A,@A+DPTR MOVC A,@A+PC MOVX A,@Ri MOVX A,@DPTR MOVX @Ri,A MOVX @DPTR,A PUSH direct POP direct XCH A,Rn XCH A,direct XCH A,@Ri XCHD A,@Ri Moveregistertoaccumulator Movedirect byte to accumulator MoveindirectRAM to accumulator Moveimmediatedata toaccumulator Moveaccumulator toregister Movedirect byte to register Moveimmediatedata toregister Moveaccumulator todirectbyte Move register to direct byte Movedirect byte to direct byte MoveindirectRAM to directbyte Moveimmediatedata todirect byte Moveaccumulator toindirectRAM MovedirectbytetoindirectRAM Moveimmediatedata toindirect RAM Loaddata pointer with a 16-bitconstant Movecode byte relative to DPTR to accumulator Movecode byte relative to PC to accumulator Moveexternal RAM(8-bitaddr.) to A Moveexternal RAM (16-bit addr.) to A MoveAto external RAM (8-bitaddr.) MoveA to external RAM (16-bit addr.) Push direct byte onto stack Pop direct byte from stack Exchange register to accumulator Exchange direct byte to accumulator Exchange indirect RAM to accumulator Exchange low-order nibble in dir. RAM with A 1 2 1 2 1 2 2 2 2 3 2 3 1 2 2 3 1 1 1 1 1 1 2 2 1 2 1 1 1 1 1 1 1 2 1 1 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 1 1 1 1

2EC314 Microcontroller Laboratory

Page 41 of 42

Label

Mnemonic / Operand

Comments

2EC314 Microcontroller Laboratory

Page 42 of 42

You might also like