2 ; ASM dialect is for crasm/z80, producing Intel HEX.
3 ; Compile using "crasm -o tiktok.hex tiktok.asm" and transfer
4 ; to CP/M system for final conversion to COM file using LOAD.COM
6 ; A sample program that uses a busy-waiting spinloop
7 ; to produce 1ms delays. 5*200 iterations of calls to
8 ; the delay loop is made, to provide a 1sec delay per "Tick".
9 ; 60 iterations of printint "Tick" to the console is done
10 ; for a full minute of waiting time.
11 ; Console output is done using CP/M BDOS call 9 (C_WRITRSTR)
20 ; Start COM file at TPA start (Origin 0x100)
33 LD B, 5 ; 5 * 200 msec = 1000ms = 1 sec :P
49 ; Delay routine, A register contains number of Delay iterations.
50 ; Does not clobber, but A is reduced to zero on completion
51 ; Values tried (may be good) for 7.3728MHz: C=13, B=44
52 DELAY PUSH BC ; Save B and C registers
53 DLY_START LD C, 13 ; Coarse factor
54 DLY_LOOPO LD B, 44 ; Fine factor
55 DLY_LOOPI DJNZ DLY_LOOPI ; Decrement B until BZero
56 DEC C ; Decrement C ..
57 JR NZ, DLY_LOOPO ; .. until zero
58 DEC A ; Do next main iteration
59 JR NZ, DLY_START ; until given numer is zero
60 POP BC ; Restore B and C registers
61 RET ; Return from delay.
63 ; String constants here, to avoid having them clobber $100H
64 ; Note CP/M BDOS call 9 format, $ is string terminator.
65 STARTMSG ASC "Timertest\r\n$"
66 MESSAGE ASC "Tick\r\n$"
67 STOPMSG ASC "Done\r\n$"