-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonitor.i
More file actions
212 lines (173 loc) · 5.04 KB
/
monitor.i
File metadata and controls
212 lines (173 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
;
; monitor.i
;
;
; include file for Amiga Monitor
; version 1.60 -- 1993-06-06
; Copyright © 1993 by Timo Rossi
;
ifnd EXEC_TYPES_I
include "exec/types.i"
endc
ifnd DOS_DOSEXTENS_I
include "dos/dosextens.i"
endc
include "mon_macros.i"
*** macro to display a single character ***
emit macro
moveq #\1,D0
call ChrOut
endm
emitwin macro
moveq #\1,d0
call ChrOutWin
endm
*** start output line ***
startline macro
lea mon_OutputBuf(a4),a3
endm
*** end output line (line feed+NULL) ***
endline macro
putchr LF
clr.b (A3)
endm
putchr macro
move.b #\1,(a3)+
endm
;
; define a command label
;
cmd macro
xdef \1_cmd
\1_cmd ;equ *
endm
; some common ASCII control characters
BS equ 8
TAB equ 9
LF equ $0a
FF equ $0c
CR equ $0d
DEL equ $7f
ESC equ $1b
CSI equ $9b
*** SOME SPECIAL CHARACTERS ***
CtrlC equ 3 ;control-c, break
CtrlE equ 5 ;control-e, edit existing assembler instruction
CtrlQ equ 17 ;control-q, xon
CtrlS equ 19 ;control-s, xoff
CtrlX equ 24 ;control-x, clear input line
SPACE equ 32
COMMA equ ','
LEN equ 128 ;length of input & output buffers
NLINES equ 20 ;number of lines of command line history
DNBUFSIZE equ 50 ;length of disk device name buffer
DISKBLOCKSIZE equ 512 ; 9
DISKBLOCKSHIFT equ 9 ;2 = 512
BOOTBLOCKSIZE equ 2*DISKBLOCKSIZE
MONSTACK equ 2000
ILLEGAL_INSTR equ $4AFC ;illegal instruction (used by breakpoints)
** Data structure containing all monitor internal variables **
STRUCTURE MonitorData,0
; first the long word variables
APTR _ExecBase ;Exec library base
APTR _DosBase ;DOS library base
APTR _ExpansionBase ;Expansion library base
APTR mon_WBenchMsg ;Workbench startup message pointer
APTR mon_Task ;pointer to TCB of monitor process
LONG mon_StackSize ;monitor stack size
APTR mon_OrigRetAddr ;monitor process pr_ReturnAddr
;when monitor was started
APTR mon_OrigTrapCode ;original task trap code ptr
APTR mon_OrigTrapData ;original task user data ptr
LONG mon_OrigCD ;original current dir (BPTR)
;(-1 if no change)
LONG mon_OrigConTask ;original pr_ConsoleTask
LONG mon_WinFile ;main window file handle
LONG mon_OutputFile ;current output file handle
APTR mon_ConsoleUnit ;console device unit pointer for main window
APTR mon_StackPtr ;saved monitor stack pointer
APTR mon_InitialFileName ;file name given in command line
APTR mon_InitialScriptName ;file name given in -s option
LONG mon_SegList ;currently loaded
;exefile seglist (BPTR)
LONG mon_NumHunks ;number of hunks in currently
;loaded exefile segment list
APTR mon_HunkTypeTable ;pointer to array of hunk type
;values, used only if '+'-option
;of the 'l'-command has been used
APTR mon_MemoryList ;linked list of allocated memory
APTR mon_BreakList ;linked list of breakpoints
APTR mon_VarList ;linked list of variables
APTR mon_ScriptList ;linked list of currently active scripts
APTR mon_CurrentAddr ;current address
APTR mon_EndAddr ;for disassembler & memdisplay
APTR mon_StackHigh ;high limit of stack used
;by g- and j-commands
APTR mon_TempBreakAddr ;address of temporary breakpoint
APTR mon_GoBreakPtr ;address of skipped brkpoint struct
APTR mon_RelBaseAddr ;address pointed by a4 or other base reg
;
; the following two variables are for the disassemble routine
; (to avoid some kludges...)
;
APTR mon_dis_StackStore
APTR mon_dis_Addr1
;
STRUCT mon_FakeFH,fh_SIZEOF ;this must be longword aligned
APTR mon_OldFhBuf
LONG mon_OldPos
LONG mon_OldEnd
; the output buffer must be long word aligned
STRUCT mon_OutputBuf,LEN
STRUCT mon_InputBuf,LEN
STRUCT mon_History,LEN*NLINES
STRUCT mon_CmdLineBuf,LEN
STRUCT mon_DevNameBuf,DNBUFSIZE
; processor register storage
STRUCT mon_DataRegs,8*4 ;data registers
STRUCT mon_AddrRegs,8*4 ;address registers
mon_RegSP equ mon_AddrRegs+7*4
APTR mon_RegPC ;program counter
;
; note: the following is because move ea,ccr moves a word and ignores
; the high byte of it...
;
UBYTE mon_RegCCR_W
UBYTE mon_RegCCR_B ;condition code register
; now word and byte variables
UWORD mon_TempBreakSave ;storage for original contents
;of a temporary breakpoint
UBYTE mon_Flags ;flags, see below for bitdefs...
UBYTE mon_DefNumBase ;current default number base for input
UBYTE mon_Options ;option flags
UBYTE mon_RelBaseReg ;base register, works with RelBaseAddr
;-1 if not in use
LABEL MonitorData_SIZE
;
; Hmm.. I think that I put this check here for a good reason, but I can't
; remember what is was... probably a bug in assembler or something...
;
ifne MonitorData_SIZE-$cb6
fail Panic! MonitorData wrong size!
endc
;
; monitor flags
;
BITDEF MON,BRKACTIVE,0
BITDEF MON,BRKSKIP,1
BITDEF MON,TMPBRK,2
BITDEF MON,QTRACE,3
BITDEF MON,OWNWINDOW,4
BITDEF MON,FIRSTCD,5
BITDEF MON,TASKSET,6
BITDEF MON,STARTUP,7
;
; Monitor option flags
;
BITDEF OPT,NARROWDIS,0
BITDEF OPT,EXTPRTCHR,1
BITDEF OPT,DUMBTERM,2
BITDEF OPT,CMDECHO,3
BITDEF OPT,STACKRESET,4
BITDEF OPT,ERRORSTOP,5
MON_NUM_OPTIONS equ 6