sample 8051prgm
DESCRIPTION
cvcxTRANSCRIPT
![Page 1: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/1.jpg)
Microprocessors and Microcontrollers
8051 programs
![Page 2: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/2.jpg)
Microprocessors and Microcontrollers
• Write an 8051 program to fill the odd series from memory location 0030h to 0035h
ORG 0MOV R1,#30HMOV R2,#05MOV A,#1BACK:MOV @R1,AINC R1ADD A,#2DJNZ R2,BACKEND
![Page 3: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/3.jpg)
Microprocessors and Microcontrollers
• Write an 8051 program to copy the string “Welcome to 8051 Programming” stored at 300H ROM space to RAM location starting at location 22H.
• Note: Loop should repeat exactly as the length of the string
![Page 4: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/4.jpg)
Microprocessors and Microcontrollers
ORG 000CLR AMOV DPTR,#COUNTMOVC A,@A+DPTRMOV R1,AMOV DPTR,#MYDATAMOV R0,#22HBACK: CLR AMOVC A,@A+DPTRMOV @R0,AINC DPTRINC R0DJNZ R1,BACKHERE: SJMP HEREORG 300HMYDATA:DB "WELCOME TO JIITU !!!"COUNT:DB $-MYDATAEND
Indirect Addressing Mode
Indirect Addressing Mode
![Page 5: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/5.jpg)
Microprocessors and Microcontrollers
Execute the above program with the string terminated by NULL character and without using the counter.
![Page 6: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/6.jpg)
Microprocessors and Microcontrollers
ORG 000MOV DPTR,#MYDATAMOV R0,#22HBACK: CLR AMOVC A,@A+DPTRJZ HEREMOV @R0,AINC DPTRINC R0SJMP BACKHERE: SJMP HEREORG 300HMYDATA:DB "WELCOME TO JIITU !!!",0END
String Terminated by NULL Character
Indirect Addressing Mode
![Page 7: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/7.jpg)
Microprocessors and Microcontrollers
Addition of two 8 bit number which are stored at 300H ROM space as DATA1 and DATA2
![Page 8: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/8.jpg)
Microprocessors and Microcontrollers
ORG 000MOV DPTR,#DATA1BACK: CLR AMOVC A,@A+DPTRMOV R0,AMOV DPTR,#DATA2CLR AMOVC A,@A+DPTR ADD A,R0INC DPTRHERE: SJMP HEREORG 300HDATA1:DB 12HDATA2:DB 55HEND
![Page 9: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/9.jpg)
Microprocessors and Microcontrollers
• Program to add the two consecutive memory locations stored at 50H ROM space using DATA directive and storing the result in next consecutive memory location. ORG 0
DATA1 DATA 0x50DATA2 DATA 0x51DATA3 DATA 0x52LJMP 250ORG 250MOV DATA1,#55hMOV DATA2,#22hMOV A,DATA1ADD A,DATA2MOV DATA3,AHERE: SJMP HEREEND
DATA directive
![Page 10: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/10.jpg)
Microprocessors and Microcontrollers
• Computes Z = X + Y; Using EQU directive
ORG 0X EQU 66HY EQU 77HZ EQU 0MOV A,#XADD A,#YMOV Z,AMOV R0,ZHERE: SJMP HEREEND
EQU directive
![Page 11: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/11.jpg)
Microprocessors and Microcontrollers
Write program to add R0,R1,R2,R3 of Bank-0, Bank-1, Bank-2, Bank-3 respectively.
P --OVRS0RS1F0ACCY PSW
![Page 12: Sample 8051Prgm](https://reader035.vdocuments.site/reader035/viewer/2022073120/55cf99b6550346d0339ec9f8/html5/thumbnails/12.jpg)
Microprocessors and Microcontrollers
ORG 0CLR PSW.3CLR PSW.4CLR AMOV R0,#1ADD A,R0SETB PSW.3CLR PSW.4MOV R1,#2ADD A,R1CLR PSW.3SETB PSW.4MOV R2,#3ADD A,R2SETB PSW.3SETB PSW.4MOV R3,#4ADD A,R3END
BANK-0
BANK-1
BANK-2
BANK-3