home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
debug
/
wadesrc.lbr
/
PRINTF.LZB
/
PRINTF.LIB
Wrap
Text File
|
1988-06-19
|
4KB
|
257 lines
;
; PRINTF: Generate parameter list & call for ?prntf, the formatted
; output routine.
; See PRINTF.ASM for details on coversion specification.
;
; PRINTF will output to the console
; LPRINTF outputs to the printer
; SPRINTF writes the output into a string.
;
; Last edited 85-03-17 Wagner
;
; Copyright (c) 1984, 1985 by
;
; Thomas Wagner
; Patschkauer Weg 31
; 1000 Berlin 33
; West Germany
;
;
; Usage: PRINTF 'string',parameter
; LPRINTF 'string',parameter
; SPRINTF destination,'string',parameter
;
; Example: PRINTF 'Call params at %w = "%@t"\n',<80H,80H>
; SPRINTF dest,'Call params at %w = "%@t"\n',<80H,80H>
;
; Parameters may be any defined symbol or expression.
; Character constants may not be used.
; In addition, register names may be specified:
;
; A, F, AF
; B, C, BC
; D, E, DE
; H, L, HL
; IX
; IY
; SP
;
; Note that all registers will be stored as an
; indirect word value.
; For register pairs (IX, IY, SP), use %@x to print
; the lower byte, %@2w to print the upper byte only.
; For single registers the upper byte contains 0.
; For AF, the lower byte contains F, the upper A.
;
; Example: PRINTF 'A=%@x, F=%@x, B=%@x, HL=%@w\n',<A,AF,B,HL>
;
; CAUTION: Using Register-Parameters will generate code to
; store the register in a temporary location.
;
;
; @@@SRG: For local printf use only
;
@@@SRG MACRO PAR,PN,PNUM
IF NUL PAR
EXITM
ENDIF
@&PN&PNUM ASET 0
PN&2 ASET 0
IRPC PP,PAR
IF NOT NUL PP
PN&2 ASET PN&2 + 1
ENDIF
ENDM
IF PN&2 GT 2
EXITM
ENDIF
IF ('&PAR' EQ 'AF') OR ('&PAR' EQ 'A') OR ('&PAR' EQ 'F')
IF '&PAR' EQ 'A'
@&PN&PNUM ASET 1
ELSE
@&PN&PNUM ASET 2
ENDIF
PUSH AF
EX (SP),HL
LD (?pfraf),HL
POP HL
EXITM
ENDIF
IF ('&PAR' EQ 'BC') OR ('&PAR' EQ 'B') OR ('&PAR' EQ 'C')
IF '&PAR' EQ 'B'
@&PN&PNUM ASET 3
ELSE
@&PN&PNUM ASET 4
ENDIF
LD (?pfrbc),BC
EXITM
ENDIF
IF ('&PAR' EQ 'DE') OR ('&PAR' EQ 'D') OR ('&PAR' EQ 'E')
IF '&PAR' EQ 'D'
@&PN&PNUM ASET 5
ELSE
@&PN&PNUM ASET 6
ENDIF
LD (?pfrde),DE
EXITM
ENDIF
IF ('&PAR' EQ 'HL') OR ('&PAR' EQ 'H') OR ('&PAR' EQ 'L')
IF '&PAR' EQ 'H'
@&PN&PNUM ASET 7
ELSE
@&PN&PNUM ASET 8
ENDIF
LD (?pfrhl),HL
EXITM
ENDIF
IF '&PAR' EQ 'IX'
@&PN&PNUM ASET 9
LD (?pfrix),IX
EXITM
ENDIF
IF '&PAR' EQ 'IY'
@&PN&PNUM ASET 10
LD (?pfriy),IY
EXITM
ENDIF
IF '&PAR' EQ 'SP'
@&PN&PNUM ASET 11
LD (?pfrsp),SP
EXITM
ENDIF
ELSE
@&PN&PNUM ASET 0
ENDIF
ENDIF
ENDM
;
; @@@SVL: For local printf use only
;
@@@SVL MACRO PAR,PN,PNUM
IF NUL PAR
EXITM
ENDIF
IF @&PN&PNUM EQ 0
DW PAR
EXITM
ENDIF
IF @&PN&PNUM EQ 1
DW ?pfra
EXITM
ENDIF
IF @&PN&PNUM EQ 2
DW ?pfraf
EXITM
ENDIF
IF @&PN&PNUM EQ 3
DW ?pfrb
EXITM
ENDIF
IF @&PN&PNUM EQ 4
DW ?pfrbc
EXITM
ENDIF
IF @&PN&PNUM EQ 5
DW ?pfrd
EXITM
ENDIF
IF @&PN&PNUM EQ 6
DW ?pfrde
EXITM
ENDIF
IF @&PN&PNUM EQ 7
DW ?pfrh
EXITM
ENDIF
IF @&PN&PNUM EQ 8
DW ?pfrhl
EXITM
ENDIF
IF @&PN&PNUM EQ 9
DW ?pfrix
EXITM
ENDIF
IF @&PN&PNUM EQ 10
DW ?pfriy
EXITM
ENDIF
IF @&PN&PNUM EQ 11
DW ?pfrsp
ENDIF
ENDM
;
;
PRINTF MACRO STRING,VALUES
LOCAL PN,PNUM
EXTRN ?PRNTF
EXTRN ?pfraf,?pfra,?pfrbc,?pfrb,?pfrde,?pfrd,?pfrhl,?pfrh
EXTRN ?pfrix,?pfriy,?pfrsp
PNUM ASET 3
IRP PAR,<VALUES>
@@@SRG PAR,PN,%PNUM
PNUM ASET PNUM+1
ENDM
CALL ?PRNTF
JP PN&1
DW PN&0
PNUM ASET 3
IRP VAL,<VALUES>
@@@SVL VAL,PN,%PNUM
PNUM ASET PNUM+1
ENDM
PN&0: DB STRING
DB 0
PN&1:
ENDM
;
;
LPRINTF MACRO STRING,VALUES
LOCAL PN,PNUM
EXTRN ?LPRNT
EXTRN ?pfraf,?pfra,?pfrbc,?pfrb,?pfrde,?pfrd,?pfrhl,?pfrh
EXTRN ?pfrix,?pfriy,?pfrsp
PNUM ASET 3
IRP PAR,<VALUES>
@@@SRG PAR,PN,%PNUM
PNUM ASET PNUM+1
ENDM
CALL ?LPRNT
JP PN&1
DW PN&0
PNUM ASET 3
IRP VAL,<VALUES>
@@@SVL VAL,PN,%PNUM
PNUM ASET PNUM+1
ENDM
PN&0: DB STRING
DB 0
PN&1:
ENDM
;
;
SPRINTF MACRO DEST,STRING,VALUES
LOCAL PN,PNUM
EXTRN ?SPRNT
EXTRN ?pfraf,?pfra,?pfrbc,?pfrb,?pfrde,?pfrd,?pfrhl,?pfrh
EXTRN ?pfrix,?pfriy,?pfrsp
PNUM ASET 3
IRP PAR,<VALUES>
@@@SRG PAR,PN,%PNUM
PNUM ASET PNUM+1
ENDM
CALL ?SPRNT
JP PN&1
DW DEST
DW PN&0
PNUM ASET 3
IRP VAL,<VALUES>
@@@SVL VAL,PN,%PNUM
PNUM ASET PNUM+1
ENDM
PN&0: DB STRING
DB 0
PN&1:
ENDM
;
;