OpenCores
URL https://opencores.org/ocsvn/blue/blue/trunk

Subversion Repositories blue

[/] [blue/] [trunk/] [blue8/] [bluemon.asm] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 wd5gnr
/* Monitor V0.4 */
2
/* Note: because of the monitors relocation
3
   You can't use the # form of immediate addressing now
4
   supported by the assembler */
5
 
6
#define CODEOFFSET 0xED0
7
#define FIRSTCODE 0xED1
8
#include "blue.inc"
9
 
10
 
11
        ORG 0
12
start:  jmp reload
13
        DEFSTACK
14
        ;; Need to eventually copy all code to top of memory
15
        call print_msgcr+CODEOFFSET
16
        ds "Blue Monitor 0.4\xFF"
17
prompt: call print_msg+CODEOFFSET
18
        ds "\r\r\nBLUE> \xFF"
19
prompt0:
20
        call waitcharecho+CODEOFFSET
21
        JMPIF(lf+CODEOFFSET,prompt0+CODEOFFSET)
22
        JMPIF(space+CODEOFFSET,prompt0+CODEOFFSET)
23
        ior makelower+CODEOFFSET
24
        JMPIF(cmdl+CODEOFFSET,load+CODEOFFSET)
25
        JMPIF(cmdd+CODEOFFSET,dump+CODEOFFSET)
26
        JMPIF(cmdg+CODEOFFSET,go+CODEOFFSET)
27
        JMPIF(cmdi+CODEOFFSET,intel+CODEOFFSET)
28
        ;; unknown command
29
        call print_msgcr+CODEOFFSET
30
        ds "?\xFF"
31
        jmp prompt+CODEOFFSET
32
 
33
        ;; load command (ESC ends)
34
load:   call hexin4+CODEOFFSET                  ; set X=address
35
        ldxa
36
load1:
37
        call hexin4+CODEOFFSET          ; get next word
38
        lda numin+CODEOFFSET            ; get number
39
        stax                    ; put it away
40
        incx                    ; next word
41
        lda hexsep+CODEOFFSET           ; if escape goto prompt
42
        JMPIF(escape+CODEOFFSET,prompt+CODEOFFSET)
43
        jmp load1+CODEOFFSET            ; keep going
44
 
45
        ;; dump command
46
dump:
47
        call hexin4+CODEOFFSET          ; get address
48
        ldxa
49
        ;;  would like to spin excess 8 words
50
dump1:
51
        stx                     ; see if are on xx0 or xx8
52
        and bits3+CODEOFFSET
53
        sz
54
        jmp dump2+CODEOFFSET
55
        ;;  do we want out? -- only test at end of lines
56
        lda uart+1
57
        spos
58
        jmp prompt+CODEOFFSET
59
 
60
        ;; new line
61
        call hexaddr+CODEOFFSET
62
dump2:
63
        ldax                    ; get word
64
        call hexout4+CODEOFFSET ; print it
65
        ldi ' '                 ; space
66
        call printchar+CODEOFFSET
67
        incx                    ; next word
68
        jmp dump1+CODEOFFSET            ; keep going
69
 
70
        ;; show XXXX:   (address)
71
hexaddr:
72
        call crlf+CODEOFFSET
73
        stx
74
        call hexout4+CODEOFFSET
75
        ldi ':'
76
        call printchar+CODEOFFSET
77
        ldi ' '
78
        jmp printchar+CODEOFFSET
79
 
80
 
81
        ;; go command
82
        ;; escape cancels
83
go:     call hexin4+CODEOFFSET
84
        lda hexsep+CODEOFFSET           ; see if we cancelled
85
        cmp escape+CODEOFFSET
86
        snz
87
        jmp prompt+CODEOFFSET
88
        lda numin+CODEOFFSET            ; nope. get number and jump
89
        jmpa
90
 
91
intel:  call waitcharecho+CODEOFFSET
92
        cmp escape+CODEOFFSET
93
        snz
94
        jmp prompt+CODEOFFSET
95
        cmp colon+CODEOFFSET
96
        sz
97
        jmp intel+CODEOFFSET
98
        ldi 2
99
        call hexinct+CODEOFFSET
100
        ;; count of bytes
101
        rar                     ; divide by 2
102
        and hexnib+CODEOFFSET   ;  max of 16
103
        sta icount+CODEOFFSET
104
        ldi 4
105
        call hexinct+CODEOFFSET
106
        rar                     ;  divide by 2
107
        push
108
        popx
109
        ldi 2
110
        call hexinct+CODEOFFSET
111
        add hexzero+CODEOFFSET
112
        sz
113
        jmp inteldone+CODEOFFSET
114
intelloop:
115
        ldi 4
116
        call hexinct+CODEOFFSET
117
        stax
118
        incx
119
        lda icount+CODEOFFSET
120
        deca
121
        sta icount+CODEOFFSET
122
        sz
123
        jmp intelloop+CODEOFFSET
124
        jmp intel+CODEOFFSET    ; ignore checksum crlf
125
inteldone:
126
        call waitcharecho+CODEOFFSET
