flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Tricky data macro

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 672
Roman
Code:
macro xcod {
                dd X
                restore X              
                 }  

section '.code' code readable writeable executable
start:  X EQU 1
         X EQU 2
         X EQU 4 
         X EQU 5

section '.data' readable writeable
         xcod
    


I want get in section '.data' all X. And X EQUATES there may be many (1 or 2000 X EQUATES ) !
The result in section '.data' should be a:
dd 1
dd 2
dd 4
dd 5

How to do it ?
Post 01 Feb 2014, 16:25
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
Post 01 Feb 2014, 16:32
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 672
Roman
revolution
Sorry, but show me simple macro on my example.
Please.
Post 01 Feb 2014, 16:39
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
Code:
;<--- put the list_builder macro here

list_builder xcod

section '.code' code readable writeable executable
start:
  .xcod { dd 1 }
  .xcod { dd 2 }
  .xcod { dd 4 }
  .xcod { dd 5 }
ret

section '.data' readable writeable
         xcod_list    
Post 01 Feb 2014, 16:44
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 672
Roman
I have to use this macro ? Am I right?
macro list_builder name {
local m,c ;avoid name clashing
c equ 0 ;initialise the counter
macro .#name [a] \{
\common
rept 1 x:c+1 \\{
c equ x ;update the counter
macro m\\#x a ;open the macro
\\}
\}
macro name#_list \{
rept c x \\{
m\\#x ;replay each line
\\}
\}
}
list_builder list2


Last edited by Roman on 01 Feb 2014, 16:48; edited 1 time in total
Post 01 Feb 2014, 16:47
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17450
Location: In your JS exploiting you and your system
revolution
All except for the last line which is not part of the macro.
Post 01 Feb 2014, 16:48
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7750
Location: Kraków, Poland
Tomasz Grysztar
Roman wrote:
Code:
macro xcod {
                dd X
                restore X              
                 }  

section '.code' code readable writeable executable
start:  X EQU 1
         X EQU 2
         X EQU 4 
         X EQU 5

section '.data' readable writeable
         xcod
    


I want get in section '.data' all X. And X EQUATES there may be many (1 or 2000 X EQUATES ) !
The result in section '.data' should be a:
dd 1
dd 2
dd 4
dd 5

How to do it ?
Funny coincidence (?), but it looks like the new directive that I was considering recently (after reading the other thread) would fit perfectly here. I thought I could implement an IRPV directive that would allow to iterate through all the past values of a symbolic variable. I'm still not sure whether it would really be useful enough to justify such an addition to language.
Post 01 Feb 2014, 16:51
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 672
Roman
Tomasz Grysztar
This can be useful in 3d games !!!
I seriously !

If user create texture ( interface ID3D11Texture2D = 4 bytes in data), macro put all textures in data.

DataBgn:
put all textures
DataEnd:

When we go out of the game, DX11 release all textures from DataBgn to
DataEnd.
We got the automatic creation and deletion textures for Directx 11 !!!
Do not need hands to write every texture in date !!! Its very good !


Last edited by Roman on 01 Feb 2014, 17:04; edited 1 time in total
Post 01 Feb 2014, 16:59
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 672
Roman
revolution
Big thanks ! Smile
Post 01 Feb 2014, 17:02
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 YouTube, Twitter.

Website powered by rwasa.