It would be great if jwasm could intelligently order parameter-loads for fastcall (x64) so that registers don't overwrite each other.
I have a large existing codebase that I want to port to 64-bit with as few changes as possible. Jwasm seems perfect for the job except for this one thing:
Example:
invoke Function,rax,rcx
Currently this compiles to:
mov rcx,rax
mov rdx,rcx ; <- The wrong parameter is loaded into rdx (and JWasm doesn't warn about it!)
call Function
In this case the problem would be fixed by simply changing the order of the loads:
mov rdx,rcx
mov rcx,rax
call Function
Another example:
invoke Function,rdx,rcx
In this case the problem cannot be solved by re-ordering the loads, but can be handled with xchg:
xchg rcx,rdx
call Function
Is this parameter-ordering issue on your ToDo list?
I made small change so JWasm detects and warns about these register-overwrites, but my C-skills are not that acute so writing the code to sort and load parameters in an arbitrary order is beyond me :-)
To emit a warning might indeed be justified.
Automatic reordering? A fool-proved solution might be hard - or impossible? - to implement if there are circular references. Probably not worth it.
JWasm v2.04 will now emit an error if parameter values are destroyed
No "automatic reodering" is implemented, though!