127
        cmp lf+CODEOFFSET
128
        sz
129
        jmp inteldone+CODEOFFSET
130
        jmp prompt+CODEOFFSET
131
 
132
 
133
        ;; commands
134
cmdl:   dw 'l'
135
cmdd:   dw 'd'
136
cmdg:   dw 'g'
137
cmdi:   dw 'i'
138
colon:  dw ':'
139
        ;; cancel key
140
escape: dw 0x1b
141
        ;; bit to OR to make upper case lower case
142
makelower:      dw 0x20
143
        ;; constants
144
zero:   dw '0'
145
hexzero:        dw 0
146
nine:   dw '9'
147
hexa:   dw 'a'
148
hexmask:        dw 0xFFF0
149
// The below doesn't work because lf isn't defined in pass1
150
//ten:  equ lf
151
#define ten lf
152
hexnib:  dw 0xF
153
bits3:  dw 0x7
154
 
155
        ;; number in winds up here (and in ACC)
156
numin:  dw 0
157
 
158
hextmp: dw 0
159
hextmp2: dw 0
160
hexsep: dw 0                    ; hexin separator
161
bs:     dw 8
162
hexct:  dw 4
163
mask3:   dw 0xFFF
164
icount: dw 0
165
space:  dw ' '
166
 
167
        ;; read 4 hex characters, result in acc and numin
168
        ;; also set hexsep to the "ending character" (e.g., space, CR, etc.)
169
hexin4: ldi 0xFFFF
170
hexinct:
171
        sta hexct+CODEOFFSET
172
        ldi 0                   ; clear acc
173
        sta numin+CODEOFFSET            ; store acc
174
hexinl:
175
        call waitcharecho+CODEOFFSET    ; get character
176
        JMPIF(space+CODEOFFSET,hexinl+CODEOFFSET)
177
        SKIP
178
hexinl2:        call waitcharecho+CODEOFFSET ;  character after first
179
        cmp bs+CODEOFFSET
180
        snz
181
        jmp hexbs+CODEOFFSET
182
        cmp zero+CODEOFFSET             ; if <'0' then done
183
        snz
184
        jmp hexin09+CODEOFFSET
185
        sc
186
        jmp hexin4done+CODEOFFSET
187
        cmp nine+CODEOFFSET             ; if <='9' then number
188
        sc
189
        jmp hexin09+CODEOFFSET
190
        snz
191
        jmp hexin09+CODEOFFSET
192
        ;; TODO:         need to test that not above 'F'
193
        ;; if here we have a non number (A-F)
194
        ior makelower+CODEOFFSET                ;  make lower case
195
        sub hexa+CODEOFFSET
196
        sc
197
        jmp hexin4done+CODEOFFSET
198
        add ten+CODEOFFSET
199
        SKIP
200
hexin09:
201
        sub zero+CODEOFFSET
202
        sta hextmp+CODEOFFSET
203
        lda numin+CODEOFFSET            ; shift number over
204
        ral
205
        ral
206
        ral
207
        ral
208
        and hexmask+CODEOFFSET
209
        ior hextmp+CODEOFFSET           ; put in our current number
210
        sta numin+CODEOFFSET            ; store acc
211
        lda hexct+CODEOFFSET
212
        deca
213
        sta hexct+CODEOFFSET
214
        sz
215
        jmp hexinl2+CODEOFFSET
216
hexin4done:
217
        sta hexsep+CODEOFFSET           ; remember why we quit
218
        lda numin+CODEOFFSET            ; load the number and return
219
        ret
220
 
221
hexbs:  lda numin+CODEOFFSET
222
        rar
223
        rar
224
        rar
225
        rar
226
        and mask3+CODEOFFSET
227
        sta numin+CODEOFFSET
228
        ;; assume hextct will equal FFFF if backspaces occur
229
        jmp hexinl2+CODEOFFSET
230
 
231
        ;; print out 4 hex digits
232
hexout4:        sta hextmp+CODEOFFSET
233
                swap
234
                call hexout2+CODEOFFSET
235
                lda hextmp+CODEOFFSET
236
hexout2:        sta hextmp2+CODEOFFSET
237
                rar
238
                rar
239
                rar
240
                rar
241
                call hexout1+CODEOFFSET
242
                lda hextmp2+CODEOFFSET
243
hexout1:        and hexnib+CODEOFFSET
244
                cmp ten+CODEOFFSET
245
                snc
246
                jmp hexouta+CODEOFFSET
247
                add zero+CODEOFFSET
248
                jmp printchar+CODEOFFSET
249
hexouta:        sub ten+CODEOFFSET
250
                add hexa+CODEOFFSET
251
                jmp printchar+CODEOFFSET        ;  hidden return
252
 
253
 
254
 
255
 
256
#include "syslib.inc"
257
reload: ldx 0
258
reloadx:
259
        ldax 0
260
        stax CODEOFFSET
261
        incx
262
        stx
263
        sub limit
264
        sz
265
        jmp reloadx
266
        jmp FIRSTCODE
267
 
268
limit:  dw reload
269
 
270
        END

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.