NASM trying to add variables to different sections inside a macro

Viewed 58

I would like to make a macro that will init co-routines, so i need a different name for each of theese variables. For this purpose i will get a unique ID for each of the co-routines. Here is the problematic code:

    %macro initialize 1 
section .bss
    STK%1: resb STKSZ

; section .data
;     CO%1: dd CO%1code
;     Flags%1: dd 0
;     SP%1: dd STK%1 + STKSZ
section .text

%endmacro 

Maybe me trying to chain the ID number to a given string (like that: STK%1) is impossible? Is it even possible to modify sections inside a macro? If it is possible, how can i do that inside my macro? Thank you!

1 Answers

I would like to suggest an answer to my own question, What I have done with this issue is to implement an "array" that will hold the variables for each of the co-routines. Each of the co-routines will get a unique ID number and he will use his own ID to find his own variables inside the "array". Let's assume that each of the co-routines have 5 variables, so the current co-routine will take his variables in this manner: array[(ID*5)+0] ... array[(ID*5)+4] . Hopefully my solution will help other programmers too.

Related