Here is a set of delay sub-routines that will cover almost every need. You can call a delay routine a number of times to increase the delay or combine any delays to create the desired time. Each delay routine needs 1, 2, 3 or 4 files and these are named d1, d2, d3, and d4.
At the beginning of your assembly program, assign d1, d2, d3, and d4 as follows:
d1 equ 21h d2 equ 22h d3 equ 23h d4 equ 24h
Clock frequency = 4MHz means the instructions are processed at one million instructions per second. One instruction is also called one cycle in this discussion.
Note: d1, f
means the result obtained when file d1 is decremented, is placed in the file d1.
Note: 0xC7
means the hex value: C7 and this is equal to 199.
Note: goto $+1
means to go to the next instruction and this takes 2 cycles.
Note: goto $+2
means jump the next instruction and this takes 2 cycles.
Note: goto $+3
means jump two instructions and this takes 2 cycles.
Click HERE for a .txt file that can be copied and pasted.
Quick Links
Legal Stuff
Social Media