flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > macros with reverse order

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 414
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 18 Sep 2016, 19:04
I found on the Internet these macros:
Code:
;global.inc

;------------------------------------------------------------------
; use "iglobal" for inserting initialized global data definitions.
;------------------------------------------------------------------
macro iglobal {
  IGlobals equ IGlobals,
  macro __IGlobalBlock { }

macro iglobal_nested {
  IGlobals equ IGlobals,
  macro __IGlobalBlock \{ }

;-------------------------------------------------------------
; use 'uglobal' for inserting uninitialized global definitions.
; even when you define some data values, these variables
; will be stored as uninitialized data.
;-------------------------------------------------------------
macro uglobal {
  UGlobals equ UGlobals,
  macro __UGlobalBlock { }

macro uglobal_nested {
  UGlobals equ UGlobals,
  macro __UGlobalBlock \{ }

endg fix }              ; Use endg for ending iglobal and uglobal blocks.
endg_nested fix \}

macro IncludeIGlobals{
  macro IGlobals dummy,[n] \{ __IGlobalBlock
     purge __IGlobalBlock  \}
  match I, IGlobals \{ I \} }

macro IncludeUGlobals{
  macro UGlobals dummy,[n] \{
    \common
      \local begin, size
      begin = $
      virtual at $
    \forward
      __UGlobalBlock
      purge __UGlobalBlock
    \common
      size = $ - begin
    end virtual
    rb size
  \}
  match U, UGlobals \{ U \} }

macro IncludeAllGlobals {
  IncludeIGlobals
  IncludeUGlobals       ;will be zeroed
}

iglobal
endg

uglobal
endg

    

How to use it:
Code:
include "global.inc"

;block 1
iglobal
db 1
endg

;block 2
iglobal
db 2
endg

;block 3
iglobal
db 3
endg

IncludeAllGlobals
    

Blocks 1..3 are put in reverse order. I would like to forge macros so that they are in the correct order. How to do it?

_________________
smaller is better
Post 18 Sep 2016, 19:04
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 19 Sep 2016, 02:25
I haven't examined the code above, but I can suggest an alternative that is more efficient.

https://board.flatassembler.net/topic.php?t=12012

And the specific post that shows both forward and reverse outputs.

https://board.flatassembler.net/topic.php?p=175908#175908
Post 19 Sep 2016, 02:25
View user's profile Send private message Visit poster's website Reply with quote
CandyMan



Joined: 04 Sep 2009
Posts: 414
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 19 Sep 2016, 10:15
Your post was of help very much. I am thanking you a lot.

_________________
smaller is better
Post 19 Sep 2016, 10:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 19 Sep 2016, 10:27
You're welcome CandyMan. Smile
Post 19 Sep 2016, 10:27
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.