News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Structure notes

Started by ecube, August 01, 2010, 07:14:21 PM

Previous topic - Next topic

ecube

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

donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ecube

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

ecube

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.

Yuri

PTR is just a synonym for DD, or DQ. They are all simple numbers. GoAsm doesn't know that it's a pointer.

ecube

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

donkey

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
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ecube

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.