flat assembler
Message board for the users of flat assembler.

Index > Main > Is my array struc correct?

Author
Thread Post new topic Reply to topic
Gonzalo28



Joined: 03 Feb 2008
Posts: 9
Gonzalo28
Hi all! Very Happy
Is correct this struc for arrays?
Code:
struc array type, [data]{
common
    . type data
    .lenght = $-.
}
    

If the answer is yes, how i access for the first(or any) element?

Sorry for my english....is veeeeery bad Embarassed
Post 03 Feb 2008, 01:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17719
Location: In your JS exploiting you and your system
revolution
Code:
MyString array db 'test',0 ;defined your string
mov al,[MyString] ;first element
mov al,[MyString+1] ;second element
mov ebx,MyString ;pointer to beginning
mov ecx,MyString.lenght ;(sic) the length    
Post 03 Feb 2008, 06:21
View user's profile Send private message Visit poster's website Reply with quote
Gonzalo28



Joined: 03 Feb 2008
Posts: 9
Gonzalo28
For strings i use this
Code:
struc string [data]{
common
    . db data
    .lenght = $-.-1
}
    

and for unicode i use
Code:
struc utf16 [data]{
common
    . dw data
    .lenght = $-.-1
}
    


My idea is for use with integers arrays, float arrays, struct arrays etc...

this better?
Code:
;se = size of one element
struc array se, type, [data]{
common
    . type data
    .lenght = $-.
    .se dd se
} 
; For use
; define one array
MyArray 4, dd, 2345,253,5235,25
mov ebx, [MyArray] ; first element?
mov ecx, [MyArray+MyArray.se] ; well?
    


Again sorry for my english...
Post 03 Feb 2008, 18:22
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3056
Location: vpcmipstrm
bitRAKE
Code:
struc pascal [data] {
  common
      db .len
    . db data
    .len=$-.
}    
Post 03 Feb 2008, 19:36
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Gonzalo28: small mistake: you forgot "array" in your code
Post 03 Feb 2008, 21:47
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Gonzalo28



Joined: 03 Feb 2008
Posts: 9
Gonzalo28
Quote:

Gonzalo28: small mistake: you forgot "array" in your code

Yes, i sorry...
Code:
;se = size of one element
struc array se, type, [data]{
common
    . type data
    .lenght = $-.
    .se dd se
} 
; For use
; define one array
MyArray array 4, dd, 2345,253,5235,25
mov ebx, [MyArray] ; first element?
mov ecx, [MyArray+MyArray.se] ; no work... 
    
Post 03 Feb 2008, 23:26
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 GitHub, YouTube, Twitter.

Website powered by rwasa.