0% found this document useful (0 votes)
99 views

Programme

The document contains 34 programs demonstrating various assembly language instructions for the 8051 microcontroller. The programs cover data transfer instructions, logical operations, arithmetic operations, conditional jumps, delays, I/O ports, and monitoring input ports.

Uploaded by

Saurabh Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views

Programme

The document contains 34 programs demonstrating various assembly language instructions for the 8051 microcontroller. The programs cover data transfer instructions, logical operations, arithmetic operations, conditional jumps, delays, I/O ports, and monitoring input ports.

Uploaded by

Saurabh Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 11

1. Programme to move Data to Register A (MOV) ORG 00H MOV A, #20H END 2.

Programme to move Data to Register B ORG 00H MOV B, #40H END 3. Programme to move data to Register R0 R7 ORG 00H MOV R3, #21H END 4. Programme to move data from Accumulator (Reg A) to other resister ORG 00H MOV A, #20H MOV R2, A END 5. Programme to move data to I.O. Ports. ORG 00H MOV P2, #55H END 6. Programme to move data from Accumulator (Reg A) to other Ports. ORG 00H MOV A, #55H MOV P2, A END 7. Programme to Add two Numbers (Add Instruction)

ORG 00H MOV A, #25H MOV R2, #34H ADD A, R2 END 8. Programme to perform Loop Function (AJMP,SJMP & LJMP) ORG 00H XYZ: MOV A, # 55H MOV P1, A MOV A, # 0AAH MOV P1, A SJMP XYZ END

9. Programme to perform Delay Function (NOP, ACALL, LCALL) ORG 00H XYZ: MOV A, # 55H MOV P1, A NOP NOP NOP MOV A, # 0AAH MOV P1, A NOP ACALL DELAY SJMP XYZ

END 10.Programme to select a single bit as high on Port (setb) ORG 00H SETB P1.2 END 11.Programme to select a single bit as low on Port (clr) ORG 00H CLR P1.2 END 12.Programme to make a single bit of port High & Low ORG 00H SETB P2.1 NOP CLR P2.1 END 13.Programme to make a single bit of port High & Low continuously. ORG 00H XYZ: SETB P2.5 NOP CLR P2.5 NOP SJMP XYZ END 14.Programme to compliment the bits. (CPL) ORG 00H RPT: MOV A, #55H MOV P2, A

NOP CPL A SJMP RPT END

15.Programme to ADD two 16 bit numbers (ADD) ORG 00H CLR C MOV A, #0E7H ADD A, #8DH MOV R6, A MOV A, #3CH ADDC A, #3BH MOV R7, A END 16.Using decimal adjust for addition (DA) ORG 00H MOV A, #47H MOV B, #25H ADD A,B DA A END 17.Programme to substract two numbers (SUB) ORG 00H CLR C MOV A, #3FH MOV R3, #23H

SUBB A, R3 END 18.Programme to Multiply two numbers (MUL) ORG 00H MOV A, #25H MOV B, #65H MUL AB END 19.Programme to Divide two numbers (DIV) ORG 00H MOV A. #95H MOV B, #10H DIV AB END 20.Programming for using logical operation OR (ORL) ORG 00H MOV A, #04H ORL A, #30H END

21.Programming for using logical operation AND (ANL) ORG 00H MOV A, #35H ANL A, #0FH END 22.Programming for using logical operation XOR (XRL)

ORG 00H MOV A, #54H XRL A, #78H END 23.Programming to create 1s complement ORG 00H MOV A, #55H CPL A END 24.Programming to create 2s compliment ORG 00H MOV A, #55H CPL A ADD A, #1 END 25.Programming to ADD 3 to Acc for 10 times ORG 00H MOV A, #0 MOV R2, #10 AGN: ADD A, #03 DJNZ R2, AGN MOV R5, A END 26.Programme to check the condition, If 0 then it jump to the target. ORG 00H MOV A, R0 JZ OVER (A=R0) (Jump if A=0)

MOV A, R1 JZ OVER OVER:

(A=R1) (Jump if A=0)

27.Programme to create delay and kill more time using NOP in delay. ORG 00H RPT: MOV A, #55H MOV P1, A ACALL DELAY CPL A SJMP RPT DELAY: MOV R3, #250 HERE: NOP NOP NOP NOP DJNZ R3, HERE END 2 1 1 1 1 2 1

Time Delay=[250(1+1+1+1+2)]x1.085=1627.5 micro sec + 3 instruction outside the loop 1.085x3=1630.755 micro sec 28.Programme to create Time Delay in Nested Loop

ORG 00H RPT: MOV A, #55H MOV P2, A ACALL DELAY CPL A SJMP RPT DELAY: MOV R2, #200 AGAIN: MOV R3, #250 HERE: NOP NOP DJNZ R3, HERE DJNZ R2, AGAIN END Inner loop here delay (4x250)x1.085=1085 micro sec Again loop repeats the Here loop 200 times 200x1085=217000 micro sec + instruction machine cycle outside the loop repeated for internal loop 1.085x3x200=651 micro sec Total Delay=217000+651=217651 micro sec

29.Programme to toggle all the bits of P2 every 200 ms using crystal frequency 11.0592 Mhz

ORG 00H REP: MOV A, #55H MOV P2, A ACALL DELAY CPL A SJMP REP DELAY: MOV R5, #2 HERE1: MOV R4, # 180 HERE2: MOV R3, #255 HERE3: DJNZ R3, HERE3 DJNZ R4, HERE2 DJNZ R5, HERE1 END Delay= (2x180x255x2) x 1.085 = 199.206 ms 30.Single bit Instruction programming. SETB CLR CPL JB JNB JBC Set the bit High Clear the bit Low Compliment the bit Jump to target if bit =1 (Jump if Bit) Jump to target if bit =0 (Jump if No Bit) Jump if bit =1 then clear the bit.

31.Monitor bit P1.2, when it becomes high, send value 55h to p2. ORG 00H SETB A, #55H FRIDAY: JNB P1.2, FRIDAY MOV P2, A END

32.Monitor bit P1.2, when it becomes high, send value 55h to p2 and send high to low pulse to P2.3. ORG 00H SETB A, #55H FRIDAY: JNB P1.2, FRIDAY MOV P2, A SETB P2.3 CLR P2.3 END

33.Programme P1.5 as Input port for ON/OFF Switch and send a pulse to output port P2.5 The switch is connected to VCC ORG 00H FRI: SETB P1.5 JNB P1.5 SETB P2.5 SJMP FRI END 34.Programme P1.5 as Input port for ON/OFF Switch and send a pulse to output port P2.5 The switch is connected to VCC ORG 00H LOOP: JNB P1.5, LOOP SETB P2.5 CLR P2.5 SJMP LOOP END

You might also like