;;Wait S in register sreg waits macro tms movlw tms movwf sreg call loops endm ;;WAIT MS in register msreg waitms macro tmms ;;literal tmms movlw tmms ;; move to W movwf msreg ;; into regester msreg now! call loopms ;; go! endm ;;Wait 10 * us in register usreg wait10us macro tmus ;;literal tmus movlw tmus ;; move to W movwf usreg ;; into usreg we go call loopus ;;loop de doo endm ;;the real code behind waits (sec wait) loops movlw d'250' ;;250 ms movwf msreg ;; load into millisec register call loopms ;; do it movlw d'250' ;;500 ms movwf msreg ;; load into millisec register call loopms ;; do it movlw d'250' ;;750 ms movwf msreg ;; load into millisec register call loopms ;; do it movlw d'250' ;;1000 ms/1 second movwf msreg ;; load into millisec register call loopms ;; do it decfsz sreg, f ;; decrement counter if = 0 then skip and end goto loops ;;jump back up return ;;EOM ;;the real code behind waitms (ms wait) loopms movlw d'100' ;;wait 100 * 10 micro seconds movwf usreg ;; load into 20 call loopus ;; do it decfsz msreg, 1 ;; decrement counter if = 0 then skip and end goto loopms ;;jump back up return ;;EOM ;;the real code behind waitus (10*x us) loopus nop ;;delay us for 7 us (4mhz) nop nop nop nop nop nop decfsz usreg,1 ;;decrement counter. if=0 then skip next line and end, 1 unless zero then 2 cycles goto loopus ;;jump back up, 2 cycles return ;;EOM!