You're right, fasm is not just an assembler, it's a HLA.Rusky wrote:Not really assembly anymore then, is it?
Not necessarily.Brendan wrote:It's "using the assembler's pre-processor to construct an entirely new/different language that isn't assembly at all", which I'd expect to lead to crappy executable code because the underlying assembler won't do any optimisation whatsoever.
First you could write optimized assembly with macros (it's preprocessor is *really* featurefull). You can create code specific to argument size, for example (it's a silly example, but I hope you get the point)
Code: Select all
macro mymacro arg
{
if ~ arg in rax, eax, ax
push rax
end if
if arg in rbx,rcx,rdx,rsi,rdi
mov rax, arg
else
if arg in ebx, ecx,edx,esi,edi
xor rax, rax
mov eax, arg
else
movzx rax, arg
end if
end if
... do something ...
if ~ arg in rax, eax, ax
pop rax
end if
}
Third, it repeats optimalisation until code unchanged (no further optimalisation can be done). This could mean thousands of passes (not just 2 passes like most assemblers do).
Finally it's not just theory, I use this for real, from a C like source my compiler generates assembly primarily for fasm, which can be assembled using a massive macro header file. The results are pretty good.
ps.: writing the macros to be efficient could be really tricky, it's not an easy task at all. But the point is, it can be done.