unit5-8051 4th sem anna university cse

28
SYLLABUS CS 2252 MICROPROCESSORS AND MICROCONTROLLERS L T P C (Common to CSE & IT) 3 0 0 3 UNIT I THE 8085 AND 8086 MICROPROCESSORS 9 8085 Microprocessor architecture-Addressing modes- Instruction set- Programming the 8085 UNIT II SOFTWARE ASPECTS 9 Intel 8086 microprocessor - Architecture - Signals- Instruction Set- Addressing ModesAssembler Directives- Assembly Language Programming- Procedures-Macros-Interrupts And Interrupt Service Routines-BIOS function calls. UNIT III MULTIPROCESSOR CONFIGURATIONS 9 Coprocessor Configuration – Closely Coupled Configuration – Loosely Coupled Configuration –8087 Numeric Data Processor – Data Types – Architecture –8089 I/O Processor –Architecture –Communication between CPU and IOP. UNIT IV I/O INTERFACING 9 Memory interfacing and I/O interfacing with 8085 – parallel communication interface – serial communication interface – timer-keyboard/display controller – interrupt controller – DMA controller (8237) – applications – stepper motor – temperature control. UNIT V MICROCONTROLLERS 9

Upload: vijayashree-venkat

Post on 28-Dec-2015

53 views

Category:

Documents


5 download

DESCRIPTION

unit5 4th sem anna university cse

TRANSCRIPT

Page 1: unit5-8051 4th sem anna university cse

SYLLABUS

CS 2252 MICROPROCESSORS AND MICROCONTROLLERS L T P C

(Common to CSE & IT) 3 0 0 3

UNIT I THE 8085 AND 8086 MICROPROCESSORS 9

8085 Microprocessor architecture-Addressing modes- Instruction set-Programming the

8085

UNIT II SOFTWARE ASPECTS 9

Intel 8086 microprocessor - Architecture - Signals- Instruction Set-Addressing ModesAssembler Directives- Assembly Language Programming-Procedures-Macros-Interrupts

And Interrupt Service Routines-BIOS function calls.

UNIT III MULTIPROCESSOR CONFIGURATIONS 9

Coprocessor Configuration – Closely Coupled Configuration – Loosely Coupled

Configuration –8087 Numeric Data Processor – Data Types – Architecture –8089 I/O

Processor –Architecture –Communication between CPU and IOP.

UNIT IV I/O INTERFACING 9

Memory interfacing and I/O interfacing with 8085 – parallel communication interface –

serial communication interface – timer-keyboard/display controller – interrupt controller –

DMA controller (8237) – applications – stepper motor – temperature control.

UNIT V MICROCONTROLLERS 9

Architecture of 8051 Microcontroller – signals – I/O ports – memory – counters and

timers – serial data I/O – interrupts- Interfacing -keyboard, LCD,ADC & DAC

TOTAL: 45 PERIODS

TEXT BOOKS

1. Ramesh S. Gaonkar ,”Microprocessor – Architecture, Programming and Applications

with the 8085” Penram International Publisher , 5

Page 2: unit5-8051 4th sem anna university cse

th

Ed.,2006

2. Yn-cheng Liu,Glenn A.Gibson, “Microcomputer systems: The 8086 / 8088 Family

architecture, Programming and Design”, second edition, Prentice Hall of India , 2006

3. Kenneth J.Ayala, ’The 8051 microcontroller Architecture, Programming and

applications‘ second edition ,Penram international

REFERENCES

1. Douglas V.Hall, “ Microprocessors and Interfacing : Programming and Hardware”,

second edition , Tata Mc Graw Hill ,2006.

2. A.K.Ray & K.M Bhurchandi, “Advanced Microprocessor and Peripherals –

Architecture, Programming and Interfacing”, Tata Mc Graw Hill , 2006.

3. Peter Abel, “ IBM PC Assembly language and programming” , fifth edition, Pearson

education / Prentice Hall of India Pvt.Ltd,2007.

4. Mohamed Ali Mazidi,Janice Gillispie Mazidi,” The 8051 microcontroller and

embedded systems using Assembly and C”,second edition, Pearson education

/Prentice hall of India , 2007

Page 3: unit5-8051 4th sem anna university cse

UNIT V

8051 MICROCONTROLLER• It is a single chip• Consists of Cpu, Memory• I/O ports, timers and other peripherals

