flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > irpv create labels.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1286
Roman 29 Sep 2022, 07:20
Code:
 a1 EQU macroA
 a1 EQU macroB
 a1 EQU macroC
 irpv v,a1 { .branch#num: v }
    


I want get:
.branch1: macroA
.branch2: macroB
.branch3: macroC

How do this for irpv ?
Post 29 Sep 2022, 07:20
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8041
Location: Kraków, Poland
Tomasz Grysztar 29 Sep 2022, 07:56
With fasmg it would work as simply as you imagine:
Code:
a1 EQU macroA
a1 EQU macroB
a1 EQU macroC
irpv v,a1
  .branch#%: v
end irpv    
But with fasm 1 you need to maintain a counter manually:
Code:
a1 EQU macroA
a1 EQU macroB
a1 EQU macroC
__c equ 1
irpv v,a1 { rept 1 num:__c,next:__c+1 \{ .branch\#num: v
                                         __c equ next \} }    
Post 29 Sep 2022, 07:56
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1286
Roman 29 Sep 2022, 09:20
Thanks. Work fine.
Post 29 Sep 2022, 09:20
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8041
Location: Kraków, Poland
Tomasz Grysztar 29 Sep 2022, 11:48
Could in fact be a little simpler:
Code:
a1 EQU macroA
a1 EQU macroB
a1 EQU macroC
__c equ 0
irpv v,a1 { rept 1 num:__c+1 \{ .branch\#num: v
                                __c equ num \} }    
Post 29 Sep 2022, 11:48
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1286
Roman 29 Sep 2022, 13:55
Tomasz Grysztar wrote:
Could in fact be a little simpler:
Code:
a1 EQU macroA
a1 EQU macroB
a1 EQU macroC
__c equ 0
irpv v,a1 { rept 1 num:__c+1 \{ .branch\#num: v
                                __c equ num \} }    


Ho do jmp nxt branch ?
I mean:
macroA must jmp .branch2
.branch2: macroB must jmp .branch3
.branch3: macroC must jmp .branch4
.branch4:


Last edited by Roman on 29 Sep 2022, 15:01; edited 1 time in total
Post 29 Sep 2022, 13:55
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1286
Roman 29 Sep 2022, 14:51
I try this work.
Code:
   __c equ 0
irpv v,a1 { rept 1 num:__c+1 \{ .branch\#num: v .branch_\#num
                                .branch_\#num:
                                __c equ num \} } 
    
Post 29 Sep 2022, 14:51
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 676
Location: Russia
macomics 29 Sep 2022, 18:08
Can't you do that?
Code:
macro macroA {local end_label
jmp end_label
...
end_label: }

a1 EQU macroA
a1 EQU macroB
a1 EQU macroC
__c equ 0
irpv v,a1 { rept 1 num:__c+1 \{ .branch\#num: v
                                __c equ num \} }    
Post 29 Sep 2022, 18:08
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1286
Roman 29 Sep 2022, 20:16
This variant I try.
But some times local labels in macro not good, and create problems if I want do loop from macroC to macroA
Post 29 Sep 2022, 20:16
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.