The MASM Forum Archive 2004 to 2012

Project Support Forums => GoAsm Assembler and Tools => Topic started by: ecube on August 01, 2010, 07:14:21 PM

Title: Structure notes
Post by: ecube on August 01, 2010, 07:14:21 PM
I found myself frustrated with donkey on how he defined some structures(he'd set some of the structure pointers within a structure as simple ptr)

for example heres a regular structure

STRUCT1 Struct
val1 STRUCT2 <>
STRUCT2 ENDS

STRUCT2 Struct
myval dd ?
STRUCT2 ENDS

teststr STRUCT1 <>

so you could just do

mov ecx,[teststr.val1.myval]


the above 3 levels deep, what donkey did was

STRUCT1 Struct
val1 PTR
STRUCT2 ENDS

teststr STRUCT1 <>


so as you can you can't do the above the same(atleast I don't think) but what you can do is

lea edi,teststr
lea esi,[edi+STRUCT1.val1]
mov ecx,[esi+STRUCT2.myval]


anyway this was might be common knowledge to most but it took me abit to realize I could do the above, so now it's fine
Title: Re: Structure notes
Post by: donkey on August 02, 2010, 02:38:44 AM
Hi E^cube,

I'm not sure which structures you're referring to but if this is the case then it is an error in the headers and it should be fixed. Could you post any structures that have a substructure defined improperly as a pointer ? In all cases they should be defined as you suggested in the first example.

Edgar
Title: Re: Structure notes
Post by: ecube on August 02, 2010, 04:49:00 AM
Searched for PTR in *.h for the GoASM Headers folder using the Tool below

Lines Found:36014
Files Found:420

heheĀ  :bg I attached a text line listing each file and line a PTR was found
Title: Re: Structure notes
Post by: ecube on August 02, 2010, 04:51:18 AM
Also here's one of my all time favorite tools,i've used it for years, I didn't write myself but it comes with source, lets you search files/folders for strings and lists the info.
Title: Re: Structure notes
Post by: Yuri on August 02, 2010, 05:48:03 AM
PTR is just a synonym for DD, or DQ. They are all simple numbers. GoAsm doesn't know that it's a pointer.
Title: Re: Structure notes
Post by: ecube on August 02, 2010, 12:11:47 PM
Quote from: Yuri on August 02, 2010, 05:48:03 AM
PTR is just a synonym for DD, or DQ. They are all simple numbers. GoAsm doesn't know that it's a pointer.

I'm aware Yuri, and that's the point of this, it's not specifically being defined as a ptr to another structure, just a regular ptr.

Donkey personally since you defined so many structures as PTR you can just leave em if you want, the abit of indirection like I did above isn't difficult. i'm more concerned with 32bit/64bit structure sizes than anything else, which so far so good on those :U
Title: Re: Structure notes
Post by: donkey on August 02, 2010, 11:04:35 PM
Hi E^cube,

Even if I defined each structure with a pointer type as is done in C it would still just resolve to DD or DQ and would not generate an error in GoAsm since it does not do any type checking at all. For that reason I decided to leave out thousands of data types by just using PTR for all pointers.

Edgar
Title: Re: Structure notes
Post by: ecube on August 04, 2010, 10:01:54 AM
Quote from: donkey on August 02, 2010, 11:04:35 PM
Hi E^cube,

Even if I defined each structure with a pointer type as is done in C it would still just resolve to DD or DQ and would not generate an error in GoAsm since it does not do any type checking at all. For that reason I decided to leave out thousands of data types by just using PTR for all pointers.

Edgar

Donkey I understand I was just saying originally I was frustrated because it wasn't defined in the easy way i'm use to, but now that I discovered the indirect approach it doesn't matter.