flat assembler
Message board for the users of flat assembler.
Index
> Windows > local variable ~ stack "enter" fails |
Author |
|
wanderer 01 Oct 2004, 17:35
vbVeryBeginner wrote:
You should know that local variables are placed on stack and that means that you can't just write push <localvar> as it will result in instruction like this: push ebx+14. Write instead "lea eax,[localvar] / push eax" or something like this. Try also searching the forum, this have already been discussed somewhere. _________________ Best regards, Antoch Victor |
|||
01 Oct 2004, 17:35 |
|
vbVeryBeginner 02 Oct 2004, 07:35
yup, you are correct, wanderer, thanks
Code: push NULL lea eax,[pipeSecAttr] push eax lea eax,[pipeWriteH] push eax lea eax,[pipeReadH] push eax call [CreatePipe] is equal to Code: invoke CreatePipe,pipeReadH,pipeWriteH,pipeSecAttr,NULL is equal also to Code: lea eax,[pipeSecAttr] lea ebx,[pipeWriteH] lea ecx,[pipeReadH] invoke CreatePipe,ecx,ebx,eax,NULL when using local variable wanderer wrote:
em, i don't know what keyword to identify that particular thread, but i search using ur nick :p, and saw a thread named something like "iStream", which if see from the title ~ totally unassociate with my problem , so i put the link here, (for reference to others) http://board.flatassembler.net/topic.php?t=152 sincerely, vbVeryBeginner d(&-&)b |
|||
02 Oct 2004, 07:35 |
|
pelaillo 02 Oct 2004, 13:32
Hi vbVeryBeginner,
http://board.flatassembler.net/topic.php?t=2346 Look also that is better to use a dot so you can reuse names for locals through procedures. |
|||
02 Oct 2004, 13:32 |
|
vbVeryBeginner 02 Oct 2004, 18:31
actually, i am not really so understand about the concept of having a (dot). variable
i know they exists in structure, but what is the meaning of a dot (.) variable? the feature and so on? i am kinda blur :-/ sincerely, me d(&9#)b |
|||
02 Oct 2004, 18:31 |
|
vbVeryBeginner 02 Oct 2004, 18:32
what is the different of a dot variable that reside in structure and the dot variable that function as local variable in proc stack?
|
|||
02 Oct 2004, 18:32 |
|
wanderer 02 Oct 2004, 22:41
vbVeryBeginner wrote: actually, i am not really so understand about the concept of having a (dot). variable Quote from fasm's manual: Tomasz Grisztar wrote:
vbVeryBeginner wrote: what is the different of a dot variable that reside in structure and the dot variable that function as local variable in proc stack? You should read the fasm manual. _________________ Best regards, Antoch Victor |
|||
02 Oct 2004, 22:41 |
|
wanderer 03 Oct 2004, 01:52
vbVeryBeginner wrote:
Well, I didn't post anything for a long time, so it wasn't best idea . I tryed to find "local variables" with <search for all terms> and found several threads that may be interesting for you. Here is one of them: http://board.flatassembler.net/topic.php?t=441 _________________ Best regards, Antoch Victor |
|||
03 Oct 2004, 01:52 |
|
vbVeryBeginner 03 Oct 2004, 02:43
thank you, wanderer for the searching and the thread
Quote:
well, i notice that too, but i sincerely wish you would post a lot in the future, you seem to be a knowledgeable person in ASM *ps: hopefully i am not wrong sincerely, vbVeryBeginner d(^-^)b |
|||
03 Oct 2004, 02:43 |
|
vbVeryBeginner 03 Oct 2004, 05:28
i try this code, it could be assembled but display other than the text i wish to see
Code: wmCREATE: call testing_1 jmp wmBYE proc testing_1 txt1 db 'text 1 from proc testing_1',0 enter lea eax,[txt1] invoke MessageBox,NULL,eax,eax,MB_OK return endp |
|||
03 Oct 2004, 05:28 |
|
roticv 03 Oct 2004, 07:17
Are you crazy? Local variables are not initialized when you are about to use it. They are part of the stack. So you are essentially displaying all the data you pushed onto the stack previously.
If you want strings, declare them as global data. |
|||
03 Oct 2004, 07:17 |
|
vbVeryBeginner 03 Oct 2004, 08:33
Code: proc testing_1 push ebp mov ebp,esp push 0x00494847 push 0x46454443 push 0x42414020 mov eax,esp invoke MessageBox,NULL,eax,eax,MB_OK mov esp,ebp pop ebp return endp if this is possible, why pushing string into stack is impossible? Last edited by vbVeryBeginner on 03 Oct 2004, 08:53; edited 1 time in total |
|||
03 Oct 2004, 08:33 |
|
vbVeryBeginner 03 Oct 2004, 08:40
i wonder, if that possible for the "enter" to reverse our string and push them into stack accordingly in dwords
or string is not suitable to be put on stack?? must (MUST) be treated as global data? which one is better, optimize or guru ways? |
|||
03 Oct 2004, 08:40 |
|
roticv 03 Oct 2004, 09:06
It takes lesser number of bytes if they are declared as global data.
|
|||
03 Oct 2004, 09:06 |
|
wanderer 03 Oct 2004, 10:40
vbVeryBeginner wrote: if this is possible, why pushing string into stack is impossible? Of course, it's possible, but you'll have to do in runtime, not at the time of compilation. I think one should have special reason to do it, because defining strings as global data really takes less bytes, as roticv said. Another way of string definition (for example, used only once) is: Code: push MB_OK call @f db "Message",0 @@: call @f db "Title",0 @@: invoke MessageBox,NULL _________________ Best regards, Antoch Victor |
|||
03 Oct 2004, 10:40 |
|
vbVeryBeginner 03 Oct 2004, 12:19
wanderer wrote:
i guess it is better to group a group of proc variable under a place for better management, otherwise, some of the proc variables are on stack, some on global... em... ... anyway.. u show me a nice trick thanks Code: push MB_OK call @f db "Message",0 @@: call @f db "Title",0 @@: invoke MessageBox,NULL sincerely, vbVeryBeginner |
|||
03 Oct 2004, 12:19 |
|
wanderer 03 Oct 2004, 17:09
vbVeryBeginner wrote: i guess it is better to group a group of proc variable under a place for better management, otherwise, some of the proc variables are on stack, some on global... em... ... You can have all the variables on stack, however in this case you'll have to provide initialization code if you wish them to be initialized. Global variables can be initialized at the compile time, local - only at runtime. This is because memory for local variables is allocated when entering procedures (and therefore are filled with random values), and global variables exist all the time program runs. vbVeryBeginner wrote: anyway.. Feel free to ask . This trick is used in 'win32ax.inc' to make possible to write something like: Code: invoke MessageBox,NULL,"Message","Title",MB_OK This macro also lets you use local variables addresses in it. _________________ Best regards, Antoch Victor |
|||
03 Oct 2004, 17:09 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.