Post by Johnny BillquistAnd while it's pretty straight forward in theory, I can't create such
a padding in MACRO-11. The problem is that I'm not allowed to do that
kind of arithmetic on the current location, as it is a relative value.
But maybe I'm just not creative enough right at this moment.
But with that said, I do have a MACRO-11 definition of .LONG which
works just fine. :-)
Johnny
Care to share it?
Sure. Here is both .LONG and .QUAD (yes, I occasionally need those on a
PDP-11).
--------snip---------
;
; The .LONG and .QUAD macros are a bit complex since we want to handle
; all different ways of doing radix in MACRO-11.
;
; As such, they understands:
; . Default radix based on .RADIX
; . Explicit ending with . to indicate decimal
; . ^O for octal
; . ^D for decimal
; . ^X for hexadecimal
;
; Note that ^x notation requires the argument to be enclosed
; in <>, since otherwise MACRO-11 tries to parse if before
; the macro expansion happens.
;
; The variables used are:
; $$$F flag if previous char was ^
; $$$B base used for conversion
; $$$B1-$$$B8 the eight bytes accumulating the value
;
;
; $$$TD tests if the argument ends with a dot, and if so
; sets conversion base explicitly to 10.
;
.MACRO $$$TD WORD
.IRPC D,<WORD>
.IF IDN <D> .
$$$B=10.
.ENDC
.ENDR
.ENDM $$$TD
;
; $$$ADD will add one digit, in the appropriate base,
; to the accumulating bytes.
;
.MACRO $$$ADD DI
.IF EQ $$$B-8.
$$$V = ^O'DI
.ENDC
.IF EQ $$$B-10.
$$$V = ^D'DI
.ENDC
.IF EQ $$$B-16.
$$$V = ^X0'DI
.ENDC
.IRPC X,<12345678>
$$$B'X=$$$B'X*$$$B+$$$V
$$$V=$$$B'X/256.
$$$B'X=$$$B'X&^O377
.ENDR
.ENDM $$$ADD
;
; Accumulate a word into multiple bytes.
; The bytes gets into $$$Bn
;
.MACRO $$$ACC WORD
.MCALL $$$TD, $$$ADD
.IRPC X,<12345678>
$$$B'X=0
.ENDR
$$$F=0
$$$B=10
$$$TD <WORD>
.IRPC DI,<WORD>
.IF IDN <DI> <^>
$$$F=1
.IFF
.IF NE $$$F
.IF IDN <DI> O
$$$B=^O10
.ENDC
.IF IDN <DI> D
$$$B=10.
.ENDC
.IF IDN <DI> X
$$$B=^X10
.ENDC
$$$F=0
.IFF
.IF IDN <DI> .
.IFF
$$$ADD <DI>
.ENDC
.ENDC
.ENDC
.ENDR
.ENDM $$$ACC
.MACRO .LONG WORD,ORDER
.MCALL $$$ACC
$$$ACC <WORD>
$$$W1=$$$B2*256.+$$$B1
$$$W2=$$$B4*256.+$$$B3
.LIST MEB
.IF NB ORDER
.WORD $$$W1,$$$W2
.IFF
.WORD $$$W2,$$$W1
.ENDC
.NLIST MEB
.ENDM .LONG
.MACRO .QUAD WORD
.MCALL $$$ACC
$$$ACC <WORD>
$$$W1=$$$B2*256.+$$$B1
$$$W2=$$$B4*256.+$$$B3
$$$W3=$$$B6*256.+$$$B5
$$$W4=$$$B8*256.+$$$B7
.LIST MEB
.WORD $$$W1,$$$W2,$$$W3,$$$W4
.NLIST MEB
.ENDM .QUAD
---------snip---------