flat assembler
Message board for the users of flat assembler.

Index > Main > Size of an array

Author
Thread Post new topic Reply to topic
shaolin007



Joined: 03 Sep 2004
Posts: 65
shaolin007
Could someone show me example in FASM for getting the size of an array without manually calculating it each time?

Code:
array    db 20 dup (0)
    
Post 21 Jun 2005, 20:56
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
Just:
Code:
array db 20 dup (0)
sizearr = $-array
;or make it persistent
sizearr dd $-array
    
Post 21 Jun 2005, 22:24
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
shaolin007



Joined: 03 Sep 2004
Posts: 65
shaolin007
Hmm tried that and it seemed to have a detrimental effect when passed to a function in my code.
Post 21 Jun 2005, 22:36
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7736
Location: Kraków, Poland
Tomasz Grysztar
Try the sample macro from section 2.3.4 of fasm's manual:
Code:
    struc db [data]
     {
       common
        . db data
        .size = $ - .
     }    

after such definition this code:
Code:
array    db 20 dup (0)     

will define array.size constant with value 20.
Post 21 Jun 2005, 22:52
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.