Author Topic: Concatenate tokens  (Read 7429 times)

Offline Tyler

  • Jr. Member
  • *
  • Posts: 2
Concatenate tokens
« on: March 14, 2012, 04:20:33 AM »
I'm writing stubs for interrupt handlers in my kernel for which I'm using rep to make it easier.

Code: [Select]
%assign i 0
%rep 256
GLOBAL int_i
int_i:
%assign i i+1
%endrep
The problem is getting int_i to do what I want. I have that there as a placeholder, what I really want is to concatenate int_ and the value of i to form a single token that will be interpreted as a label. Is this possible? If so, how?

Thanks for your time,
Tyler

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Concatenate tokens
« Reply #1 on: March 14, 2012, 05:17:05 AM »
Nasm used to be pretty casual about concatenating tokens if you just wrote 'em together, but lately wants an explicit concatenate command, "%+":
Code: [Select]
%assign i 0
%rep 256
GLOBAL int_ %+ i
int_ %+ i:
%assign i i+1
%endrep

See if that works for ya.

Best,
Frank


Offline Tyler

  • Jr. Member
  • *
  • Posts: 2
Re: Concatenate tokens
« Reply #2 on: March 15, 2012, 01:48:49 AM »
Yep, it works. Thanks.

I was unaware that the code I posted may have previously worked in NASM. I've not been using it for long. I switched from FASM, because NASM is easier to use with Linux (my development platform) and it also uses more standard command line options. So far, it is definitely living up to my expectations as far as macro abilities go.