flat assembler
Message board for the users of flat assembler.
Index
> Main > Three small questions ! |
Author |
|
LocoDelAssembly 29 Nov 2011, 22:52
2. Yes, they affect performance quite a bit, better save what you actually modify but additionally establish a convention in which some registers are allowed to be trashed by procedures like most existing calling conventions do.
3. But with Rx you can say the amount of space to reserve (e.g. byteArray rb 4096), while your example reserve only one unit of the data type size. An appropriate equivalent would be "byteArray 4096 dup(?)" (although I'm not sure if there is some subtle difference with rb), but fasm will compile rb faster. |
|||
29 Nov 2011, 22:52 |
|
khatch 30 Nov 2011, 01:27
Hi!
well i think macro is for frequently writing like this in include/macro/proc32.inc : macro invoke proc,[arg] ; indirectly call STDCALL procedure { common if ~ arg eq reverse pushd arg common end if call [proc] } this well make your writing the program easy than you write this every time you call a function pushd arg call [proc] like hello.exe in examples in the fasmw*.zip which wrote in hello.asm : invoke ExitProcess,0 which analyzed to : pushd 0 call [Exitprocess] finally i am beginner programmer in assembly language !!!!! |
|||
30 Nov 2011, 01:27 |
|
AsmGuru62 30 Nov 2011, 15:33
I do not understand the question #1.
Personally, I use simple macros (not overly complex) just to shorten my code and make it more readable. I even have 1-line macros, like the ones I use to work with my local variables: Code: macro LocSet var, value { mov [ebp + var], value } macro LocAddr reg, var { lea reg, [ebp + var] } macro LocMove dest, src { push [ebp + src] pop [ebp + dest] } ... LocSet loc1.ofsData, esi LocSet loc1.loopCounter, 32 LocMove loc1.pObject2, loc1.pObject1 LocAddr edi, loc1.vectHandles And since my IDE has auto-complete - the "loc1." type of thing shows a list of members. Or macros for branching: Code: macro IfEqu reg, target { cmp reg, value je target } ... IfEqu eax, WM_CREATE, .OnCreate IfEqu eax, WM_DESTROY, .OnDestroy IfEqu eax, WM_CHAR, .OnChar Just to fit more code into a glance and make it more readable in the future. |
|||
30 Nov 2011, 15:33 |
|
khatch 30 Nov 2011, 16:18
Hi AsmGuru62
are you sure from your last example because i got this error while assembled it : flat assembler version 1.69.32 (498586 kilobytes memory) main.asm [7]: IfEqu eax, WM_CREATE, .OnCreate error: invalid macro arguments. and thanks for learning the beginners(which i one of them) _________________ Jesus Christ is our Savior |
|||
30 Nov 2011, 16:18 |
|
AsmGuru62 30 Nov 2011, 17:53
yep, I missed the 'value' in macro definition - was writing from memory!
It must be: Code: macro IfEqu reg, value, target ; <-- 'value' was missing! { ... } |
|||
30 Nov 2011, 17:53 |
|
magicSqr 01 Dec 2011, 00:46
majidkamali1370 wrote: Hi. Set up a benchmark test Code: stdcall test1 stdcall test2 int3 proc test1 pushad xor ecx, ecx @@: push ecx ; do something here pop ecx loop @b popad ret endp proc test2 push ebx edi esi xor ecx, ecx @@: push ecx ; do same thing here pop ecx loop @b pop esi edi ebx ret endp Set up a timer for the two procs. If you find no difference, you're not doing much in your proc. magicĀ² |
|||
01 Dec 2011, 00:46 |
|
majidkamali1370 01 Dec 2011, 00:51
How to create a timer in assembly?
|
|||
01 Dec 2011, 00:51 |
|
magicSqr 01 Dec 2011, 08:20
majidkamali1370 wrote: How to create a timer in assembly? Simplest is Code:
invoke GetTickCount
push eax
.
do your stuff
.
invoke GetTickCount
pop ebx
sub eax, ebx
eax is number of milliseconds taken. |
|||
01 Dec 2011, 08:20 |
|
majidkamali1370 01 Dec 2011, 09:57
Thank you guys
|
|||
01 Dec 2011, 09:57 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.