]> cloudbase.mooo.com Git - avrcpm.git/blob - cpm/utils/timer.mac
* Test: Change directory hierarchy
[avrcpm.git] / cpm / utils / timer.mac
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
9 TIMERCTL: equ 040h
10
11 printStringCmd: equ 09h
12 bdos: equ 5
13 cr: equ 13
14 lf: equ 10
15 cmdLine: equ 80h
16 starttimercmd: equ 1
17 quitTimerCmd: equ 2
18 printTimerCmd: equ 15
19 uptimeCmd: equ 16
20
21 ; aseg
22 org 100h
23
24 jp start
25
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
31
32 start: 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
38 again: 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
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
49 ret ; and done
50
51 table: db 'S',starttimercmd
52 db 'P',printTimerCmd
53 db 'Q',quitTimerCmd
54 db 'U',uptimeCmd
55 tabsize: equ ($-table)/2
56
57 timend: equ $
58 ds 0200h-timend ; fill remainder with zeroes
59
60 end
61
62 ; vim:set ts=8 noet nowrap
63