]> cloudbase.mooo.com Git - avrcpm.git/blob - cpm/utils/ACT.MAC
* I2C Support added
[avrcpm.git] / cpm / utils / ACT.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 TIMERCTL equ 040h
9 DEBUGPORT equ 04FH
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 StartTraceCmd equ 1
22 StopTraceCmd equ 0
23
24 aseg
25 org 100h
26
27 jp start
28
29 usage: db 'Usage: TIMER S|P|B|Q|U|T|N',cr,lf
30 db ' S = (Re)Start the timer',cr,lf
31 db ' P = Print elapsed time since last S or Q command',cr,lf
32 db ' B = Print elapsed time for simple benchmark loop. wait < 60s',cr,lf
33 db ' ATmega88 with 20MHz D0 = 035,999s',cr,lf
34 db ' Q = Print the timer, then restart it',cr,lf
35 db ' U = Print uptime',cr,lf
36 db ' T = Trace enable',cr,lf
37 db ' N = Trace disable',cr,lf,'$',1AH
38
39 start: ld a,(cmdLine) ; get number of characters on command line
40 or a
41 jp z,pusage ; print usage, if command line empty
42 ld a,(cmdLine+2) ; get first character
43 cp 'B'
44 jp z,bench
45 ld b,a
46 ld hl,table ; <HL> points to (letter, port, command)
47 again: ld a,(hl) ; compare command line letter with table entry
48 inc hl ; point to command
49 cp b
50 jp z,found ; if found
51 inc hl ; otherwise proceed to next entry
52 inc hl
53 cp '$' ; end of table?
54 jp nz,again ; try next character
55
56 pusage: ld de,usage ; address of usage text
57 ld c,printStringCmd ; CP/M command for print
58 jp bdos ; print it, get ret from bdos
59
60 found: ld a,(hl) ; get timer command
61 inc hl
62 ld (port),a
63 ld a,(hl)
64 db 0D3H ;"out (port),a"
65 port: db 0
66 ret
67
68 bench:
69 ld a,startTimerCmd
70 out (TIMERCTL),a ; start timer
71 ; loop starts here
72 ld c,10
73 l1: ld b,0
74 l2: ld a,0
75 l3: dec a
76 jp nz,l3 ; 256 x
77 dec b
78 jp nz,l2 ; 256 x
79 dec c
80 jp nz,l1 ; 10 x
81 ; loop ends here
82 ld a,printTimerCmd
83 out (TIMERCTL),a ; print elapsed time
84 ret ; and done
85
86 table:
87 db 'N',DEBUGPORT,StopTraceCmd
88 db 'T',DEBUGPORT,StartTraceCmd
89 db 'S',TIMERCTL,starttimercmd
90 db 'P',TIMERCTL,printTimerCmd
91 db 'Q',TIMERCTL,quitTimerCmd
92 db 'U',TIMERCTL,uptimeCmd
93 db '$' ; Stop mark
94
95 timend equ $
96 ds ((timend+127) and 0ff80h)-timend ; fill remainder with zeroes
97
98 end
99 ; vim:set ts=8 noet nowrap
100