1
0
mirror of https://github.com/wfjm/w11.git synced 2026-01-25 20:16:00 +00:00
Files
wfjm.w11/tools/asm-11/lib/kprfmt.mac
Walter F.J. Mueller 92e149437d Fix license disclaimer
2016-12-26 21:27:33 +01:00

54 lines
1.7 KiB
Plaintext

; $Id: kprfmt.mac 830 2016-12-26 20:25:49Z mueller $
; Copyright 2013- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
; License disclaimer see License.txt in $RETROBASE directory
;
; synchronous (polling) console print: very simple printf
; Call:
; jsr pc, kprfmt
; Arguments:
; r0: pointer format string
; r1: pointer to argument list
;
; r2-r5 registers preserved
;
kprfmt: mov r2,-(sp) ; save r2
mov r0,r2 ; r2 now ptr to fmt string
1$: movb (r2)+,r0 ; next fmt char
beq 20$ ; if zero quit
cmpb #'%,r0 ; is it '%' ?
bne 10$ ; if not, print
movb (r2)+,r0 ; if yes, get next
beq 20$ ; if zero quit
cmpb #'s,r0 ; %s found ?
bne 2$
mov (r1)+,r0 ; get next arg
jsr pc,kprstr ; and print string
br 1$ ; go for next fmt char
2$: cmpb #'o,r0 ; %o found ?
bne 3$
mov (r1)+,r0 ; get next arg
jsr pc,kproct ; and print octal number
br 1$ ; go for next fmt char
3$: cmpb #'d,r0 ; %d found
bne 4$
mov (r1)+,r0 ; get next arg
jsr pc,kprdec ; and print as decimal number
br 1$
4$: movb -2(r2),r0 ; was neither %s,%o,%d
jsr pc,kprchr ; so simply print these two letters...
movb -1(r2),r0
10$: jsr pc,kprchr ; print fmt char
br 1$ ; go for next fmt char
20$: mov (sp)+,r2 ; restore r2
rts pc