annotate 3rdparty/p2mods/os9p4_regdump.asm @ 0:6641a883d6b0

Initial revision
author boisy
date Thu, 04 Apr 2002 16:34:12 +0000
parents
children 1f8438c88938
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
2 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
3 * Copyright February,1989 by Ron Lammardo
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
4 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
5 * This system call can be used in an application program to dump the
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
6 * current contents of all user registers in Hex,Decimal,Binary and Ascii
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
7 * (Registers "A" and "B" Only). This module MUST be present in the
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
8 * bootfile. If no OS9P3 module is found,change the "mname" and "nextname"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
9 * as appropriate.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
10 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
11 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
12 * If there is a conflict with the code used for this system called, it can
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
13 * be changed by resetting the equate at "F$RegDmp"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
14 *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
15 * NOTE: All registers EXCEPT 'CC' are preserved....OS9 internally resets
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
16 * the condition code register upon service call exit.
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
17
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
18 nam os9p4
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
19 ttl User Register Dump System Call for OS9 Level-II
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
20
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
21 ifp1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
22 use os9defs.l2v3
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
23 endc
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
24
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
25 typelang set systm+objct
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
26 attrev set reent+revision
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
27 revision set 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
28 edition set 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
29
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
30 mod Eom,Mname,Typelang,Attrev,Start,0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
31
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
32 mname
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
33 fcs /OS9P4/ name of this module
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
34 fcb edition
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
35
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
36 svctabl
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
37 fcb F$RegDmp F$RegDmp code
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
38 fdb regdmp-*-2 offset to actual code
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
39 fcb $80 end of table
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
40
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
41 start
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
42 leay <svctabl,pcr point to service table
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
43 os9 F$SSvc insert the new op code in the table
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
44 lda #typelang get next module type (same as this one!)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
45 leax <nextname,pcr get address of next module name
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
46 os9 F$Link attempt to link to it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
47 bcs endsetup no good...skip this
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
48 jsr ,y else go execute it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
49
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
50 endsetup
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
51 rts return back to previous module
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
52
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
53 nextname
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
54 fcc /OS9P5/ next module name to link to
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
55 fcb $0d
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
56
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
57 regdmp equ *
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
58 pshs cc,a,b,dp,x,y,u save all registers
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
59 tfr u,y transfer addresses
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
60 leas -60,s back up for some variable storage
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
61 leau 4,s buffer starts here
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
62 clr ,u+ set flag to print ascii char
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
63 lda #$20 get a space
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
64 ldb #50 number of chars to clear
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
65 tfr u,x set register for loop
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
66
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
67 clrloop
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
68 sta ,x+ initialize a space
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
69 decb decrement counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
70 bne clrloop if more..loop back & clear another
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
71 lbsr reg060 send a <cr>
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
72 leax reg080,pcr point to start of control table
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
73 clra clear msb of register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
74 ldb R$A,y get register from stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
75 bsr reg000 dump register A
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
76 ldb R$B,y get register from stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
77 bsr reg000 dump regsietr B
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
78 inc -1,u turn off ascii char print flag
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
79 ldd R$X,y get register from stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
80 bsr reg000 dump register X
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
81 ldd R$Y,y get register from stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
82 bsr reg000 dump regisetr Y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
83 ldd R$U,y get register from stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
84 bsr reg000 dump register U
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
85 ldb R$CC,y get register from stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
86 bsr reg000 dump register CC
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
87 ldb R$DP,y get register from stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
88 bsr reg000 dump register DP
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
89 ldd R$PC,y get user Task Number
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
90 bsr reg000 dump register PC
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
91 ldy <D.Proc get address of users process descriptor
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
92 ldd P$Sp,y get users stack address
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
93 addd #12 add on for registers which were saved
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
94 bsr reg000 dump register S
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
95 lbsr reg060 send a <CR>
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
96 leas 60,s restore stack pointer
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
97 puls cc,a,b,dp,x,y,u,pc restore all registers and return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
98
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
99 * Dump a register in "D"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
100 * X = Control Table Location
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
101 * U = Output buffer Location
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
102
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
103 reg000
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
104 pshs y save y register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
105 tfr d,y register in y
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
106 lda ,x # of bytes
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
107 leax 3,x point past table entry
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
108 pshs a,x,y,u save registers
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
109 ldd -2,x get register name
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
110 std ,u++ move to buffer
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
111 ldd #"=$ get chars
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
112 std ,u++ move to buffer
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
113 ldd 3,s get reg
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
114 lbsr gethex convert to hex
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
115 tst 0,s 1 byte ?
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
116 bne reg010 no...skip this
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
117 ldd 2,u get 2 lsb's
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
118 std ,u store in msb's
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
119 ldd #$2020 get two blanks
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
120 std 2,u store in lsb's
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
121
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
122 reg010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
123 ldd #$2023 get a space and "#"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
124 std 4,u move in two spaces
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
125 leau 6,u point to start of decimal output buffer
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
126 ldd 3,s get register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
127 lbsr getdec convert to decimal
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
128 tst 0,s is it one byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
129 bne reg020 no..skip this
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
130 ldd 2,u else get third & fourth chars
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
131 std ,u store as first two
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
132 lda 4,u get fifth char
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
133 sta 2,u store as third
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
134 ldd #$2020 get two spaces
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
135 std 3,u store as 4th & 5th chars
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
136
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
137 reg020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
138 ldd #$2025 get a blank & "%"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
139 std 5,u move it to buffer
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
140 leau 7,u point to start of binary output area
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
141 tfr a,b space in 'b'
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
142 std 16,u space out ascii char
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
143 ldd 3,s get register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
144 bsr getbin convert to binary
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
145 tst 0,s check byte count
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
146 bne reg040 skip if two bytes
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
147 ldb #8 loop counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
148
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
149 reg030
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
150 lda 8,u get two chars from second 8 digits
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
151 sta ,u+ store in first 8 digits
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
152 lda #$20 get two blanks
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
153 sta 7,u store in second 8 digits
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
154 decb decrement counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
155 bne reg030 loop back if not done
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
156 leau -8,u back up to beginning of binary digit output
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
157 ldb 4,s get lsb of register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
158 tst -18,u check if we want to print ascii char
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
159 bne reg040 nope..skip this
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
160 cmpb #$20 compare char with space
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
161 blo reg040 if lower..skip this
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
162 cmpb #'z compare with last alpha char
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
163 bhi reg040 if higher..skip this
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
164 stb 17,u else store the char
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
165
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
166 reg040
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
167 lda #$0d get a <cr>
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
168 sta 18,u and store it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
169 leax -17,u back up to buffer start
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
170 bsr reg070 send it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
171 clra clear msb for next reg
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
172 puls b,x,y,u restore registers
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
173 puls y,pc restore y & return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
174
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
175 reg050
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
176 fcb $0d
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
177
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
178 reg060
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
179 leax <reg050,pcr point to <cr>
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
180
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
181 reg070
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
182 pshs x,y,u,a,b save registers
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
183 ldy <D.Proc get process descriptor address
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
184 lda P$Path+2,y get user error path number
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
185 pshs a save it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
186 ldu P$Sp,y get user stack address
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
187 leau -50,u back off to make room
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
188 lda <D.SysTsk get system task number
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
189 ldb P$Task,y get users task number
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
190 ldy #40 chars to move
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
191 os9 F$Move move from system to user space
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
192 tfr u,x restore buffer address
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
193 puls a restore user error path number
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
194 os9 I$WritLn send it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
195 puls x,y,u,a,b,pc restore registers & return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
196
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
197 * Control Table - Format is :
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
198 * Byte count (0=1,1=2)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
199 * Register name (Two chars)
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
200
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
201 reg080
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
202 fcb 0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
203 fcc /a /
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
204 fcb 0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
205 fcc /b /
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
206 fcb 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
207 fcc /x /
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
208 fcb 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
209 fcc /y /
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
210 fcb 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
211 fcc /u /
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
212 fcb 0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
213 fcc /cc/
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
214 fcb 0
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
215 fcc /dp/
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
216 fcb 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
217 fcc /pc/
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
218 fcb 1
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
219 fcc /s /
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
220
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
221
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
222 * Convert "D" to binary digits in buffer "U"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
223
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
224 getbin
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
225 pshs u,b save 'u', second byte of register
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
226 bsr bin010 convert first byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
227 puls a get second byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
228 bsr bin010 convert it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
229 puls u,pc restore 'u' and return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
230
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
231 bin010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
232 bita #%10000000 check bit
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
233 bsr bin020 print result
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
234 bita #%01000000
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
235 bsr bin020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
236 bita #%00100000
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
237 bsr bin020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
238 bita #%00010000
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
239 bsr bin020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
240 bita #%00001000
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
241 bsr bin020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
242 bita #%00000100
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
243 bsr bin020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
244 bita #%00000010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
245 bsr bin020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
246 bita #%00000001
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
247
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
248 bin020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
249 beq bin030 skip this if bit was set
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
250 ldb #'1 else get an ascii '1'
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
251 bra bin040 skip next
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
252
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
253 bin030
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
254 ldb #'0 bit not set...get an ascii '0'
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
255
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
256 bin040
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
257 stb ,u+ store the ascii char
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
258 rts
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
259
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
260 * Convert "D" to 4 hex digits in buffer "U"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
261
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
262 gethex
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
263 pshs u,b save 'u',second register byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
264 bsr gth010 convert first byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
265 puls a restore second byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
266 bsr gth010 convert it
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
267 puls u,pc restore 'u' and return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
268
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
269 gth010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
270 pshs a save the byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
271 lsra shift left 4 bits to right
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
272 lsra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
273 lsra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
274 lsra
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
275 bsr gth020 convert to hex digit
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
276 puls a restore the byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
277 anda #$0f strip off high 4 digits
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
278
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
279 gth020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
280 adda #'0 make it ascii
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
281 cmpa #$3a is it a letter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
282 blt gth030 nope..skip this
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
283 adda #7 else add bias
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
284
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
285 gth030
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
286 sta ,u+ store the ascii character
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
287 rts return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
288
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
289 * Convert "D" to 5 decimal digits in buffer at "U"
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
290
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
291
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
292 getdec
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
293 pshs x,y,u save registers
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
294 ldx #10000 get decimal number for subtraction
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
295 bsr gtd010 get the decimal digit
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
296 ldx #01000
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
297 bsr gtd010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
298 ldx #00100
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
299 bsr gtd010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
300 ldx #00010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
301 bsr gtd010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
302 ldx #00001
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
303 bsr gtd010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
304 puls x,y,u,pc restore registers & return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
305
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
306 gtd010
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
307 pshs x,a save x register & extra byte
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
308 clr ,s clear counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
309
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
310 gtd020
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
311 cmpd 1,s compare 'd' with 'x' on stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
312 blo gtd030 less...skip this
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
313 subd 1,s else subtract number on stack
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
314 inc ,s increment digit counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
315 bra gtd020 and loop back
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
316
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
317 gtd030
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
318 std 1,s save remainder of number
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
319 ldb ,s+ get counter
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
320 addb #$30 make it ascii
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
321 stb ,u+ and move it as output
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
322 puls d,pc restore remainder & return
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
323
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
324 emod
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
325 eom
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
326 end
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
327
6641a883d6b0 Initial revision
boisy
parents:
diff changeset
328