flat assembler
Message board for the users of flat assembler.

Index > Main > structures...

Author
Thread Post new topic Reply to topic
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
I was just finishing the last lesson, and once again it seems some sort of ignorance dawns on me in such a way that makes me wonder if i should even be writing the AFS project...

Code:
struc string [text] {
common
local size
.size dd size ;Don't include .size
.text:
forward
    db text
common
   db 0
size = $ - .text }

;some code, including declaration of str0, str1, and str2 (str0 and str1 are of the string structure)

    mov dword [str2 + string.size], str2-str0-5
    


The extra stuff was taken out, but for some reason this seems to not work. Mainly...

Quote:
flat assembler version 1.69.10 (16384 kilobytes memory)
/home/kohlrak/projects/AFS/AFS/linux/../12.asm [47]:
mov dword [str2 + string.size], str2-str0-5
error: undefined symbol 'string.size'.
Post 07 Dec 2009, 22:21
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
string.size is not a defined symbol for struc, however if you do:
Code:
str2 string 'some',0x0A,'text'    

then actually the symbol str2.size is defined:
Code:
mov dword [str2.size], str2-str0-5    
Post 07 Dec 2009, 23:20
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
str2 is actually an rb, so that doesn't work.

I know i've done something like this before when doing windows programming, but for some reason i can't get it to work anymore. I can even find posts here where suggestions like this are made, so i'm guessing it's something special one of the windows includes add, but i can't find which include it is...
Post 07 Dec 2009, 23:41
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
Well you can do string.size with struct:
Code:
struct string
    size dd ?
    ; not sure how to handle this bit though...
ends    
Post 08 Dec 2009, 01:01
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
I could've sworn that struc itself was rewritten along with struct. Oh well, point made... I'll either have to write a wrapper struc to rewrite struct or support it in my struc. Thanks for your help.
Post 08 Dec 2009, 01:14
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
it remember me my problem there.
ad it was solved:
http://board.flatassembler.net/topic.php?t=10831
Wink
Post 08 Dec 2009, 02:40
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
Related problems, but not quite the same one. My main issue is that I have to do this:

Code:
meow.size = 0
meow.text = 4
struc meow param {
.size dd 0
forward
.text db param }

mov eax, [eax+meow.size]    


instead of:

Code:
struc meow param {
.size dd 0
forward
.text db param }

mov eax, [eax+meow.size]    


because otherwise the code won't work. I could've sworn i was able to do the second code when i did windows programming, but perhaps i was wrong.
Post 08 Dec 2009, 03:08
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
struc doesn't DECLARE anything, it just DEFINES a structure.

Code:
struc meow param {
.size dd 0
forward
.text db param } 

declared meow 4

mov eax, [eax+declared.size]    
Smile

(just like a macro)

_________________
Previously known as The_Grey_Beast
Post 08 Dec 2009, 04:13
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak
Indeed, i just thought that since i was able to do it (perhaps i was using struct somehow before) before, it was just a fancy feature of a structure.
Post 08 Dec 2009, 19:12
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
from tha fasm manual, i read that:
Code:
struct point x,y
{
dd x,y
}

p1 point 1,2

mov eax,[p1.x]
mov ebx,[p1.y]
    

struct is just an addressing method

you can write a macro that use the structure.
Post 08 Dec 2009, 21:28
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
struct is not the same as struc
Post 09 Dec 2009, 20:58
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4240
Location: 2018
edfed
erf. sorry. struc point x,y
Post 10 Dec 2009, 00:23
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.