flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > preprocessor params from one macro to another

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 24 Aug 2022, 05:47
Fasmw 1.73
Code:
;data 
a dd 1
b dd 2
c dd 10
;from one place code
mcg.start = [a]
mcg.loop = [b]
mcg.end = [c]

mcg ;do some

;second place in code
mcg.start = [b]
mcg.loop = [c]
mcg.end = [a]

mcg ;do some

    

Now i don`t know what good.
mcg.start\mcg.end like as equ or local macro data.
Post 24 Aug 2022, 05:47
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 24 Aug 2022, 06:01
I write prototype.
Code:
macro mcg.Init { local a
      jmp a
      mcg.start dd 0
      mcg.end   dd 0
      mcg.loop  dd 0
a:
      }
macro mcg.Put a,b {
      movd xmm0,b
      movd [mcg.#a],xmm0
      }
macro mcg.Run {local .a
      mov eax,[mcg.start]
      mov ebx,[mcg.loop]
      mov ecx,[mcg.end]
      invoke MessageBox,0,'mcg.Run',0,0
.a:
      }   

;in code
                mcg.Init  ;do once or not write this.
                mcg.Put start,[cerr]  ;if this and mcg.start not defined then define mcg.start
                mcg.Put end,[cerr]
                mcg.Put loop,eax
                mcg.Run 
    
Post 24 Aug 2022, 06:01
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 24 Aug 2022, 06:12
but this fasm not compiled.
Error: code cannot be generated
Code:
macro mcg.Put a,b {
    if ~ defined mcg.#a

    jmp @f
    mcg.#a dd 0
  @@:
    end if
      movd xmm0,b
      movd [mcg.#a],xmm0
      } 
    
Post 24 Aug 2022, 06:12
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1066
Location: Russia
macomics 24 Aug 2022, 06:42
Code:
macro mcg.Put a,b {
        if ~ defined mcg.#a | defined @f
jmp @f
  mcg#.a dd 0
@@:
  movd xmm0,b
  movd [mcg.#a],xmm0
        }    
Post 24 Aug 2022, 06:42
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1878
Roman 24 Aug 2022, 06:47
Thanks macomics
This code well.
Code:
macro mcg.Put_ a,b {
        if ~ defined mcg.#a | defined @f
jmp @f
  mcg.#a dd 0
@@:
end if
  movd xmm0,b
  movd [mcg.#a],xmm0
        } 
    
Post 24 Aug 2022, 06:47
View user's profile Send private message Reply with quote
Overclick



Joined: 11 Jul 2020
Posts: 670
Location: Ukraine
Overclick 24 Aug 2022, 11:11
Is your code section writable? If not you need to use some.
Or welcome to multisection
Code:
macro mcg.Put_ a,b
{  ..dataonce mcg.#a, mcg.#a   dd 0
      movd   xmm0,b
      movd   [mcg.#a],xmm0 }     
Post 24 Aug 2022, 11:11
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.