Author Topic: %xdefine expects a macro identifier or how to define increment variables in loop  (Read 11824 times)

Offline kores

  • New Member
  • Posts: 1
Hello! I use NASM version 2.11.05

I need to create variables in the loop, so that they can later be used and modified. But the preprocessor gives an error on %xdefine and %assign

Code: [Select]
%macro mytest 0
%push
%assign %$counter 0

%assign %$state%$counter 0
%warning %$state0 %$counter
%assign %$state%$counter 51
%warning %$state%+%$counter %$counter
%pop
%endmacro
At compilation the following is deduced:
Quote
test.asm:104: warning: (mytest:5) 0 0
test.asm:104: error: (mytest:6) `%assign' expects a macro identifier
test.asm:104: warning: (mytest:7) 0 0

When using a %xdefine, the same thing happens... Why it is impossible to reassign the value?

In general, I need to implement the following:
Code: [Select]
%macro init 0
%assign %$counter 0
%rep 256
%assign %$state%$counter %$counter
%assign %$counter %$counter+1
%endrep
%endmacro

%macro work 0
%push
init
%assign %$counter 0
%rep 256
%if %$state%$counter % 10 == 0
%assign %$tmp %$state%$counter / 10
%assign %$state%$counter %$state%$counter + %$tmp
%endif
%assign %$counter %$counter+1
%endrep
%pop
%endmacro

In the end, I need to get variables from %$state0 to %$state255  and be able to read / modify(arithmetic operations) them.
This is generally possible??

Help me please. Thank you in advance!






« Last Edit: November 15, 2017, 02:53:29 AM by kores »