Pristine Ack-5.5
[Ack-5.5.git] / mach / z8000 / libem / libem_s.a
1 eÿaar.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ÿ\0.define aar
2 .sect .text
3 .sect .rom
4 .sect .data
5 .sect .bss
6 .sect .text
7
8 !R1 contains description address
9 !R3 contains element number
10 !base address is on stack
11 aar:
12         sub     R3, 0(R1)
13         mult    RR2, 4(R1)
14         inc     R15, $4
15         add     R3, *RR14
16         ld      *RR14, R3
17         dec     R15, $4
18         ret
19 \0blm.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ý\ 1.define blm
20 .sect .text
21 .sect .rom
22 .sect .data
23 .sect .bss
24 .sect .text
25
26 !size in R0
27 blm:
28         popl    saveret, *RR14
29         ldm     savereg, R4, $10
30         ldk     R2, $0
31         ld      R4, R2
32         pop     R3, *RR14               !RR2: dst address
33         pop     R5, *RR14               !RR4: src address
34         ld      R1, R0
35         sra     R0
36         jr      EQ, 2f
37             !now avoid wrong copy in case the pieces overlap
38         cp      R5, R3
39         jr      EQ, 2f
40         jr      LT, 1f
41         ldir    *RR2, *RR4, R0
42         jr      2f
43 1:      dec     R1, $2
44         add     R3, R1
45         add     R5, R1
46         lddr    *RR2, *RR4, R0
47 2:      ldm     R4, savereg, $10
48         pushl   *RR14, saveret
49         ret
50 \0cii.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¦\ 1.define cii
51 .sect .text
52 .sect .rom
53 .sect .data
54 .sect .bss
55 .sect .text
56
57 cii:
58         popl    saveret, *RR14
59         pop     R2, *RR14
60         pop     R1, *RR14
61         sub     R2, R1          !expansion in bytes
62         jr      LE, 1f
63         sra     R2              !expansion in words > 0
64         jr      NC, 2f
65         pop     R1, *RR14       !expand 1 --> 2
66         extsb   R1
67         push    *RR14, R1
68         test    R2
69         jr      EQ, 4f
70 2:                              !expand >= 1 word
71         ld      R1, *RR14
72         exts    RR0
73 3:      push    *RR14, R0
74         djnz    R2, 3b
75         jr      4f
76 1:      sub     R15, R2
77 4:      pushl   *RR14, saveret
78         ret
79 cmi.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ø\0.define cmi
80 .sect .text
81 .sect .rom
82 .sect .data
83 .sect .bss
84 .sect .text
85
86 !size in R0
87 cmi:
88         cp      R0, $2
89         jr      NE, 1f
90         popl    RR2, *RR14
91         pop     R1, *RR14
92         pop     R0, *RR14
93         sub     R0, R1
94         jp      *RR2
95 1:      cp      R0, $4
96         jr      EQ, cmi4
97         jr      unknown
98 cmi4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0î\0.define cmi4
99 .sect .text
100 .sect .rom
101 .sect .data
102 .sect .bss
103 .sect .text
104
105 cmi4:
106         popl    saveret, *RR14
107         popl    RR0, *RR14
108         popl    RR2, *RR14
109         subl    RR2, RR0
110         ldk     R0, $0
111         ldl     RR2, saveret
112         jr      LT, 1f
113         jp      EQ, *RR2
114         inc     R0
115         jp      *RR2
116 1:      dec     R0
117         jp      *RR2
118 cms.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\05\ 1.define cms
119 .sect .text
120 .sect .rom
121 .sect .data
122 .sect .bss
123 .sect .text
124
125 cms:
126         popl    saveret, *RR14
127         ldm     savereg, R4, $10
128         ldl     RR2, RR14
129         add     R3, R0
130         ldl     RR4, RR2
131         add     R5, R0
132         sra     R0
133 2:      pop     R1, *RR14
134         cp      R1, *RR2
135         jr      NE, 1f
136         inc     R3, $2
137         djnz    R0, 2b
138 1:      ld      R15, R5
139         ldm     R4, savereg, $10
140         pushl   *RR14, saveret
141         ret
142 1cmu.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\17\ 1.define cmu
143 .sect .text
144 .sect .rom
145 .sect .data
146 .sect .bss
147 .sect .text
148
149 !size in R0
150 cmu:
151         cp      R0, $2
152         jr      NE, 1f
153         popl    RR2, *RR14
154         pop     R1, *RR14
155         pop     R0, *RR14
156         cp      R0, R1
157         ldk     R0, $0
158         jr      ULT, 2f
159         jp      EQ, *RR2
160         inc     R0
161         jp      *RR2
162 2:      dec     R0
163         jp      *RR2
164 1:      cp      R0, $4
165         jr      EQ, cmu4
166         jr      unknown
167 1cmu4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0î\0.define cmu4
168 .sect .text
169 .sect .rom
170 .sect .data
171 .sect .bss
172 .sect .text
173
174 cmu4:
175         popl    saveret, *RR14
176         popl    RR0, *RR14
177         popl    RR2, *RR14
178         cpl     RR2, RR0
179         ldk     R0, $0
180         ldl     RR2, saveret
181         jr      ULT, 1f
182         jp      EQ, *RR2
183         inc     R0
184         jp      *RR2
185 1:      dec     R0
186         jp      *RR2
187 csa.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0<\ 1.define csa
188 .sect .text
189 .sect .rom
190 .sect .data
191 .sect .bss
192 .sect .text
193
194 !R1 contains address of jump table
195 !R2 contains case index
196 csa:
197         sub     R2, 2(R1)
198         jr      LT, 1f
199         cp      R2, 4(R1)
200         jr      UGT, 1f
201         sla     R2
202         add     R1, R2
203         ld      R2, 06(R1)
204         cp      R2, $0
205         jr      EQ, 2f
206         jp      0(R2)
207 1:      ld      R1, 0(R1)
208         jp      NE, 0(R1)
209 2:      push    *RR14, $ECASE
210         jr      fatal
211 csb.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\85\ 1.define csb
212 .sect .text
213 .sect .rom
214 .sect .data
215 .sect .bss
216 .sect .text
217
218 !R1 contains address of jump table
219 !R2 contains case index
220 csb:
221         ld      R3, 0(R1)       !default pointer
222         ld      R0, 2(R1)       !number of entries
223         test    R0
224         jr      EQ, 1f
225 3:      inc     R1, $4
226         cp      R2, 0(R1)
227         jr      EQ, 2f
228         djnz    R0, 3b
229 1:      ld      R1, R3          !default pointer
230         jr      4f
231 2:      ld      R1, 2(R1)
232 4:      test    R1
233         jr      EQ, 5f
234         jp      0(R1)
235 5:      push    *RR14, $ECASE
236         jr      fatal
237  cuu.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\11\ 1.define cuu
238 .sect .text
239 .sect .rom
240 .sect .data
241 .sect .bss
242 .sect .text
243
244 cuu:
245         popl    RR2, *RR14
246         pop     R0, *RR14
247         pop     R1, *RR14
248         sub     R0, R1          !expansion in bytes
249         jr      LE, 1f
250         sra     R0              !expansion in words
251         jp      EQ, *RR2
252 2:      push    *RR14, $0
253         djnz    R0, 2b
254         jp      *RR2
255 1:      sub     R15, R0
256         jp      *RR2
257         dup.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ï\0.define dup
258 .sect .text
259 .sect .rom
260 .sect .data
261 .sect .bss
262 .sect .text
263
264 dup:
265         popl    saveret, *RR14
266         dec     R15, $2
267         ldl     RR2, RR14
268         add     R3, R0
269         sra     R0
270         lddr    *RR14, *RR2, R0
271         inc     R15, $2
272         pushl   *RR14, saveret
273         ret
274 2dvu2.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0ÿ\0.define dvu2
275 .sect .text
276 .sect .rom
277 .sect .data
278 .sect .bss
279 .sect .text
280
281 dvu2:
282         popl    saveret, *RR14
283         pop     R2, *RR14
284         pop     R1, *RR14
285         test    R2
286         jr      MI, 1f
287         ldk     R0, $0
288         div     RR0, R2
289 2:      pushl   *RR14, saveret
290         ret
291 1:      cp      R2, R1
292         ldk     R1, $0
293         jr      UGT, 2b
294         inc     R1
295         jr      2b
296         dvu4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\08\ 1.define dvu4
297 .sect .text
298 .sect .rom
299 .sect .data
300 .sect .bss
301 .sect .text
302
303 dvu4:
304         popl    saveret, *RR14
305         ldm     savereg, R4, $10
306         popl    RR4, *RR14
307         popl    RR2, *RR14
308         testl   RR4
309         jr      MI, 1f
310         ldl     RR0, $0
311         divl    RQ0, RR4
312         jr      2f
313 1:      cpl     RR4, RR2
314         ldl     RR2, $0
315         jr      UGT, 2f
316         inc     R3
317 2:      ldm     R4, savereg, $10
318         pushl   *RR14, saveret
319         ret
320 exg.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\1c\ 1.define exg
321 .sect .text
322 .sect .rom
323 .sect .data
324 .sect .bss
325 .sect .text
326
327 !size (bytes) in R0
328 exg:
329         ldm     savereg, R4, $10
330         ldl     RR2, RR14
331         inc     R3, $2
332         ldl     RR4, RR2
333         add     R5, R0
334         sra     R0
335 1:      ld      R1, *RR2
336         ex      R1, *RR4
337         ld      *RR4, R1
338         inc     R3, $2
339         inc     R5, $2
340         djnz    R0, 1b
341         ldm     R4, savereg, $10
342         ret
343 gto.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\91\0.define gto
344 .sect .text
345 .sect .rom
346 .sect .data
347 .sect .bss
348 .sect .text
349
350 gto:
351         pop     R3, *RR14
352         ld      R13, 4(R3)
353         ld      R15, 2(R3)
354         ld      R3, 0(R3)
355         jp      0(R3)
356         inn.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\95\ 1.define inn
357 .sect .text
358 .sect .rom
359 .sect .data
360 .sect .bss
361 .sect .text
362
363 !bitnr in R1
364 !size (bytes) in R2
365 inn:
366         ld      R3, R2
367         sra     R2
368         ldk     R0, $0
369         div     RR0, $020       !R0: bitnr, R1: wordnr
370         cp      R1, R2
371         jr      UGE, 1f         !R1 must be < R2
372         inc     R1, $2          !R1 contains nr of words from top stack
373         sla     R1
374         ld      R1, RR14(R1)
375         bit     R1, R0
376         jr      EQ, 1f
377         ldk     R0, $1
378         jr      2f
379 1:      ldk     R0, $0
380 2:      ld      R1, R3
381         popl    RR2, *RR14
382         add     R15, R1
383         jp      *RR2
384 1lar.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Ç\ 1.define lar
385 .sect .text
386 .sect .rom
387 .sect .data
388 .sect .bss
389 .sect .text
390
391 !R1 contains description address
392 !R3 contains element number
393 !base address is on stack
394 lar:
395         popl    saveret, *RR14
396         sub     R3, 0(R1)
397         ld      R0, 4(R1)               !nr of bytes per element
398         mult    RR2, R0
399         add     R3, *RR14
400         add     R3, R0
401         sra     R0                      !nr of words per element
402         jr      EQ, 1f
403         dec     R3, $2
404         lddr    *RR14, *RR2, R0
405         inc     R15, $2
406         jr      2f
407 1:      ldb     RL2, -1(R3)
408         ldb     RH2, $0
409         ld      *RR14, R2
410 2:      ldl     RR2, saveret
411         jp      *RR2
412 llos2.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0Z\ 1.define los2
413 .sect .text
414 .sect .rom
415 .sect .data
416 .sect .bss
417 .sect .text
418
419 los2:
420         popl    saveret, *RR14
421         pop     R0, *RR14               !object size
422         ldk     R2, $0
423         pop     R3, *RR14               !address of object
424         cp      R0, $1
425         jr      NE, 1f
426         ldb     RL0, *RR2
427         push    *RR14, R0
428         jr      2f
429 1:      add     R3, R0
430         dec     R3, $2
431         dec     R15, $2
432         sra     R0
433         lddr    *RR14, *RR2, R0
434         inc     R15, $2
435 2:      pushl   *RR14, saveret
436         ret
437 noop.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¥\0.define noop
438 .sect .text
439 .sect .rom
440 .sect .data
441 .sect .bss
442 .sect .text
443
444 noop:
445         push    *RR14, hol0
446         push    *RR14, $fmt
447         calr    prf
448         ret
449 .sect .data
450 fmt:    .asciz  "test %d\n"
451 oprf.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\85\ 2.define prf
452 .sect .text
453 .sect .rom
454 .sect .data
455 .sect .bss
456 .sect .text
457
458 prf:
459         ld      R0, hol0+4      !pointer to filename
460         cp      R0, $0
461         jr      EQ, 1f
462         ld      R2, R0
463         ld      R1, $40
464 3:          !test filename on bad characters
465         ldb     R3, 0(R2)
466         cpb     R3, $0
467         jr      EQ, 2f
468         cpb     R3, $0177
469         jr      GE, 1f
470         cpb     R3, $040
471         jr      LT, 1f
472         inc     R2
473         djnz    R1, 3b
474         clrb    0(R2)
475 2:      push    *RR14, hol0
476         ld      R1, R15
477         push    *RR14, R1
478         push    *RR14, R0
479         push    *RR14, $fmt1
480         calr    printf
481         popl    saveprf, *RR14  !return address
482         calr    printf          !because of call from 'noop'
483         pushl   *RR14, saveprf
484         ret
485 1:      ld      R0, $name
486         jr      2b
487 .sect .data
488 fmt1:   .asciz  "%s, sp = %x, line %d:\n"
489 name:   .asciz  "_unknown file_"
490 saveprf:
491         .data4 0
492 \0rck.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0·\0.define rck
493 .sect .text
494 .sect .rom
495 .sect .data
496 .sect .bss
497 .sect .text
498
499 rck:
500         ld      R0, RR14($4)
501         cp      R0, 0(R1)
502         jr      LT, 1f
503         cp      R0, 2(R1)
504         jr      LE, 2f
505 1:      push    *RR14, $ERANGE
506         calr    trp
507 2:      ret
508 armu2.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\ 2\ 1.define rmu2
509 .sect .text
510 .sect .rom
511 .sect .data
512 .sect .bss
513 .sect .text
514
515 rmu2:
516         popl    saveret, *RR14
517         pop     R2, *RR14
518         pop     R1, *RR14
519         test    R2
520         jr      MI, 1f
521         ldk     R0, $0
522         div     RR0, R2
523 2:      pushl   *RR14, saveret
524         ret
525 1:      ld      R0, R1
526         cp      R2, R1
527         jp      UGT, 2b
528         sub     R0, R2
529         jp      2b
530 rmu4.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0?\ 1.define rmu4
531 .sect .text
532 .sect .rom
533 .sect .data
534 .sect .bss
535 .sect .text
536
537 rmu4:
538         popl    saveret, *RR14
539         ldm     savereg, R4, $10
540         popl    RR4, *RR14
541         popl    RR2, *RR14
542         testl   RR4
543         jr      MI, 1f
544         ldl     RR0, $0
545         divl    RQ0, RR4
546         jr      2f
547 1:      ldl     RR0, RR2
548         cpl     RR4, RR2
549         jr      UGT, 2f
550         sub     RR0, RR4
551 2:      ldm     R4, savereg, $10
552         pushl   *RR14, saveret
553         ret
554 2sar.s\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0¡\ 1.define sar
555 .sect .text
556 .sect .rom
557 .sect .data
558 .sect .bss
559 .sect .text
560
561 !R1 contains description address
562 !R3 contains element number
563 !base address is on stack
564 sar:
565         popl    saveret, *RR14
566         sub     R3, 0(R1)
567         ld      R0, 4(R1)               !nr of bytes per element
568         mult    RR2, R0
569         add     R3, *RR14
570         inc     R15, $2
571         sra     R0                      !nr of words per element
572         jr      EQ, 1f
573         ldir    *RR2, *RR14, R0
574         jr      2f
575 1:      pop     R1, *RR14
576         ldb     *RR2, RL1
577 2:      ldl     RR2, saveret
578         jp      *RR2
579 osigtrp.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0:\0.sect .text
580 .sect .rom
581 .sect .data
582 .sect .bss
583 .sect .text
584 strhp.s\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0É\0.define strhp
585 .sect .text
586 .sect .rom
587 .sect .data
588 .sect .bss
589 .sect .text
590
591 strhp:
592         popl    RR2, *RR14
593         pop     R0, *RR14
594         cp      R0, R15
595         jp      ULT, 1f
596         push    *RR14, $EHEAP
597         calr    trp
598         jp      *RR2
599 1:
600         ld      reghp, R0
601         jp      *RR2
602 dsts2.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0'\ 1.define sts2
603 .sect .text
604 .sect .rom
605 .sect .data
606 .sect .bss
607 .sect .text
608
609 sts2:
610         popl    saveret, *RR14
611         pop     R0, *RR14               !object size
612         ldk     R2, $0
613         pop     R3, *RR14               !address of object
614         cp      R0, $1
615         jr      NE, 1f
616         pop     R0, *RR14
617         ldb     *RR2, RL0
618         jr      2f
619 1:      sra     R0
620         ldir    *RR2, *RR14, R0
621 2:      pushl   *RR14, saveret
622         ret
623 oxset.s\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0h\ 1.define xset
624 .sect .text
625 .sect .rom
626 .sect .data
627 .sect .bss
628 .sect .text
629
630 !bitnr in R1
631 !size (bytes) in R0
632 xset:
633         popl    saveret, *RR14
634         sra     R0
635         ld      R2, R0
636 1:      push    *RR14, $0
637         djnz    R0, 1b
638         div     RR0, $020               !R0: bitnr, R1: wordnr
639         cp      R1, R2
640         jr      UGE, 2f
641         ldk     R2, $0
642         set     R2, R0
643         sla     R1
644         ld      RR14(R1), R2
645 3:      pushl   *RR14, saveret
646         ret
647 2:      push    *RR14, $ESET
648         calr    trp
649         jr      3b
650 unknown.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0r\0.define unknown
651 .sect .text
652 .sect .rom
653 .sect .data
654 .sect .bss
655 .sect .text
656
657 unknown:
658         push    *RR14, $EODDZ
659         jr      fatal
660 trp.s\0n.s\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0z\ 3.define trp, fatal
661 .sect .text
662 .sect .rom
663 .sect .data
664 .sect .bss
665 .sect .text
666
667 fatal:
668         push    *RR14, R1
669         inc     R15, $2
670         popl    saveret, *RR14
671         pop     R1, *RR14       !trap number in R1
672         push    *RR14, R1
673         push    *RR14, R1
674         dec     R15, $4
675         pop     R1, *RR14       !restore R1
676         inc     R15, $2
677         pushl   *RR14, saveret
678         calr    trp
679         push    *RR14, $1
680         jr      EXIT
681         !NOTREACHED
682
683 trp:
684         push    *RR14, R1
685         inc     R15, $2
686         popl    saveret, *RR14
687         pop     R1, *RR14       !trap number in R1
688         pushl   *RR14, saveret
689         push    *RR14, R0
690         dec     R15, $2
691         cp      R1, $16
692         jr      UGE, 1f
693         ld      R0, trpim
694         bit     R0, R1
695         jr      NE, 2f          !ignore
696 1:      sub     R15, $24
697         ldm     *RR14, R2, $12
698         push    *RR14, R1
699         ld      R1, trppc
700         cp      R1, $0
701         jr      EQ, 3f
702         clr     trppc
703         call    0(R1)
704         inc     R15, $2
705         ldm     R2, *RR14, $12
706         add     R15, $24
707 2:      pop     R1, *RR14
708         pop     R0, *RR14
709         ret
710 3:      pop     R1, *RR14
711         push    *RR14, R1
712         push    *RR14, R1
713         push    *RR14, $err
714         calr    printf
715         push    *RR14, $1
716         jr      EXIT
717         !NOTREACHED
718 .sect .data
719 err:    .asciz  "trap error %d\n"
720 printf.s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0J\ 6.define printf
721 .sect .text
722 .sect .rom
723 .sect .data
724 .sect .bss
725 .sect .text
726
727 printf:
728         popl    saveret, *RR14
729         ldm     savereg, R4, $10
730         ld      R3, $buff       !R3 is pointer to a buffer, in which 
731                                 !we built the string to be printed.
732         pop     R2, *RR14       !R2 is pointer to format-string
733 prloop:
734         ldb     RL0, 0(R2)
735         testb   RL0
736         jr      EQ, ready
737         inc     R2
738         cpb     RL0, $045       ! '%'?
739         jr      NE, 1f
740         ldb     RL0, 0(R2)
741         inc     R2
742         cpb     RL0, $0163      ! 's'?
743         jr      EQ, 3f
744         cpb     RL0, $0170      ! 'x'?
745         ld      R4, $16         ! print number hexadecimal
746         jr      EQ, 2f
747         cpb     RL0, $0144      ! 'd'?
748         ld      R4, $10         ! print number decimal
749         jr      EQ, 2f
750         cpb     RL0, $0157      ! 'o'?
751         ld      R4, $8          ! print number octal
752         jr      EQ, 2f
753 1:      ldb     0(R3), RL0
754         inc     R3
755         jr      prloop
756 2:          !in case of %x, %d or %o
757         pop     R1, *RR14
758         test    R1
759         jr      PL, 4f
760         cp      R4, $10
761         jr      NE, 4f          ! print only '-' in case of %d
762         ldb     0(R3), $055     ! '-'
763         inc     R3
764         neg     R1
765 4:      calr    printn
766         jr      prloop
767 3:          !in case of %s
768         pop     R1, *RR14
769 6:      ldb     RL0, 0(R1)
770         testb   RL0
771         jr      EQ, prloop
772         inc     R1
773         ldb     0(R3), RL0
774         inc     R3
775         jr      6b
776 ready:      !now really print the string we built in the buffer
777         ldb     0(R3), RL0      !end string with '\0'
778         sub     R3, $buff-1     !R3 contains the number of characters
779         ld      R1, $buff
780
781         push    *RR14, R3       !count
782         push    *RR14, R1       !buffer
783         push    *RR14, $2       !file descriptor
784         calr    WRITE
785         inc     R15, $6
786
787         ldm     R4, savereg, $10
788         pushl   *RR14, saveret
789         ret
790
791 printn:
792         ldk     R0, $0
793         div     RR0, R4         !%x, %d or %o determined by R4
794         test    R1
795         jr      EQ, 5f          !if quotient is '0' printn is ready
796         push    *RR14, R0       !push remainder onto the stack
797         calr    printn
798         pop     R0, *RR14
799 5:      add     R0, $060
800         cp      R0, $071        !'9'
801         jr      LE, 8f
802         add     R0, $7
803 8:      ldb     0(R3), RL0
804         inc     R3
805         ret
806
807 .sect .data
808 buff:
809         .space 256
810 save.s\0s\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤\ 1\0\0\8e\0.define saveret
811 .define savereg
812 .sect .text
813 .sect .rom
814 .sect .data
815 .sect .bss
816 .sect .text
817
818 .sect .data
819 saveret:
820         .data4 0
821 savereg:
822         .space 20