SlideShare a Scribd company logo
1 of 10
Subroutine
MCS-51 Microcontroller
By Arkhom JODTANG
Civil Aviation Training Center, Thailand
• Subroutines are a small part of program that
able to call for use in multiple times.
Subroutine1
Subroutine2
Subroutine3
• Subroutines are
contended as the
part of main
program.
Main Program
Subroutine1
Subroutine2
ORG 00H
END
Writing Subroutine
• ACALL instruction to call subroutine
– Use LCALL for longer then 2 kByte distance
• Label, such as
– Delay:
– Multipli4X4Bytes:
– CheckOnes:
• RET instruction
– RET will make return to the next instruction (After
ACALL)
Recording the Return Address
• Stack will be use to record the return to main
program address.
Sample Program
ORG 00H
MOV R0, #30H
Loop:
ACALL DecimalAdj
ACALL WriteData
INC R0
INC A
CJNE R0,#70H, Loop
SJMP $
; --------------------------------
DecimalAdj:
CLR C
DA A
RET
WriteData:
MOV @R0, A
RET
END
Sample Program
ORG 0000H
Start: MOV P2, #11101111B
ACALL DELAY_100ms
MOV P2, #11010111B
ACALL DELAY_100ms ; Note:
MOV P2, #10111011B ; P2 Connect with Active LOW LED Display
ACALL DELAY_100ms
MOV P2, #01111101B
ACALL DELAY_100ms
JMP Start
DELAY_100ms:
MOV R7, #64H
DELAY_1ms_1:
MOV R6, #0E6H
DELAY_1ms_2:
NOP
NOP
DJNZ R6, DELAY_1ms_2
DJNZ R7, DELAY_1ms_1
RET
Sample Program
• ; Program to paint memory area with integer number.
• ; Then use subroutine to check, if found letter (A-F)
• ; then change that byte to #60H
• ORG 00H
• MOV A, #0H
• MOV R0, #30H
• L_Paint:
• MOV @R0, A
• ACALL ADJUST
• INC R0
• INC A
• CJNE A, #60H, L_Paint
• SJMP $
• ADJUST:
• PUSH Acc
• MOV A,@R0
• ANL A,#0FH
• SUBB A,#09H
• JC SKIP_Adjust
• MOV @R0,#60H
• SKIP_Adjust:
• POP Acc
• RET
• END
Sample Program
; Program DIGITAL count-up to Port 1 (LED); Push SW1 (P0.0) to start ; R2 Control the speed by press D3 to Increase, Push D4
to Decrease speed
ORG 0000H
MOV R2, #0FFH
Start: MOV P1, #000H
MOV R0, #00H
in : MOV P1, R0
JNB P0.3, SKIP
MOV A, R2
SUBB A, #10H ; Increase speed of Delay
MOV R2, A
JMP SKIP
JNB P0.4, SKIP
MOV A, R2
ADD A, #10H ; Decrease speed of Delay
MOV R2, A
SKIP:
ACALL DELAY1
INC R0
CJNE R0, #0255D, in
JMP Start
DELAY1:
MOV A, R2
MOV R7, A
DELAY_1ms_1:
MOV R6, #0E6H
DELAY_1ms_2:
NOP
NOP
DJNZ R6, DELAY_1ms_2
DJNZ R7, DELAY_1ms_1
RET
END
Sample Question
• Program to
A. Fill value #F0 to #FFH to memory address 20h to 2Fh
B. Also Fill left shifted value of item A to to memory address 30h to 3Fh

More Related Content

What's hot

1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
bvenkanna
 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly language
hemant meena
 
8051 addressing modes
 8051 addressing modes 8051 addressing modes
8051 addressing modes
ghoshshweta
 

What's hot (20)

1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
 
1347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 80511347 Assembly Language Programming Of 8051
1347 Assembly Language Programming Of 8051
 
8051 basic programming
8051 basic programming8051 basic programming
8051 basic programming
 
subroutines and interrupts
subroutines and interruptssubroutines and interrupts
subroutines and interrupts
 
8051assembly language
8051assembly language8051assembly language
8051assembly language
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
Microcontroller instruction set
Microcontroller instruction setMicrocontroller instruction set
Microcontroller instruction set
 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly language
 
mup
mupmup
mup
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
Class2
Class2Class2
Class2
 
8051 instruction set
8051 instruction set8051 instruction set
8051 instruction set
 
Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontroller
 
