; ********** DELAY SUBROUTINE ********** ; DELAYS 1 TO 65536 mS. ; ENTRY: (HL) = DELAY COUNT IN mS. ; 0 = 65536. ; ALL REGISTERS SAVED. ; ************************************** .ORG 0000h LD SP, 0080h ; ADDED FOR TESTING PURPOSES. LD HL, 100 ; ADDED FOR TESTING PURPOSES. CALL DELAY ; ADDED FOR TESTING PURPOSES. HALT ; ADDED FOR TESTING PURPOSES. DELAY: PUSH BC ; SAVE REGISTERS. PUSH DE PUSH HL LD DE, -1 ; -1 FOR DECREMENT. DEC HL ; ADJUST FOR "JP NC". DEL001: LD B, 131 ; INNER LOOP COUNT. DEL002: DJNZ DEL002 ; LOOP FOR DELAY. ADD HL, DE ; DECREMENT OUTER LOOP COUNT. JP C, DEL001 ; CONTINUE. POP HL ; RESTORE REGISTERS IN REVERSE ORDER. POP DE POP BC RET ; RETURN. .END