;+
; These macros are used when writing privel'd tasks (or ones which
; simply must be small - can't afford the overhead of the C library).
;
;               prints buf-addr <string> p1 p2 ..       ;like sprintf in c
;               type buf-addr  [car-control]            ;qiow to lun5 buffer
;               len buf-addr                            ;sets r0=len of str
;               tty <string>                            ;just dump it on ti:
;
;       All assume that r0 and r1 are available to be
;       destroyed without saving. (all c callable stuff is like this)
;       car-control defaults to #40
;-
$MACRO PRINTS  bufaddr <STRING> p1 p2...
I%NB <#@D> <I%ERR <#@D=too many parms>>
?- 0,,26
?? 14,15
	BR #@F
#@E=.
	.ASCIZ _#@2_
	.EVEN
#@F=.
** P%SH <#@C><#@B><#@A><#@9><#@8><#@7><#@6><#@5><#@4><#@3><##@E><#@1>
	jsr pc,sprint
?+ 1,,26
	ADD ##@1,SP	;clean up stk
$ENDM
;
$MACRO LEN string
?? 2
	mov #@1,r0
#@2=.
	tstb (r0)+
	bne #@2
	sub #@1,r0
	dec r0
$ENDM
;
$MACRO TYPE string-addr types asciz string
LEN #@1
I%IN <#@2> <> <<POKE 28 #40>> <POKE 28 #@2>
?+ 2,,28
;qiow$s #io.wvb,#5,#5,,,,<#BUF,r0,#40>   THIS IS TOO DAMN SLOW
	CLR     -(SP)
	CLR     -(SP)
	CLR     -(SP)
	MOV     #@2,-(SP)
	MOV     r0,-(SP)
	MOV     #@1,-(SP)
	CLR     -(SP)
	CLR     -(SP)
	CLR     -(SP)
	MOVB    #5,(SP)
	MOV     #5,-(SP)
	MOV     #io.wvb,-(SP)
	MOV     (PC)+,-(SP)
	.BYTE   3,12.
	EMT     ^O<377>
$ENDM
$MACRO TTY string-literal [control]
?? 5,4
	br #@4
#@5=.
	.asciz _#@1_
	.even
#@4=.
	TYPE ##@5  #@2
$ENDM
;
$MACRO PRINTF
PUSH R0
PUSH R1
PRINTS #@1 <#@2><#@3><#@4><#@5><#@6><#@7><#@8><#@9><#@A><#@B><#@C><#@D>
TYPE #@1
POP R1
POP R0
$ENDM

