wdc-utils/samples/stdio_test.lst
Kelvin Sherlock e693ad8ef3 more fixes...
2017-01-17 23:31:28 -05:00

564 lines
22 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Tue Jan 17 2017 23:30 Page 1
***************************************
** WDC 65C816 Macro Assembler **
** **
** Version 3.49.1- Feb 6 2006 **
***************************************
1 ;:ts=8
2 00000001 R0 equ 1
3 00000005 R1 equ 5
4 00000009 R2 equ 9
5 0000000D R3 equ 13
6 ;#include <stdio.h>
7 ;#include <fcntl.h>
8 ;
9 ;
10 ;void main(void) {
11 code
12 xdef ~~main
13 func
14 ~~main:
15 longa on
16 longi on
17 00:0000: 3B tsc
18 00:0001: 38 sec
19 00:0002: E9 08 00 sbc #L2
20 00:0005: 1B tcs
21 00:0006: 0B phd
22 00:0007: 5B tcd
23 ; FILE *fp;
24 ;
25 ; #asm
26 00000000 fp_1 set 0
27 ; phk
28 ; plb
29 ; #endasm
30 asmstart
31 00:0008: 4B phk
32 00:0009: AB plb
33 asmend
34 ;
35 ; fputs("hello, world\n", stdout);
36 00:000A: A9 xx xx lda #<~~_iob+20
37 00:000D: 85 01 sta <R0
38 xref _BEG_DATA
39 00:000F: A9 xx xx lda #_BEG_DATA>>16
40 00:0012: 85 03 sta <R0+2
41 00:0014: D4 03 pei <R0+2
42 00:0016: D4 01 pei <R0
43 00:0018: F4 xx xx pea #^L1
44 00:001B: F4 xx xx pea #<L1
45 00:001E: 22 xx xx xx jsl ~~fputs
46 ;
47 ; fp = fopen("file.txt", "wb");
48 00:0022: F4 xx xx pea #^L1+23
49 00:0025: F4 xx xx pea #<L1+23
50 00:0028: F4 xx xx pea #^L1+14
51 00:002B: F4 xx xx pea #<L1+14
52 00:002E: 22 xx xx xx jsl ~~fopen
Tue Jan 17 2017 23:30 Page 2
53 00:0032: 85 05 sta <L3+fp_1
54 00:0034: 86 07 stx <L3+fp_1+2
55 ; fclose(fp);
56 00:0036: D4 07 pei <L3+fp_1+2
57 00:0038: D4 05 pei <L3+fp_1
58 00:003A: 22 xx xx xx jsl ~~fclose
59 ;}
60 L4:
61 00:003E: 2B pld
62 00:003F: 3B tsc
63 00:0040: 18 clc
64 00:0041: 69 08 00 adc #L2
65 00:0044: 1B tcs
66 00:0045: 6B rtl
67 00000008 L2 equ 8
68 00000005 L3 equ 5
69 ends
70 efunc
71 data
72 L1:
73 00:0000: 68 65 6C 6C db $68,$65,$6C,$6C,$6F,$2C,$20,$77,$6F,$72,
$6C,$64,$0A,$00,$66
00:0004: 6F 2C 20 77
00:0008: 6F 72 6C 64
00:000C: 0A 00 66
74 00:000F: 69 6C 65 2E db $69,$6C,$65,$2E,$74,$78,$74,$00,$77,$62,
$00
00:0013: 74 78 74 00
00:0017: 77 62 00
75 00:001A: ends
76 ;
77 ;// these stubs are not provided in the library bu
t could call gs/os.
78 ;
79 ;int open(const char *name, int mode) {
80 code
81 xdef ~~open
82 func
83 ~~open:
84 longa on
85 longi on
86 00:0046: 3B tsc
87 00:0047: 38 sec
88 00:0048: E9 00 00 sbc #L6
89 00:004B: 1B tcs
90 00:004C: 0B phd
91 00:004D: 5B tcd
92 00000004 name_0 set 4
93 00000008 mode_0 set 8
94 ; return -1;
95 00:004E: A9 FF FF lda #$ffff
96 L8:
97 00:0051: A8 tay
98 00:0052: A5 02 lda <L6+2
99 00:0054: 85 08 sta <L6+2+6
100 00:0056: A5 01 lda <L6+1
101 00:0058: 85 07 sta <L6+1+6
102 00:005A: 2B pld
Tue Jan 17 2017 23:30 Page 3
103 00:005B: 3B tsc
104 00:005C: 18 clc
105 00:005D: 69 06 00 adc #L6+6
106 00:0060: 1B tcs
107 00:0061: 98 tya
108 00:0062: 6B rtl
109 ;}
110 00000000 L6 equ 0
111 00000001 L7 equ 1
112 ends
113 efunc
114 ;
115 ;int close(int fd) {
116 code
117 xdef ~~close
118 func
119 ~~close:
120 longa on
121 longi on
122 00:0063: 3B tsc
123 00:0064: 38 sec
124 00:0065: E9 00 00 sbc #L9
125 00:0068: 1B tcs
126 00:0069: 0B phd
127 00:006A: 5B tcd
128 00000004 fd_0 set 4
129 ; return -1;
130 00:006B: A9 FF FF lda #$ffff
131 L11:
132 00:006E: A8 tay
133 00:006F: A5 02 lda <L9+2
134 00:0071: 85 04 sta <L9+2+2
135 00:0073: A5 01 lda <L9+1
136 00:0075: 85 03 sta <L9+1+2
137 00:0077: 2B pld
138 00:0078: 3B tsc
139 00:0079: 18 clc
140 00:007A: 69 02 00 adc #L9+2
141 00:007D: 1B tcs
142 00:007E: 98 tya
143 00:007F: 6B rtl
144 ;}
145 00000000 L9 equ 0
146 00000001 L10 equ 1
147 ends
148 efunc
149 ;
150 ;
151 ;size_t read(int fd, void *buffer, size_t count) {
152 code
153 xdef ~~read
154 func
155 ~~read:
156 longa on
157 longi on
158 00:0080: 3B tsc
159 00:0081: 38 sec
160 00:0082: E9 02 00 sbc #L12
Tue Jan 17 2017 23:30 Page 4
161 00:0085: 1B tcs
162 00:0086: 0B phd
163 00:0087: 5B tcd
164 00000004 fd_0 set 4
165 00000006 buffer_0 set 6
166 0000000A count_0 set 10
167 ;
168 ;static struct {
169 ; unsigned pCount;
170 ; unsigned refNum;
171 ; void *dataBuffer;
172 ; unsigned long requestCount;
173 ; unsigned long transferCount;
174 ; unsigned cachePriority;
175 ;} dcb;
176 udata
177 L10001:
178 00:0000: ds 18
179 00:0012: ends
180 ;
181 ;
182 ; unsigned tool_error = 0x0043;
183 ;
184 ; dcb.pCount = 4;
185 00000000 tool_error_1 set 0
186 00:0088: A9 43 00 lda #$43
187 00:008B: 85 01 sta <L13+tool_error_1
188 00:008D: A9 04 00 lda #$4
189 00:0090: 8D xx xx sta |L10001
190 ; dcb.refNum = fd+1;
191 00:0093: A5 06 lda <L12+fd_0
192 00:0095: 1A ina
193 00:0096: 8D xx xx sta |L10001+2
194 ; dcb.dataBuffer = buffer;
195 00:0099: A5 08 lda <L12+buffer_0
196 00:009B: 8D xx xx sta |L10001+4
197 00:009E: A5 0A lda <L12+buffer_0+2
198 00:00A0: 8D xx xx sta |L10001+4+2
199 ; dcb.requestCount = count;
200 00:00A3: A5 0C lda <L12+count_0
201 00:00A5: 8D xx xx sta |L10001+8
202 00:00A8: 9C xx xx stz |L10001+8+2
203 ; #asm
204 ; pea #^%%dcb
205 ; pea #%%dcb
206 ; pea #$2012
207 ; jsl $e100b0
208 ; sta %%tool_error;
209 ; #endasm
210 asmstart
211 00:00AB: F4 xx xx pea #^L10001
212 00:00AE: F4 xx xx pea #L10001
213 00:00B1: F4 12 20 pea #$2012
214 00:00B4: 22 B0 00 E1 jsl $e100b0
215 00:00B8: 85 01 sta <L13+tool_error_1;
216 asmend
217 ; if (tool_error) return -1;
218 00:00BA: A5 01 lda <L13+tool_error_1
Tue Jan 17 2017 23:30 Page 5
219 00:00BC: D0 03 bne L14
220 00:00BE: 82 15 00 brl L10002
221 L14:
222 00:00C1: A9 FF FF lda #$ffff
223 L15:
224 00:00C4: A8 tay
225 00:00C5: A5 04 lda <L12+2
226 00:00C7: 85 0C sta <L12+2+8
227 00:00C9: A5 03 lda <L12+1
228 00:00CB: 85 0B sta <L12+1+8
229 00:00CD: 2B pld
230 00:00CE: 3B tsc
231 00:00CF: 18 clc
232 00:00D0: 69 0A 00 adc #L12+8
233 00:00D3: 1B tcs
234 00:00D4: 98 tya
235 00:00D5: 6B rtl
236 ; return dcb.transferCount;
237 L10002:
238 00:00D6: AD xx xx lda |L10001+12
239 00:00D9: 82 E8 FF brl L15
240 ;
241 ;}
242 00000002 L12 equ 2
243 00000001 L13 equ 1
244 ends
245 efunc
246 ;
247 ;size_t write(int fd, void *buffer, size_t count)
{
248 code
249 xdef ~~write
250 func
251 ~~write:
252 longa on
253 longi on
254 00:00DC: 3B tsc
255 00:00DD: 38 sec
256 00:00DE: E9 02 00 sbc #L16
257 00:00E1: 1B tcs
258 00:00E2: 0B phd
259 00:00E3: 5B tcd
260 00000004 fd_0 set 4
261 00000006 buffer_0 set 6
262 0000000A count_0 set 10
263 ;
264 ;static struct {
265 ; unsigned pCount;
266 ; unsigned refNum;
267 ; void *dataBuffer;
268 ; unsigned long requestCount;
269 ; unsigned long transferCount;
270 ; unsigned cachePriority;
271 ;} dcb;
272 udata
273 L10003:
274 00:0012: ds 18
275 00:0024: ends
Tue Jan 17 2017 23:30 Page 6
276 ;
277 ;
278 ; unsigned tool_error = 0x0043;
279 ;
280 ; dcb.pCount = 4;
281 00000000 tool_error_1 set 0
282 00:00E4: A9 43 00 lda #$43
283 00:00E7: 85 01 sta <L17+tool_error_1
284 00:00E9: A9 04 00 lda #$4
285 00:00EC: 8D xx xx sta |L10003
286 ; dcb.refNum = fd+1;
287 00:00EF: A5 06 lda <L16+fd_0
288 00:00F1: 1A ina
289 00:00F2: 8D xx xx sta |L10003+2
290 ; dcb.dataBuffer = buffer;
291 00:00F5: A5 08 lda <L16+buffer_0
292 00:00F7: 8D xx xx sta |L10003+4
293 00:00FA: A5 0A lda <L16+buffer_0+2
294 00:00FC: 8D xx xx sta |L10003+4+2
295 ; dcb.requestCount = count;
296 00:00FF: A5 0C lda <L16+count_0
297 00:0101: 8D xx xx sta |L10003+8
298 00:0104: 9C xx xx stz |L10003+8+2
299 ; #asm
300 ; pea #^%%dcb
301 ; pea #%%dcb
302 ; pea #$2013
303 ; jsl $e100b0
304 ; sta %%tool_error;
305 ; #endasm
306 asmstart
307 00:0107: F4 xx xx pea #^L10003
308 00:010A: F4 xx xx pea #L10003
309 00:010D: F4 13 20 pea #$2013
310 00:0110: 22 B0 00 E1 jsl $e100b0
311 00:0114: 85 01 sta <L17+tool_error_1;
312 asmend
313 ; if (tool_error) return -1;
314 00:0116: A5 01 lda <L17+tool_error_1
315 00:0118: D0 03 bne L18
316 00:011A: 82 15 00 brl L10004
317 L18:
318 00:011D: A9 FF FF lda #$ffff
319 L19:
320 00:0120: A8 tay
321 00:0121: A5 04 lda <L16+2
322 00:0123: 85 0C sta <L16+2+8
323 00:0125: A5 03 lda <L16+1
324 00:0127: 85 0B sta <L16+1+8
325 00:0129: 2B pld
326 00:012A: 3B tsc
327 00:012B: 18 clc
328 00:012C: 69 0A 00 adc #L16+8
329 00:012F: 1B tcs
330 00:0130: 98 tya
331 00:0131: 6B rtl
332 ; return dcb.transferCount;
333 L10004:
Tue Jan 17 2017 23:30 Page 7
334 00:0132: AD xx xx lda |L10003+12
335 00:0135: 82 E8 FF brl L19
336 ;}
337 00000002 L16 equ 2
338 00000001 L17 equ 1
339 ends
340 efunc
341 ;
342 ;long lseek(int fd, long offset, int whence) {
343 code
344 xdef ~~lseek
345 func
346 ~~lseek:
347 longa on
348 longi on
349 00:0138: 3B tsc
350 00:0139: 38 sec
351 00:013A: E9 00 00 sbc #L20
352 00:013D: 1B tcs
353 00:013E: 0B phd
354 00:013F: 5B tcd
355 00000004 fd_0 set 4
356 00000006 offset_0 set 6
357 0000000A whence_0 set 10
358 ; return -1;
359 00:0140: A9 FF FF lda #$ffff
360 00:0143: AA tax
361 00:0144: A9 FF FF lda #$ffff
362 L22:
363 00:0147: A8 tay
364 00:0148: A5 02 lda <L20+2
365 00:014A: 85 0A sta <L20+2+8
366 00:014C: A5 01 lda <L20+1
367 00:014E: 85 09 sta <L20+1+8
368 00:0150: 2B pld
369 00:0151: 3B tsc
370 00:0152: 18 clc
371 00:0153: 69 08 00 adc #L20+8
372 00:0156: 1B tcs
373 00:0157: 98 tya
374 00:0158: 6B rtl
375 ;}
376 00000000 L20 equ 0
377 00000001 L21 equ 1
378 ends
379 efunc
380 ;
381 ;int creat(const char *name, int mode) {
382 code
383 xdef ~~creat
384 func
385 ~~creat:
386 longa on
387 longi on
388 00:0159: 3B tsc
389 00:015A: 38 sec
390 00:015B: E9 00 00 sbc #L23
391 00:015E: 1B tcs
Tue Jan 17 2017 23:30 Page 8
392 00:015F: 0B phd
393 00:0160: 5B tcd
394 00000004 name_0 set 4
395 00000008 mode_0 set 8
396 ; return -1;
397 00:0161: A9 FF FF lda #$ffff
398 L25:
399 00:0164: A8 tay
400 00:0165: A5 02 lda <L23+2
401 00:0167: 85 08 sta <L23+2+6
402 00:0169: A5 01 lda <L23+1
403 00:016B: 85 07 sta <L23+1+6
404 00:016D: 2B pld
405 00:016E: 3B tsc
406 00:016F: 18 clc
407 00:0170: 69 06 00 adc #L23+6
408 00:0173: 1B tcs
409 00:0174: 98 tya
410 00:0175: 6B rtl
411 ;}
412 00000000 L23 equ 0
413 00000001 L24 equ 1
414 ends
415 efunc
416 ;
417 ;int unlink(const char *name) {
418 code
419 xdef ~~unlink
420 func
421 ~~unlink:
422 longa on
423 longi on
424 00:0176: 3B tsc
425 00:0177: 38 sec
426 00:0178: E9 00 00 sbc #L26
427 00:017B: 1B tcs
428 00:017C: 0B phd
429 00:017D: 5B tcd
430 00000004 name_0 set 4
431 ; return -1;
432 00:017E: A9 FF FF lda #$ffff
433 L28:
434 00:0181: A8 tay
435 00:0182: A5 02 lda <L26+2
436 00:0184: 85 06 sta <L26+2+4
437 00:0186: A5 01 lda <L26+1
438 00:0188: 85 05 sta <L26+1+4
439 00:018A: 2B pld
440 00:018B: 3B tsc
441 00:018C: 18 clc
442 00:018D: 69 04 00 adc #L26+4
443 00:0190: 1B tcs
444 00:0191: 98 tya
445 00:0192: 6B rtl
446 ;}
447 00000000 L26 equ 0
448 00000001 L27 equ 1
449 ends
Tue Jan 17 2017 23:30 Page 9
450 efunc
451 ;
452 ;int isatty(int fd) {
453 code
454 xdef ~~isatty
455 func
456 ~~isatty:
457 longa on
458 longi on
459 00:0193: 3B tsc
460 00:0194: 38 sec
461 00:0195: E9 00 00 sbc #L29
462 00:0198: 1B tcs
463 00:0199: 0B phd
464 00:019A: 5B tcd
465 00000004 fd_0 set 4
466 ; return -1;
467 00:019B: A9 FF FF lda #$ffff
468 L31:
469 00:019E: A8 tay
470 00:019F: A5 02 lda <L29+2
471 00:01A1: 85 04 sta <L29+2+2
472 00:01A3: A5 01 lda <L29+1
473 00:01A5: 85 03 sta <L29+1+2
474 00:01A7: 2B pld
475 00:01A8: 3B tsc
476 00:01A9: 18 clc
477 00:01AA: 69 02 00 adc #L29+2
478 00:01AD: 1B tcs
479 00:01AE: 98 tya
480 00:01AF: 6B rtl
481 ;}
482 00000000 L29 equ 0
483 00000001 L30 equ 1
484 ends
485 efunc
486 ;
487 ;
488 ;#pragma section udata=heap
489 heap section
490 00:0000: ends
491 ;char __heap[8192];
492 ;void *heap_start = (void *)__heap;
493 data
494 xdef ~~heap_start
495 ~~heap_start:
496 00:001A: xx xx xx xx dl ~~__heap
497 00:001E: ends
498 ;void *heap_end = (void *)&__heap[8092];
499 data
500 xdef ~~heap_end
501 ~~heap_end:
502 00:001E: xx xx xx xx dl ~~__heap+8092
503 00:0022: ends
504 ;
505 xref ~~fputs
506 xref ~~fopen
507 xref ~~fclose
Tue Jan 17 2017 23:30 Page 10
508 heap
509 xdef ~~__heap
510 ~~__heap
511 00:0000: ds 8192
512 00:2000: ends
513 xref ~~_iob
514 end
Lines assembled: 514
Errors: 0