Page 4: unit5-8051 4th sem anna university cse

Memory Organization- Logical separation of program and data memory-Separate address spaces for Program (ROM) and Data (RAM) Memory-Allow Data Memory to be accessed by 8-bit addresses quickly and manipulated by8-bit CPUProgram memory-Only be read, not written to-The address space is 16-bit, so maximum of 64K bytes-Up to 4K bytes can be on-chip (internal) of 8051 core-PSEN (Program Store Enable) is used for access to external Program MemoryData memory-Includes 128 bytes of on-chip Data Memory which are more easily accessibledirectly by its instructions-There is also a number of Special Function Registers (SFRs)-Internal Data Memory contains four banks of eight registers and a special 32-byte long segment which is bit addressable by 8051 bit-instructions-External memory of maximum 64K bytes is accessible by “movx”

Page 5: unit5-8051 4th sem anna university cse

Interrupt StructureThe 8051 provides 4 interrupt sources

Two External interruptTwo timer interrupt

Page 6: unit5-8051 4th sem anna university cse

Instruction FormatAn instruction is a command to the microprocessor to perform a given task on a specified data.Each instruction has two parts: one is task to be performed, called the operation code (opcode),and the second is the data to be operated on, called the operand. The operand (or data) can bespecified in various ways. It may include 8-bit (or 16-bit ) data, an internal register, a memorylocation, or 8-bit (or 16-bit) address. In some instructions, the operand is implicit.Instruction word sizeThe 8051 instruction set is classified into the following three groups according to word size:1. One-word or 1-byte instructions2. Two-word or 2-byte instructions3. Three-word or 3-byte instructions

Page 7: unit5-8051 4th sem anna university cse

One-Byte InstructionsA 1-byte instruction includes the opcode and operand in the same byte. Operand(s) are internalregister and are coded into the instruction.These instructions are 1-byte instructions performingthree different tasks. In the first instruction, both operand registers are specified. In the secondinstruction, the operand B is specified and the accumulator is assumed. Similarly, in the thirdinstruction, the accumulator is assumed to be the implicit operand. These instructions are storedin 8-bit binary format in memory; each requires one memory location.Two-Byte InstructionsIn a two-byte instruction, the first byte specifies the operation code and the second byte specifiesthe operand. Source operand is a data byte immediately following the opcode.Three-Byte InstructionsIn a three-byte instruction, the first byte specifies the opcode, and the following two bytes specifythe 16-bit address. Note that the second byte is the low-order address and the third byte is thehigh-order address.

ADDRESSING MODES OF 8051

The 8051 provides a total of five distinct addressing modes.(1) immediate(2) register(3) direct(4) register indirect(5) indexed(1) Immediate Addressing Mode The operand comes immediately after the op-code. The immediate data must be preceded by the pound sign, "#".

(2) Register Addressing Mode Register addressing mode involves the use of registers to hold the data to bemanipulated.

(3)Direct Addressing ModeIt is most often used to access RAM locations 30 - 7FH.This is due to the fact that register bank locations are accessed by the registernames of R0 - R7.There is no such name for other RAM locations so must use direct addressingIn the direct addressing mode, the data is in a RAM memory location whose

Page 8: unit5-8051 4th sem anna university cse

address is known, and this address is given as a part of the instruction

(4)Register Indirect Addressing Mode

(5) Indexed Addressing Mode

up table entrieslocated in the program ROM space of the 8051.The instruction used for this purpose is :MOVC A, @ A+DPTR-The 16 bit register DPTR and register A are used to form the address of the data element stored

TIMERS

The 8051 comes equipped with two timers, both of which may be controlled, set, read, andconfigured individually. The 8051 timers have three general functions: 1) Keeping time and/orcalculating the amount of time between events, 2) Counting the events themselves, or 3)Generating baud rates for the serial port.one of the primary uses of timers is to measure time. We will discuss this use of timers first andwill subsequently discuss the use of timers to count events. When a timer is used to measure timeit is also called an "interval timer" since it is measuring the time of the interval between twoevents.Timer SFR8051 has two timers which each function essentially the same way. One timer is TIMER0 and theother is TIMER1. The two timers share two SFRs (TMOD and TCON) which control the timers,and each timer also has two SFRs dedicated solely to itself (TH0/TL0 and TH1/TL1).

