flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
a115433
number of instructions isnt property of function/macro.
so it can be infinite, and 0. |
|||
![]() |
|
pete
Probably my question was unclear. If, for instance i have a set of instructions that get repeatedly executed through the runtime of a program, i want to optimize the program to store the same set of instructions as seldom as possible. This forces me to use functions or procedures. But of course i want the program to run as fast as possible. So when i call a procedure inside my program very often, but this procedure consists of only four instructions, i am thinking of converting this procedure into a macro instead, because the jumping around in the memory that comes with procedures probably isn't worth the four instructions.
So what i am interested in is, how many instructions should a procedure at least consist of, so that the memory jumps (through call and return) are endorsed? |
|||
![]() |
|
edfed
4 instructions? ok, lets go for a function, then, you will have many more flexibility during software evolution.
i have a fucntion with 4 instructions, including ret. Code: asm: .call=0 .func=4 .op1=8 .op2=12 .op3=16 .op4=20 .op5=24 .op6=28 .op7=32 .op8=36 cmp dword[esi+.func],0 je @f call near[esi+.func] @@: ret |
|||
![]() |
|
pete
Thanks for the example edfed, but why do i gain flexibility during software evolution with a function?
|
|||
![]() |
|
edfed
simple to explain.
a function, for example, put a picture. instead of puting pixel inside the picture function, you use putpixel subfunction, then, you just give X,Y and color to putpixel. then, if you change screen mode (320*200*8bpp to 1280*1024*32bpp), only putpixel function will change. if you want to draw line, you will use the same putpixcel function, draw a rectangle, draw a circle, draw a triangle, put text, etc... and all will use only one putpixel fucntion, then, mode switch will be easy. and if one day you use hardware acceleration, some complex putpixel queue will be good, or something like that. there are many other examples where a function is good. a function that have only 4 instruction can easy become fat, adding security tests, particular case, etc.. |
|||
![]() |
|
pete
Well, thanks!
|
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.