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