]> cloudbase.mooo.com Git - avrcpm.git/blame - cpm/utils/timer.mac
* cpm/Makefile
[avrcpm.git] / cpm / utils / timer.mac
CommitLineData
06644909
L
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.
3;
4; changed to assemble with z80asm
5;
6; .Z80 ; mnemonics only
7
8;SIMHPort equ 0feh
9TIMERCTL: equ 040h
10
11printStringCmd: equ 09h
12bdos: equ 5
13cr: equ 13
14lf: equ 10
15cmdLine: equ 80h
16starttimercmd: equ 1
17quitTimerCmd: equ 2
18printTimerCmd: equ 15
19uptimeCmd: equ 16
20
21; aseg
22 org 100h
23
24 jp start
25
26usage: 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
31
32start: ld a,(cmdLine) ; get number of characters on command line
33 or a
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
38again: cp (hl) ; compare command line letter with table entry
39 inc hl ; point to command
40 jp z,found ; if found
41 inc hl ; otherwise proceed to next entry
42 dec b ; decrement loop counter
43 jp nz,again ; try next character
44pusage: 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
47found: ld a,(hl) ; get SIMH command
48 out (TIMERCTL),a ; send to SIMH port
49 ret ; and done
50
51table: db 'S',starttimercmd
52 db 'P',printTimerCmd
53 db 'Q',quitTimerCmd
54 db 'U',uptimeCmd
55tabsize: equ ($-table)/2
56
57timend: equ $
58 ds 0200h-timend ; fill remainder with zeroes
59
60 end
61
62; vim:set ts=8 noet nowrap
63