1 ; This is a utility program to control the timer of the AVR CP/M emulator.
2 ; This file is stolen from the SIMH AltairZ80 Simulator.
4 ; changed to assemble with z80asm
6 ; .Z80 ; mnemonics only
11 printStringCmd: equ 09h
26 usage: db 'Usage: TIMER S|P|Q|U',cr,lf
27 db ' S = (Re)Start the timer',cr,lf
28 db ' P = Print elapsed time since last S or Q command',cr,lf
29 db ' Q = Print the timer, then restart it',cr,lf
30 db ' U = Print uptime',cr,lf,'$',1AH
32 start: ld a,(cmdLine) ; get number of characters on command line
34 jp z,pusage ; print usage, if command line empty
35 ld a,(cmdLine+2) ; get first character
36 ld hl,table ; <HL> points to (letter, command)^3
37 ld b,tabsize ; nr elements in table
38 again: cp (hl) ; compare command line letter with table entry
39 inc hl ; point to command
41 inc hl ; otherwise proceed to next entry
42 dec b ; decrement loop counter
43 jp nz,again ; try next character
44 pusage: ld de,usage ; address of usage text
45 ld c,printStringCmd ; CP/M command for print
46 jp bdos ; print it, get ret from bdos
47 found: ld a,(hl) ; get SIMH command
48 out (TIMERCTL),a ; send to SIMH port
51 table: db 'S',starttimercmd
55 tabsize: equ ($-table)/2
58 ds 0200h-timend ; fill remainder with zeroes
62 ; vim:set ts=8 noet nowrap