flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > questions about the structure macros

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 24 Oct 2003, 21:07
Hi everyone,
I have some questions about the macro definitions in the previous post, I'm used to the "old fashioned" way of programming in assembler and would like to learn to use a more organized way, and the new structure macros may be it. I would like to ask a few questions about the struct macros.

Question 1
How would access the x member of point of the structure WINDOWPLACEMENT?
like this?: mov eax,ptMinPosition.x OR mov eax,rcNormalPosition.left

struct POINT
DWORD x
DWORD y
ends

struct RECT
DWORD left
DWORD top
DWORD right
DWORD bottom
ends

struct WINDOWPLACEMENT
DWORD length
DWORD flags
DWORD showCmd
POINT ptMinPosition
POINT ptMaxPosition
RECT rcNormalPosition
ends

--------------------------------------------------------
Question 2:
How would I define an array of many dwords (or any other data type) in the structure definition?

struct MYSTUCTURE
DWORD data1
WORD data2
like this?: BYTE mystring times 80 db 0
like this?: BYTE mystring <times 80 db 0>.
ends
--------------------------------------------------------
Question 3:
How about a POINTER data type for various kinds of data
like this:

struct MYSTRUCTURE
TPTRZ arrayofchar ; pointer to array of characters (text,zero terminated)
DPTR arrayofdwords ; pointer to array of dwords
PPTR arrayofpointers ; pointer to array of pointers
ends

Now TPTR,DPTR,PPTR would all be dword size, unless you are programming for the AMD64 processor! in which they would be all
qword size!!

HEY PRIVALOV!, you are doing an excellent job on this assembler! Very Happy When do you sleep? Shocked You deserve a vacation! Cool
Post 24 Oct 2003, 21:07
View user's profile Send private message Reply with quote
eet_1024



Joined: 22 Jul 2003
Posts: 59
eet_1024 24 Oct 2003, 23:47
Answer 1:
First, MOV's in fasm are like those in debug; mov eax, 0x12345678 loads an immediate, mov eax, [0x12345678] loads the dword stored at address 0x12345678

If you defined MyInstance WINDOWPLACEMENT

You can load eax with the address of x for MyInstance with:
mov eax, MyInstance.ptMinPosition.x

Or to load eax with the value of x use:
mov eax, [MyInstance.ptMinPosition.x]

Answer 2:
Look at my post for SZ in http://board.flatassembler.net/topic.php?t=273

Answer 3:
I think the following will work:
TPTRZ equ DWORD
DPTR equ DWORD
PPTR equ DWORD
Post 24 Oct 2003, 23:47
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 25 Oct 2003, 12:00
Thanks eet_1024, Here is a c example of something that I want to do.

struct gfxinfo {
unsigned word vendorid1
unsigned word vendorid2
char vendorname[40]
}

struct gfxinfo mygfxinfo = {0abcdh,0deffh,"Matrox Millenium Mystique 220"}

Is there a way to do this with the structure macros in the previous post?
Post 25 Oct 2003, 12:00
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8411
Location: Kraków, Poland
Tomasz Grysztar 25 Oct 2003, 13:10
For this purpose it's better to use the "native" struc, like:
Code:
struc gfxinfo id1,id2,name
 {
  .vendorid1 dw id1
  .vendorid2 dw id2
  .vendorname db name ; or du if you're using WideChar functions
  times 40-($-.vendorname) db 0 ; repeating might be unnecessary
 }

mygfxinfo gfxinfo 0abcdh,0deffh,"Matrox Millenium Mystique 220"    
Post 25 Oct 2003, 13:10
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt 25 Oct 2003, 22:24
Ok everyone, thanks for your help Razz , I'll give all the solutions a try.
Take Care,
Matt
Post 25 Oct 2003, 22:24
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.