This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GAS macro formals as expression


Fruhwirth Clemens <clemens-dated-1064072781.3fe4@endorphin.org> writes:

> > > ldCache macro addr,byteCnt,cpuName
> > > NN=0
> > >   rept (byteCnt+63)/64                  ;force cache line load (Pentium only)
> > >     irp QQ,<%(NN)>
> > >     mov         eax,addr[QQ]
> > >         endm
> > >    if (NN+32) lt byteCnt
> > >     irp QQ,<%(NN+36)>
> > >       mov       ebx,addr[QQ]
> > >         endm
> > >    endif
> > > NN=NN+64
> > >   endm
> > > endm
> > > 
> > > I reimplemented this loop with this recursive gas macro:
> > 
> > Why didn't you use the gas rept and irp pseudo-ops?  Would they not
> > work for this application?
> 
> Because it's impossible to access the current counter value of the rept
> expansion and reassigning macro formals is not possible either.

I think gas is more flexible than you give it credit for.  Try this
version.  It probably needs some tweaks, but I think the general
approach should be workable.

.macro	ldCachePentium2 addr,byteCnt
	NN = 0
	.rept	(\byteCnt + 63) / 64
		.ifeq	NN
			mov \addr,%eax
		.else
			mov	NN \addr,%eax
		.endif
		.if	(NN + 32) < \byteCnt
			mov NN + 36 \addr,%eax
		.endif
		NN = NN + 64
	.endr
	.endm

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]