flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > linked list macro

Author
Thread Post new topic Reply to topic
Ralph



Joined: 04 Oct 2003
Posts: 86
Ralph 02 Jun 2004, 06:06
I have a big linked list consisting of a small header, a pointer to the previous item, and an included file. Kind of like this:
Code:
dd 0
__item1: include 'item1'
dd __item1
__item2: include 'item2'
dd __item2
__item3: include 'item3'
    

I'm trying to figure out a better way to link them, preferably using some sort of anonymous labels, which won't work because those included files could use them as well. I don't suppose there is some way to use labels local to that file only or something along those lines?
Post 02 Jun 2004, 06:06
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 04 Jul 2004, 13:02
Could you use a macros similar to this do create the linked list?

Code:
prev_link equ 0

macro chain a, b {
 local c
 label c
 dd prev_link
 label a
 include b
 prev_link equ c
}

; Here's how it is used:
chain __a, 'apples'
chain __b, 'bananas'
chain __c, 'carrots'
    


This won't solve the label issue though; perhaps you could append a line of text specific to each file to the label (not sure how this would be done...)

_________________
Charles Childers, Programmer
Post 04 Jul 2004, 13:02
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 08 Jul 2004, 09:04
Wouldn't something like this be enough?

Code:
macro linked [filename]
 { common local previous
     previous = 0
   forward
     dd previous
     previous = $
     include filename }

linked 'item1','item2','item3'    
Post 08 Jul 2004, 09:04
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.