flat assembler
Message board for the users of flat assembler.

Index > Main > Why Undefined symbol???

Author
Thread Post new topic Reply to topic
Chijik



Joined: 04 Feb 2004
Posts: 3
Chijik
struc _b
{
.b1 db 0
}

mov ax,_b.b1 ;Error:Undefined symbol!!! Smile))
Post 04 Feb 2004, 11:38
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Because "struc" does not define any labels. It simply defines some "shape" for defining data.

Code:
struc _b1
{
.b1 db 0
} 

My_b1   _b1
_b1       _b1   ; this is valid too. Smile

mov  al, [My_b1.b1] ; should be OK
mov  al, [_b1.b1]     ; should be OK too.
    
Post 04 Feb 2004, 11:44
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Chijik



Joined: 04 Feb 2004
Posts: 3
Chijik
Because "struc" does not define any labels. It simply defines some "shape" for defining data.

So, working with dymamic data is not possible Sad
Sit down. 2. Smile
Post 04 Feb 2004, 12:13
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
Chijik wrote:
So, working with dymamic data is not possible Sad


Wrong answer, young man! Wink
Of course you can use dynamic data with structures without any problem. I do it all the time. Look below:
Code:
struc TMyData {
  .field1 dd ?
  .field2 dd ?
}

; for easy use of following construction there is a macro "struct"
; in FASM standard macro library.
; if you want to use "struct" macro, use:
;
; struct TMyData instead of virtual statement.
;
virtual at 0
  TMyData TMyData
  sizeof.TMyData = $
end virtual
; allocate some dynamic memory for array...
        invoke  GetProcessHeap
        invoke  HeapAlloc, eax, 0, 1000 * sizeof.TMyData
        mov     esi, eax
        xor     eax, eax
; Then use it as array of TMyData structures...
.fillloop:
        mov     [esi+eax+TMyData.field1], eax
        mov     [esi+eax+TMyData.field1], 1234h
        add     eax, sizeof.TMyData
        cmp     eax, 1000*sizeof.TMyData
        jne     .fillloop

;....
    
Post 04 Feb 2004, 12:57
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you should read fasm's docs more carefully:

struc is like macro, only difference is that used struc must be preceded by label, which is then appended before any symbol starting with '.' in struc.

To define labels, you should create one virtual structure (virtual = no data really gets defined, only labels are), with name preceding structure same as structure name. thus you'll get names for dynamic access you wanted.
Post 04 Feb 2004, 19:10
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
there is standard struct macro for this

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 04 Feb 2004, 21:45
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Chijik



Joined: 04 Feb 2004
Posts: 3
Chijik
[quote="JohnFound"]
Chijik wrote:
So, working with dymamic data is not possible Sad


Wrong answer, young man! Wink
Of course you can use dynamic data with structures without any problem. I do it all the time. Look below:

Through anus... Ok, thank you.
Post 05 Feb 2004, 12:55
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.

Powered by rwasa.