flat assembler
Message board for the users of flat assembler.

Index > Main > how to declare an array of struc vars?

Author
Thread Post new topic Reply to topic
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
Code:
struct Star
 r dd ?
 g dd ?
 b dd ?
 dist dd ?
ends
    

How do I declare array of above structure?
stars Star 10 dup <>
Doesn't seem to work Sad

_________________
Code:
 o__=-
 )
(\
 /\  
    
Post 06 Nov 2007, 11:50
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6035
Location: Poland
MHajduk
Maybe this way:
Code:
stars rd 10 * (sizeof.Star/4)    
Question
Post 06 Nov 2007, 12:13
View user's profile Send private message Visit poster's website Reply with quote
0.1



Joined: 24 Jul 2007
Posts: 474
Location: India
0.1
Kludgey! But Works!
Isn't there a more direct, simpler way?

_________________
Code:
 o__=-
 )
(\
 /\  
    
Post 06 Nov 2007, 12:29
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1606
Location: Ukraine
shoorick
stars rb 10 * sizeof.Star
Post 06 Nov 2007, 12:54
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2914
Location: [RSP+8*5]
bitRAKE
Code:
repeat 10
  rb sizeof.Star
end repeat    
There isn't an array concept within the FASM language. MASM tries to fake an array concept with DUP, but initialization of multi-dimentional arrays is broken in MASM. It is better to leave the implementation of arrays to the programmer, imho. This greater flexiblity does add to the learning curve, but once you get to 0.2 you'll be glad the options are all open. Razz
Post 06 Nov 2007, 20:28
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Note that actually does exist dup in fasm, the problem is that the win32 headers does not "overload" it to support structures defined with the struct macro.

hmmm, would be so hard to implement it? I gonna give it a try but don't expect much Razz
Post 06 Nov 2007, 21:47
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Loco: main problem will be, of course, that you can't overload operator in FASM
Post 06 Nov 2007, 23:05
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
But I can match the macro argument and react accordingly. However I don't understand why match is not working inside the struc, even if I do "match times =dup (values), 10 dup (5)" it doesn't match while it matchs perfectly when I test it outside Confused

I will try more before posting something.
Post 06 Nov 2007, 23:59
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you must be messing something, matching inside struc works:
Code:
struc XXX arg
{
  match =special, arg 
  \{
    display 'oh yeah'
  \}
}

foobar XXX special    


maybe it's because you use reservered word "times" as name of match argument?
Post 07 Nov 2007, 00:22
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
No, just because I'm stupid. I've misplaced the "display 'reachable?',13,10" so I believed that the sub struc was overriding the one generated by the original headers but NO, so the match wasn't ever processed by the preprocessor.

Seems that I need some rest before continuing Smile

[edit]After my dinner I realized what is the problem but now I'm lazy to finish it Razz
Tomorrow (GMT-3) I'll post the code[/edit]
Post 07 Nov 2007, 00:30
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6035
Location: Poland
MHajduk
Vinita, try this:
Code:
proc        X

       ; Local table of 10 copies of 'Star' structure.
   ;
   local stars[10]:Star

        ; Some code.

    ret
endp    
Smile
Post 07 Nov 2007, 12:53
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.