macro's and local variables

Mischa Baars mjbaars1977@gmail.com
Wed Oct 17 12:31:00 GMT 2012


On 10/17/2012 01:51 PM, Jan Beulich wrote:
>>>> On 17.10.12 at 13:06, Mischa Baars <mjbaars1977@gmail.com> wrote:
>> On 10/17/2012 08:52 AM, Jan Beulich wrote:
>>> Another option here is to use "local" (requiring .altmacro to be
>>> in effect).
>> Again, could you be more specific. Perhaps you could rewrite
>> 'function.S' to demonstrate?
> Did you even make an attempt at using the information that is
> available to you, e.g. gas/testsuite/gas/macros/altmacro.[sd],
> or trying this out on your own?
Sorry, I forgot to check the testsuite. Here it is, seems to work 
indeed. I suppose that solves one of the problems.

Thanks,
Mischa.
>
> Jan
>

-------------- next part --------------

./function.o:     file format elf32-i386


Disassembly of section .text:

00000000 <.text>:
   0:	66 b8 00 00          	mov    $0x0,%ax
   4:	66 bb 00 00          	mov    $0x0,%bx
   8:	66 b8 00 00          	mov    $0x0,%ax
   c:	66 b8 01 00          	mov    $0x1,%ax
  10:	66 bb 00 00          	mov    $0x0,%bx
  14:	66 bb 01 00          	mov    $0x1,%bx
  18:	66 b8 00 00          	mov    $0x0,%ax
  1c:	66 b8 01 00          	mov    $0x1,%ax
  20:	66 b8 02 00          	mov    $0x2,%ax
  24:	66 bb 00 00          	mov    $0x0,%bx
  28:	66 bb 01 00          	mov    $0x1,%bx
  2c:	66 bb 02 00          	mov    $0x2,%bx
-------------- next part --------------
		.intel_syntax	noprefix

		.global		function

		.code64

		.altmacro

.macro		A		arg1

		local		i

		.set		i, 0

.rept		\arg1	

		mov		ax, i	

		.set		i, i + 1

.endr

.endm

.macro		B		arg1

		local		j

		.set		j, 0

.rept		\arg1	

		mov		bx, j 	

		.set		j, j + 1

.endr

.endm

.macro		C

		local		i

		.set		i, 0

.rept		4	

		A		i
		B		i

		.set		i, i + 1

.endr

.endm

		C




More information about the Binutils mailing list