flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > initialize structure data

Author
Thread Post new topic Reply to topic
Treant



Joined: 09 Oct 2009
Posts: 16
Location: Russia
Treant 09 Jan 2011, 11:37
I initialize data in structure next code for sample:
Code:
wc WNDCLASSEX

mov [wc.cbSize], 48
mov [wc.style], 0
mov [wc.lpfnWndProc], WndProc
mov [wc.cbClsExtra], 0
mov [wc.cbWndExtra], 0
mov [wc.hInstance], 400000h
mov [wc.hIcon], 0
mov [wc.hCursor], 0
mov [wc.hbrBackground], 6
mov [wc.lpszMenuName], 0
mov [wc.lpszClassName], Title
mov [wc.hIconSm], 0    


these instructions can remove if initialize structure field
next code do it:
Code:
wc:
  dd 48
  dd 0
  dd WndProc
  dd 0
  dd 0
  dd 400000h
  dd 0
  dd 0
  dd 6
  dd 0
  dd Title
  dd 0
virtual at wc
  wcex WNDCLASSEX
end virtual
    

also we can initialize structure next:
Code:
struc WNDCLASSEX
{
 .cbSize dd 48
 .style dd 0
 .lpfnWndProc dd WndProc
 .cbClsExtra dd 0
 .cbWndExtra dd 0
 .hInstance dd 400000h
 .hIcon dd 0
 .hCursor dd 0
 .hbrBackground dd 6
 .lpszMenuName dd 0
 .lpszClassName dd Title
 .hIconSm dd 0
}
    

but we can't dinamically change stucture fields values
it would be nice to add dinamically change stucture fields values feature
May be i don't know how do it?
Question
Post 09 Jan 2011, 11:37
View user's profile Send private message Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 138
SFeLi 09 Jan 2011, 12:05
Code:
wc WNDCLASSEX sizeof.WNDCLASSEX,0,WndProc,...    
Post 09 Jan 2011, 12:05
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4353
Location: Now
edfed 09 Jan 2011, 13:33
structures initialised by code will take more bytes that strcutures initialised by datas.

in the first case, initialisation uses instructions to encode the values
in the second case, datas are still initialised by the data definition directives.

of course, under windows, it is possible to do it both ways, but the more used is the first one, via invoke macro.
Post 09 Jan 2011, 13:33
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.