flat assembler
Message board for the users of flat assembler.
Index
> Main > Backwards virtual |
Author |
|
vid 28 Aug 2004, 09:41
seems you didn't really comprehend what is "virtual", only one of it's usages.
First of all, you have to reserve space on stack for variables (sub esp), otherwise you will overwrite something other or something other will overwrite your variables. |
|||
28 Aug 2004, 09:41 |
|
Dragontamer 28 Aug 2004, 16:58
That is the point. If virtual went backwards, the stack wouldn't be a problem.
Anyway, as long as you don't push/pop or call a function in the function, then there really is no loss, and it would be easier to have the second code over the first code. And if you saw the first code, the one which i do right now, i did do sub esp, 8. |
|||
28 Aug 2004, 16:58 |
|
vid 28 Aug 2004, 19:11
now i get what you wanted. Look at fasm's proc macro. You can use forward reference to get size of local data and then sustract size from base of virtual block, like:
Code: ;in macro local ..from, ..size virtual at ebp - ..size ..from = $ a dd 0 b dd 0 ..size = $ - ..from end virtual |
|||
28 Aug 2004, 19:11 |
|
vid 28 Aug 2004, 19:13
you wanted this?
Code: ;must be in macro local ..from,..size virtual at ebp - ..size ..from: a dd ? b dd ? ..size = $ - ..from end virtual |
|||
28 Aug 2004, 19:13 |
|
Tommy 28 Aug 2004, 19:28
What about this?
Code: macro back_virtual_at x { local ..start, ..end ..1 equ ..start ..2 equ ..end virtual at x - ..2 ..1: } macro end_virtual { ..2 = $ - ..1 end virtual restore ..1 restore ..2 } back_virtual_at ebp a dd ? b dd ? end_virtual mov [a],eax mov [b],ebx Last edited by Tommy on 28 Aug 2004, 19:47; edited 2 times in total |
|||
28 Aug 2004, 19:28 |
|
Tomasz Grysztar 28 Aug 2004, 19:34
Better use "restore ..1" instead of "..1 equ" - this way you can even make these macros nestable.
|
|||
28 Aug 2004, 19:34 |
|
Tommy 28 Aug 2004, 19:47
Thanks for pointing that out Privalov!
|
|||
28 Aug 2004, 19:47 |
|
Dragontamer 29 Aug 2004, 17:18
Wow. Fasm macros impress me again!!
|
|||
29 Aug 2004, 17:18 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.