Microprocessor Part 3
Microprocessor    Part  3Microprocessor    Part  3
Microprocessor Part 3
 
8051 Instruction Set
8051 Instruction Set8051 Instruction Set
8051 Instruction Set
 
Subroutine
SubroutineSubroutine
Subroutine
 
8051 addressing modes
 8051 addressing modes 8051 addressing modes
8051 addressing modes
 
Class10
Class10Class10
Class10
 
Lecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of InstructionsLecture 05 NOP and Stack Group of Instructions
Lecture 05 NOP and Stack Group of Instructions
 
Micro task1
Micro task1Micro task1
Micro task1
 

Similar to Microprocessor Week 8: Subroutine

Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
vijaydeepakg
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
vijaydeepakg
 
Micro controller based DAQ
Micro controller based DAQMicro controller based DAQ
Micro controller based DAQ
Murugappa Group
 
Solutionmanual8051microcontrollerbymazidi
Solutionmanual8051microcontrollerbymazidi Solutionmanual8051microcontrollerbymazidi
Solutionmanual8051microcontrollerbymazidi
Ahsan Mehmood
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
logesh waran
 
8051 micro controllers Instruction set
8051 micro controllers Instruction set 8051 micro controllers Instruction set
8051 micro controllers Instruction set
Nitin Ahire
 
Automatic light project
Automatic light projectAutomatic light project
Automatic light project
kspece0928
 

Similar to Microprocessor Week 8: Subroutine (20)

Microcontroller 8051- soft.ppt
Microcontroller 8051- soft.pptMicrocontroller 8051- soft.ppt
Microcontroller 8051- soft.ppt
 
lb instruments by using microcontroller , Rabi Moirangthem
lb instruments by using microcontroller , Rabi Moirangthemlb instruments by using microcontroller , Rabi Moirangthem
lb instruments by using microcontroller , Rabi Moirangthem
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
 
Microprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructionsMicroprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructions
 
Mic practicals
Mic practicalsMic practicals
Mic practicals
 
Buy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects OnlineBuy Embedded Systems Projects Online,Buy B tech Projects Online
Buy Embedded Systems Projects Online,Buy B tech Projects Online
 
MICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptxMICROCONTROLLERS-module2 (7).pptx
MICROCONTROLLERS-module2 (7).pptx
 
Micro controller based DAQ
Micro controller based DAQMicro controller based DAQ
Micro controller based DAQ
 
Microcontroller 8051 soft
Microcontroller 8051  softMicrocontroller 8051  soft
Microcontroller 8051 soft
 
Lec04
Lec04Lec04
Lec04
 
Lec04
Lec04Lec04
Lec04
 
Solutionmanual8051microcontrollerbymazidi
Solutionmanual8051microcontrollerbymazidi Solutionmanual8051microcontrollerbymazidi
Solutionmanual8051microcontrollerbymazidi
 
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02
Solutionmanual8051microcontrollerbymazidi 131215070701-phpapp02
 
8255 programming
8255 programming8255 programming
8255 programming
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
8051 micro controllers Instruction set
8051 micro controllers Instruction set 8051 micro controllers Instruction set
8051 micro controllers Instruction set
 
3 jump, loop and call instructions
3 jump, loop and call instructions3 jump, loop and call instructions
3 jump, loop and call instructions
 
Programs using Microcontrollers.ppt
Programs using Microcontrollers.pptPrograms using Microcontrollers.ppt
Programs using Microcontrollers.ppt
 
Automatic light project
Automatic light projectAutomatic light project
Automatic light project
 

More from Arkhom Jodtang

More from Arkhom Jodtang (15)

MCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016AMCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016A
 
Microprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsMicroprocessor Week 10: Applications
Microprocessor Week 10: Applications
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and Counter
 
Microprocessor Week 8: Advance programming
Microprocessor Week 8: Advance programmingMicroprocessor Week 8: Advance programming
Microprocessor Week 8: Advance programming
 
Microprocessor Week2: Data Transfer
Microprocessor Week2: Data TransferMicroprocessor Week2: Data Transfer
Microprocessor Week2: Data Transfer
 
Microprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and OperationMicroprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and Operation
 
Microprocessor Week1: Introduction
Microprocessor Week1: IntroductionMicroprocessor Week1: Introduction
Microprocessor Week1: Introduction
 
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
 
