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