Page 9: unit5-8051 4th sem anna university cse

13-bit Time Mode (mode 0)Timer mode "0" is a 13-bit timer. This is a relic that was kept around in the 8051 to maintaincompatability with its predecesor, the 8048. Generally the 13-bit timer mode is not used in newdevelopment.When the timer is in 13-bit mode, TLx will count from 0 to 31. When TLx is incremented from31, it will "reset" to 0 and increment THx. Thus, effectively, only 13 bits of the two timer bytesare being used: bits 0-4 of TLx and bits 0-7 of THx. This also means, in essence, the timer canonly contain 8192 values. If you set a 13-bit timer to 0, it will overflow back to zero 8192machine cycles later.Again, there is very little reason to use this mode and it is only mentioned so you wont besurprised if you ever end up analyzing archaeic code which has been passed downthrough the generations (a generation in a programming shop is often on the order ofabout 3 or 4 months).16-bit Time Mode (mode 1)Timer mode "1" is a 16-bit timer. This is a very commonly used mode. It functions justlike 13-bit mode except that all 16 bits are used.TLx is incremented from 0 to 255. When TLx is incremented from 255, it resets to 0 andcauses THx to be incremented by 1. Since this is a full 16-bit timer, the timer maycontain up to 65536 distinct values. If you set a 16-bit timer to 0, it will overflow back to0 after 65,536 machine cycles.8-bit Time Mode (mode 2)Timer mode "2" is an 8-bit auto-reload mode. When a timer is in mode 2, THx holds the"reload value" and TLx is the timer itself. Thus, TLx starts counting up. When TLxreaches 255 and is subsequently incremented, instead of resetting to 0 (as in the case ofmodes 0 and 1), it will be reset to the value stored in THx.Split Timer Mode (mode 3)Timer mode "3" is a split-timer mode. When Timer 0 is placed in mode 3, it essentiallybecomes two separate 8-bit timers. That is to say, Timer 0 is TL0 and Timer 1 is TH0.Both timers count from 0 to 255 and overflow back to 0. All the bits that are related toTimer 1 will now be tied to TH0.

Page 10: unit5-8051 4th sem anna university cse

While Timer 0 is in split mode, the real Timer 1 (i.e. TH1 and TL1) can be put intomodes 0, 1 or 2 normally--however, you may not start or stop the real timer 1 since thebits that do that are now linked to TH0. The real timer 1, in this case, will be incrementedevery machine cycle no matter what.

USING TIMERS AS EVENT COUNTERSWe've discussed how a timer can be used for the obvious purpose of keeping track oftime. However, the 8051 also allows us to use the timers to count events.How can this beuseful? Let's say you had a sensor placed across a road that would send a pulse everytime a car passed over it. This could be used to determine the volume of traffic onthe road. We could attach this sensor to one of the 8051's I/O lines and constantlymonitor it, detecting when it pulsed high and then incrementing our counter when it wentback to a low state. This is not terribly difficult, but requires some code. Let's say wehooked the sensor to P1.0; the code to count cars passing would look something like this:JNB P1.0,$ ;If a car hasn't raised the signal, keep waitingJB P1.0,$ ;The line is high which means the car is on the sensor right nowINC COUNTER ;The car has passed completely, so we count it

Serial CommunicationSome of the external I/0 devices receive only the serial data.Normally serialcommunication is used in the Multi Processor environment.8051 has two pins for serialcommunication.(1)SID- Serial Input data.(2)SOD-Serial Output data.Instruction Set:Arithmetic Instructions

Logical Instructions

Page 11: unit5-8051 4th sem anna university cse

Data Transfer Instructions that access the Internal Data Memory

Data Transfer Instructions that access the External Data Memory

Jump And Boolean Instructions

Page 12: unit5-8051 4th sem anna university cse

INTERFACING KEYBOARD TO 8051 MICROCONTROLLER