Microprocessor Week 4-5 MCS-51 Arithmetic operation
Microprocessor Week 4-5 MCS-51 Arithmetic operationMicroprocessor Week 4-5 MCS-51 Arithmetic operation
Microprocessor Week 4-5 MCS-51 Arithmetic operation
 
Use of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS WordUse of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS Word
 
Microprocessor: Delay technique
Microprocessor: Delay techniqueMicroprocessor: Delay technique
Microprocessor: Delay technique
 
Distance Measuring Car
Distance Measuring CarDistance Measuring Car
Distance Measuring Car
 
Microprocessor Week 7: Branch Instruction
Microprocessor Week 7: Branch InstructionMicroprocessor Week 7: Branch Instruction
Microprocessor Week 7: Branch Instruction
 
Tamech 2013 Presentation
Tamech 2013 PresentationTamech 2013 Presentation
Tamech 2013 Presentation
 
Electronics & Avionics project
Electronics & Avionics projectElectronics & Avionics project
Electronics & Avionics project
 

Recently uploaded

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
dharasingh5698
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 

Recently uploaded (20)

Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 

Microprocessor Week 8: Subroutine

  • 1. Subroutine MCS-51 Microcontroller By Arkhom JODTANG Civil Aviation Training Center, Thailand
  • 2. • Subroutines are a small part of program that able to call for use in multiple times. Subroutine1 Subroutine2 Subroutine3
  • 3. • Subroutines are contended as the part of main program. Main Program Subroutine1 Subroutine2 ORG 00H END
  • 4. Writing Subroutine • ACALL instruction to call subroutine – Use LCALL for longer then 2 kByte distance • Label, such as – Delay: – Multipli4X4Bytes: – CheckOnes: • RET instruction – RET will make return to the next instruction (After ACALL)
  • 5. Recording the Return Address • Stack will be use to record the return to main program address.
  • 6. Sample Program ORG 00H MOV R0, #30H Loop: ACALL DecimalAdj ACALL WriteData INC R0 INC A CJNE R0,#70H, Loop SJMP $ ; -------------------------------- DecimalAdj: CLR C DA A RET WriteData: MOV @R0, A RET END
  • 7. Sample Program ORG 0000H Start: MOV P2, #11101111B ACALL DELAY_100ms MOV P2, #11010111B ACALL DELAY_100ms ; Note: MOV P2, #10111011B ; P2 Connect with Active LOW LED Display ACALL DELAY_100ms MOV P2, #01111101B ACALL DELAY_100ms JMP Start DELAY_100ms: MOV R7, #64H DELAY_1ms_1: MOV R6, #0E6H DELAY_1ms_2: NOP NOP DJNZ R6, DELAY_1ms_2 DJNZ R7, DELAY_1ms_1 RET
  • 8. Sample Program • ; Program to paint memory area with integer number. • ; Then use subroutine to check, if found letter (A-F) • ; then change that byte to #60H • ORG 00H • MOV A, #0H • MOV R0, #30H • L_Paint: • MOV @R0, A • ACALL ADJUST • INC R0 • INC A • CJNE A, #60H, L_Paint • SJMP $ • ADJUST: • PUSH Acc • MOV A,@R0 • ANL A,#0FH • SUBB A,#09H • JC SKIP_Adjust • MOV @R0,#60H • SKIP_Adjust: • POP Acc • RET • END
  • 9. Sample Program ; Program DIGITAL count-up to Port 1 (LED); Push SW1 (P0.0) to start ; R2 Control the speed by press D3 to Increase, Push D4 to Decrease speed ORG 0000H MOV R2, #0FFH Start: MOV P1, #000H MOV R0, #00H in : MOV P1, R0 JNB P0.3, SKIP MOV A, R2 SUBB A, #10H ; Increase speed of Delay MOV R2, A JMP SKIP JNB P0.4, SKIP MOV A, R2 ADD A, #10H ; Decrease speed of Delay MOV R2, A SKIP: ACALL DELAY1 INC R0 CJNE R0, #0255D, in JMP Start DELAY1: MOV A, R2 MOV R7, A DELAY_1ms_1: MOV R6, #0E6H DELAY_1ms_2: NOP NOP DJNZ R6, DELAY_1ms_2 DJNZ R7, DELAY_1ms_1 RET END
  • 10. Sample Question • Program to A. Fill value #F0 to #FFH to memory address 20h to 2Fh B. Also Fill left shifted value of item A to to memory address 30h to 3Fh