flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
WytRaven 08 Sep 2004, 13:02
Ok I figured it out...I discovered the LEA instruction, plus I finally dound one of the examples that demonstrates the proc macro's initilisation of local variables ability...
The working code is as follows for anyone else that is as new as me to all this Code: cproc _ICEInit,szName,iWidth,iHeight .wc WNDCLASS .hwnd dd ? enter xor eax,eax ;Zero EAX register mov [.wc.style],eax mov [.wc.lpfnWndProc],WndProc mov [.wc.cbClsExtra],eax mov [.wc.cbWndExtra],eax mov [.wc.hInstance],eax mov [.wc.hIcon],eax mov [.wc.hCursor],eax mov [.wc.hbrBackground],COLOR_BTNFACE+1 ;eax mov [.wc.lpszMenuName],eax mov eax,[szName] mov [.wc.lpszClassName],eax lea eax,[.wc] ;Calculate actual address ;Register window class invoke RegisterClass,eax ... ... ... _________________ All your opcodes are belong to us |
|||
![]() |
|
Imagist 09 Sep 2004, 05:48
I'm sort of new (I've been here a while, but I haven't put enough time into learning this to be very good) but I don't see why you need local variables. Why not just use the registers for temporary stuff? They are faster anyway.
|
|||
![]() |
|
WytRaven 09 Sep 2004, 06:29
Mainly because I cant place a WNDCLASS structure in registers and then pass the address pointing to the structure to RegisterClass.
There aren't enough registers, and more to the point, the fact that RegisterClass is expecting the members of WNDCLASS to be in consecutive memory locations not registers. The reason I wanted to use the stack instead of predefined data in my .data section (which is what you will see in most examples) is a matter of size optimization. Hope that helped ![]() _________________ All your opcodes are belong to us |
|||
![]() |
|
JohnFound 09 Sep 2004, 14:32
WytRaven wrote: The reason I wanted to use the stack instead of predefined data in my .data section (which is what you will see in most examples) is a matter of size optimization. Actually using local structure instead of global, doesn't make smaller the size of the application, because you have to write more instructions filling up the structure. The structure defined in initialized data memory needs only few of the fields to be filled in run-time (hInstance for example) and thus the summary size (data + code) becomes slightly smaller. (approx 3..5 bytes). Using local structures actually makes the code more "clear" and readable, and reduces code/data dependencies. Regards. |
|||
![]() |
|
WytRaven 09 Sep 2004, 17:34
Sorry I should have been clearer...
What I meant was that I only use that structure once...I don't see the need to waste RAM with a permanent copy lying around throughout my progs lifetime. A bit analy retentive I know ![]() I tend to use 'size optimisation' to refer to both image size and RAM footprint. ![]() ![]() _________________ All your opcodes are belong to us |
|||
![]() |
|
pelaillo 09 Sep 2004, 23:34
If you want to save memory for those structures used for single times you will find it valuable the help of virtual directive. You could use over and over the same small slice of RAM without loosing simplicity. Fasm rocks!
Some time ago I've done a test where everithing was local, even the MSG was in stack frame. I suffer from your same malady ![]() |
|||
![]() |
|
Matrix 09 Sep 2004, 23:39
You forgot to mention speeds, because memory writes take a lot of time.
MATRIX |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.