Hi,
Troy Martin wrote:Dex, before I reqested the macro, I had already known that it would increase the size, so I'm substituting the big fat loops with "call syscall".
Even if you are using the macro to call another function it can increase code size. For an example, consider the "puts" macro I posted earlier - it always pushes and pops SI even when it isn't necessary, and if you're printing several strings you'll end up with something like:
Code: Select all
push si
mov si,first_string
call printString
pop si
push si
mov si,second_string
call printString
pop si
push si
mov si,third_string
call printString
pop si
Instead of:
Code: Select all
push si
mov si,first_string
call printString
mov si,second_string
call printString
mov si,third_string
call printString
pop si
However, there are some macros that never increase code size - here's some that I always use:
Code: Select all
%macro clr 1
xor %1,%1
%endmacro
%macro pushes 1-*
%rep %0
push %1
%rotate 1
%endrep
%endmacro
%macro pops 1-*
%rep %0
%rotate -1
pop %1
%endrep
%endmacro
Also, (if you're still wondering) there is no way that I can think of to get NASM to support embedded newlines in strings (e.g.
"foo\nbar" instead of
"foo",0x13,"bar"). As an alternative your code to print strings could do it, but then "/n" would cost 2 bytes instead of one (because the language doesn't convert it into "db 0x13" at compile time).
Cheers,
Brendan