The key board here we are interfacing is a matrix keyboard. This key board is designed with aparticular rows and columns. These rows and columns are connected to the microcontrollerthrough its ports of the micro controller 8051. We normally use 8*8 matrix key board. So onlytwo ports of 8051 can be easily connected to the rows and columns of the key board.When ever a key is pressed, a row and a column gets shorted through that pressed key and all theother keys are left open. When a key is pressed only a bit in the port goes high. Which indicatesmicrocontroller that the key is pressed. By this high on the bit key in the corresponding column isidentified.Once we are sure that one of key in the key board is pressed next our aim is to identify that key.To do this we firstly check for particular row and then we check the corresponding column thekey board.To check the row of the pressed key in the keyboard, one of the row is made high by making oneof bit in the output port of 8051 high . This is done until the row is found out. Once we get therow next out job is to find out the column of the pressed key. The column is detected by contentsin the input ports with the help of a counter. The content of the input port is rotated with carryuntil the carry bit is set.The contents of the counter is then compared and displayed in the display. This display isdesigned using a seven segment display and a BCD to seven segment decoder IC 7447. The BCDequivalent number of counter is sent through output part of 8051 displays the number of pressedkey.

Page 13: unit5-8051 4th sem anna university cse

Circuit Diagram of Interfacing Keyboard to8051

Page 14: unit5-8051 4th sem anna university cse

Program for Keyboard Interfacing with 8051Start of main program:to check that whether any key is pressedstart: mov a,#00hmov p1,a ;making all rows of port p1 zeromov a,#0fhmov p1,a ;making all rows of port p1 highpress: mov a,p2jz press ;check until any key is pressedafter making sure that any key is pressedmov a,#01h ;make one row high at a timemov r4,amov r3,#00h ;initiating counternext: mov a,r4mov p1,a ;making one row high at a timemov a,p2 ;taking input from port Ajnz colscan ;after getting the row jump to checkcolumnmov a,r4rl a ;rotate left to check next rowmov r4,amov a,r3add a,#08h ;increment counter by 08 countmov r3,asjmp next ;jump to check next rowafter identifying the row to check the colomn following steps are followecolscan: mov r5,#00hin: rrc a ;rotate right with carry until get the carryjc out ;jump on getting carryinc r3 ;increment one countjmp inout: mov a,r3da a ;decimal adjust the contents of counterbefore displaymov p2,ajmp start ;repeat for check next key.

INTERFACING LCD TO 8051:

Liquid Crystal Display also called as LCD is very helpful in providing userinterface as well as for debugging purpose. The most common type of LCD controller isHITACHI 44780 which provides a simple interface between the controller & an LCD.These LCD's are very simple to interface with the controller as well as are costeffective.The most commonly used ALPHANUMERICdisplays are1x16 (Single Line & 16 characters),2x16 (Double Line & 16 character per line),4x20 (four lines & Twenty characters per line).The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines. The number on

Page 15: unit5-8051 4th sem anna university cse

data lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines +3 control lines i.e. total 11 lines are required. And if operated in 4-bit mode then 4 datalines + 3 control lines i.e. 7 lines are required. How do we decide which mode to use? It’ssimple if you have sufficient data lines you can go for 8 bit mode & if there is a timeconstrain i.e. display should be faster then we have to use 8-bit mode because basically 4-bit mode takes twice as more time as compared to 8-bit mode.

Pin Symbol Function1 Vss Ground2 Vdd Supply Voltage3 Vo Contrast Setting4 RS Register Select5 R/W Read/Write Select6 En Chip Enable Signal7-14 DB0-DB7 Data Lines15 A/Vee Gnd for the backlight16 K Vcc for backlightWhen RS is low (0), the data is to be treated as a command. When RS is high (1), the databeing sent is considered as text data which should be displayed on the screen.When R/W is low (0), the information on the data bus is being written to the LCD. WhenRW is high (1), the program is effectively reading from the LCD. Most of the times thereis no need to read from the LCD so this line can directly be connected to Gnd thus savingone controller line.The ENABLE pin is used to latch the data present on the data pins. A HIGH - LOWsignal is required to latch the data. The LCD interprets and executes our command at theinstant the EN line is brought low. If you never bring EN low, your instruction will neverbe executed.

For Contrast setting a 10K pot should be used as shown in the figure.Display Data Ram (DDRAM) stores the display data. So when we have to display acharacter on LCD we basically write it into DDRAM. For a 2x16 LCD the DDRAMaddress for first line is from 80h to 8fh & for second line is 0c0h to 0cfh. So if we want to

Page 16: unit5-8051 4th sem anna university cse

display 'H' on the 7th postion of the first line then we will write it at location 87h.Now as you have noticed two types of data is given to the LCD data to be displayed,command or special instruction.So now let us write a subroutine for both the type of data

