On Sun, Jul 14, 2013 at 07:11:16PM -0400, Jerome H. Fine wrote:
I have unsuccessfully attempted to isolate the first 5
characters
of STRING in the MACRO ABC, but I have been unsuccessful.
Fun problem! Thanks for the hack break. I may have missed the point of what
you're doing but I got something which I *think* is on the right track (actual
code generated by the macro may miss the point), by nesting .IRPCs until I got
all six characters in separate .IRPC variables. May be all wrong, but what
else is new ...
John Wilson
D Bit
---------------------------------------------------------------------------
;+
;
; Hideously inefficient macro which explodes a symbol name using six nested
; .IRPCs (each level started only when outer ones reach correct character --
; otherwise assembly is SUPER slow).
;
; JMBW 17-Jul-2013.
;
;-
.macro abc foo
.nchr ct1,<foo> ;must be .GE. 6 chars long
.iif lt ct1-6, .mexit ;no op if not
ct1= 0 ;CH1 is first char
.irpc ch1,<foo>
ct1= ct1+1
.if eq ct1-1
ct2= 0 ;CH2 is second char
.irpc ch2,<foo>
ct2= ct2+1
.if eq ct2-2
ct3= 0 ;you see where I'm going with this
.irpc ch3,<foo>
ct3= ct3+1
.if eq ct3-3
ct4= 0 ;nested .IRPCs run until each position found
.irpc ch4,<foo>
ct4= ct4+1
.if eq ct4-4
ct5= 0
.irpc ch5,<foo>
ct5= ct5+1
.if eq ct5-5
ct6= 0
.irpc ch6,<foo>
ct6= ct6+1
.if eq ct6-6 ;got 'em all, in order
; do whatever you had in mind, with
ch1''ch2''ch3''ch4''ch5''ch6 = sym name
.if df ch1''ch2''ch3''ch4''ch5'2 ;***** N.B. must be
backward ref *****
mov #ch1''ch2''ch3''ch4''ch5'2,-(sp) ;replace CH6
with 2
.iff
mov #foo,r0 ;use original string
.endc
; unwind all that
.endc ; CT6.EQ.6
.endm ; .IRPC CH6
.endc ; CT5.EQ.5
.endm ; .IRPC CH5
.endc ; CT4.EQ.4
.endm ; .IRPC CH4
.endc ; CT3.EQ.3
.endm ; .IRPC CH3
.endc ; CT2.EQ.2
.endm ; .IRPC CH2
.endc ; CT1.EQ.1
.endm ; .IRPC CH1
.endm abc
;
tstvar: .blkw ;exists with and without 2 as sixth char
tstva2: .blkw ;(so macro will choose this one)
;
tstnum: .blkw ;only exists without
;
pig: .blkw ;not long enough (won't really be touched)
;
.list me
abc tstvar ;MOV #TSTVA2,-(SP)
abc tstnum ;MOV #TSTNUM,R0
abc pig ;no op (name too short)
;
.end