Data to be Displayedlcd_datadisplay:SETB RS //Telling the LCD that the data which is being send is tobe displayedMOV P1,A //Character to be displayed is in AccSETB ENCLR EN //High to Low pulse on EN to latch the dataCALL DELAY //Delay so that LCD finishes its internal operationsret

Command or Special Instructionlcd_command:CLR RS //Telling the LCD that the data which is being send is acommandMOV P1,A //Character to be displayed is in AccSETB ENCLR EN //High to Low pulse on EN to latch the dataCALL DELAY //Delay so that LCD finishes its internal operationsretHere I have used delay at the end of both the subroutines this is done to wait until theinstruction is completely executed by the LCD. This will assure that our program givesthe LCD the time it needs to execute instructions and also makes our program compatiblewith any LCD, regardless of how fast or slow it is.

"*" - Not Used/Ignored. This bit can be either "1" or "0"Set Cursor Move Direction:ID - Increment the Cursor After Each Byte Written to Display if SetS - Shift Display when Byte Written to Display Enable Display/CursorD - Turn Display On(1)/Off(0) C - Turn Cursor On(1)/Off(0)B - Cursor Blink On(1)/Off(0)Set Cursor Move Direction:ID - Increment the Cursor After Each Byte Written to Display if SetS - Shift Display when Byte Written to Display Enable Display/CursorD - Turn Display On(1)/Off(0) C - Turn Cursor On(1)/Off(0)

Page 17: unit5-8051 4th sem anna university cse

B - Cursor Blink On(1)/Off(0)Move Cursor/Shift DisplaySC - Display Shift On(1)/Off(0) RL - Direction of Shift Right(1)/Left(0)Set Interface LengthDL - Set Data Interface Length 8(1)/4(0)N - Number of Display Lines 1(0)/2(1)F - Character Font 5x10(1)/5x7(0)Poll the "Busy Flag" BF - This bit is set while the LCD is processingMove Cursor to CGRAM/DisplayA - AddressRead/Write ASCII to the DisplayD - DataThe above Table shows the different commands for the LCD. I wont go into its details.Before starting to display on LCD we need to Initialize it. Firstly we must tell the LCDwhether we'll be using 8-bit or 4-bit mode. Also we will be telling the LCD that we need5x8 character font. Both these options are selected using a single command i.e. 38h. So toactivate both these options we must execute following instructions:MOV A,#38hCALL lcd_commandNow that we have to Turn On the display & set the cursor option i.e. cursor ON/OFF &Cursor blinking ON/OFF for that we will use the command 0Eh i.e. Display On , CursorON but Cursor blinking OFF.MOV A,#0EhCALL lcd_commandAnd the last command we require is to configure the LCD in such a way that everytimewe send a character to it the cursor position automatically increments by one & moves toright i.e. 06h.MOV A,#06hCALL lcd_commandSo the lcd_initialize contains the following instructionslcd_initialize:MOV A,#38hCALL lcd_commandMOV A,#38hCALL lcd_commandMOV A,#38hCALL lcd_commandretSimilarly another important instruction that we require is Clearing the LCD i.e.lcd_clr:MOV A,#01hCALL lcd_commandretNow we know all the commands to display on LCD. Let us write a program that willdisplay 'DNA TECHNOLOGY' on LCD.

Page 18: unit5-8051 4th sem anna university cse

ORG 0000hCALL lcd_initializeCALL lcd_clrMOV A,#80h //Location from where Data is to be displayedCALL lcd_commandMOV A,#'D'CALL lcd_datadisplayMOV A,#'N'CALL lcd_datadisplayMOV A,#'A'CALL lcd_datadisplayMOV A,#20h //Hex value for blank space to be displayedCALL lcd_datadisplayMOV A,#'T'CALL lcd_datadisplayMOV A,#'E'CALL lcd_datadisplayMOV A,#'C'CALL lcd_datadisplayMOV A,#'H'CALL lcd_datadisplayMOV A,#'N'CALL lcd_datadisplayMOV A,#'O'CALL lcd_datadisplayMOV A,#'L'CALL lcd_datadisplayMOV A,#'O'CALL lcd_datadisplayMOV A,#'G'CALL lcd_datadisplayMOV A,#'Y'CALL lcd_datadisplaystop:ajmp stop

INTERFACING ADC0808 TO 8051

In lot of embedded systems microcontrollers needs to take analog input. Most of thesensors & transducers such as temperature, humidity, pressure, are analog. Forinterfacing these sensors to microcontrollers we require to convert the analog output ofthese sensors to digital so that the controller can read it. Some microcontrollers have builtin Analog to Digital Convertor (ADC) so there is no need of external ADC. Formicrocontrollers that don’t have internal ADC external ADC is used.One of the most commonly used ADC is ADC0808. ADC 0808 is a Successiveapproximation type with 8 channels i.e. it can directly access 8 single ended analog

Page 19: unit5-8051 4th sem anna university cse

signals.I/O PinsADDRESS LINE A, B, CThe device contains 8-channels. A particular channel is selected by using the addressdecoder line. The TABLE 1 shows the input states for address lines to select any channel.

Address Latch Enable ALEThe address is latched on the Low – High transition of ALE.STARTThe ADC’s Successive Approximation Register (SAR) is reset on the positive edge i.e.Low- High of the Start Conversion pulse. Whereas the conversion is begun on the fallingedge i.e. High – Low of the pulse.Output EnableWhenever data has to be read from the ADC, Output Enable pin has to be pulled highthus enabling the TRI-STATE outputs, allowing data to be read from the data pins D0-D7.End of Conversion (EOC)This Pin becomes High when the conversion has ended, so the controller comes to knowthat the data can now be read from the data pins.ClockExternal clock pulses are to be given to the ADC; this can be given either from LM 555in Astable mode or the controller can also be used to give the pulses.ALGORITHM 1. Start. 2. Select the channel. 3. A Low – High transition on ALEto latch in the address. 4. A Low – High transition on Start to reset the ADC’s SAR.5. A High – Low transition on ALE. 6. A High – Low transition on start to start theconversion. 7. Wait for End of cycle (EOC) pin to become high. 8. Make OutputEnable pin High. 9. Take Data from the ADC’s output 10. Make Output Enable pinLow. 11. StopThe total numbers of lines required are:datalines:8ALE:1START:1EOC:1Output Enable:1I.e. total 12 lines. You can directly connect the OE pin to Vcc. Moreover instead ofpolling for EOC just put some delay so instead of 12 lines you will require 10 lines.You can also provide the clock through the controller thus eliminating the need of

Page 20: unit5-8051 4th sem anna university cse

external circuit for clock.Calculating Step SizeADC 0808 is an 8 bit ADC i.e. it divides the voltage applied at Vref+ & Vref- into 28 i.e.256 steps.Step Size = (Vref+ - Vref-)/256Suppose Vref+ is connected to Vcc i.e. 5V & Vref- is connected to the Gnd then the stepsize will beStep size= (5 - 0)/256= 19.53 mv.Calculating Dout.The data we get at the D0 - D7 depends upon the step size & the Input voltage i.e. Vin.Dout = Vin /step Size.If you want to interface sensors like LM35 which has output 10mv/°C then I wouldsuggest that you set the Vref+ to 2.56v so that the step size will beStep size= (2.56 - 0)/256= 10 mv.So now whatever reading that you get from the ADC will be equal to the actualtemperature.PROGRAMHere is a program for interfacing the ADC to microcontroller, as stated above I haveassumed that the OE pin is connected to Vcc & the clock is given by the controller.This program selects channel 0 as input channel reads from it & saves in the accumulator.adc_a bit p2.0adc_b bit p2.1adc_c bit p2.2adc_start bit p2.3adc_ale bit p2.4adc_clk bit P2.5Org 0000hclr aleclr startclr adc_aclr adc_b ;Select Channel 0clr adc_ccall delay_smallsetb adc_ale ;ale pin highcall delay_smallsetb adc_start ;start pin highcall delay_smallclr adc_ale ;ale pin lowcall delay_smallclr adc_start ;start pin lowcall delay_longmov a,P1loop:ajmp loopdelay_small:mov r0,#10

Page 21: unit5-8051 4th sem anna university cse

l1_delay_small:cpl adc_clknopnopnopnopnopdjnz r0,l1_delay_smallretdelay_long:mov r0,#40l1_delay_long:cpl adc_clknopnopnopnopnopdjnz r0,l1_delay_longretEnd