Message board for the users of flat assembler.
> Compiler Internals > fasm DLL bugs
Hello, I am trying to load fasm.dll through python by a stdcall function call.
However, I think there is something wrong with the stack or preprocessor. The function fasm_Assemble does not return correctly.
Upon further inspection of the DLL code at fasm.asm, I noticed that if you call the function fasm_Assemble, it never restores the stack pointer before quitting.
It seemed to be missing the statement "mov esp, [esp_save]" that was present if you returned from general_error and assembler_error, so I put this statement right above the "done:" label.
However, even with this change I am still getting an error. I tried to zero in on it by moving the statement "retn 20" around and I think it happens right in "call preprocessor".
Can anyone help me out with this?
I found out the problem was that some of the registers were expected to be restored.
When I manually tweaked the source to restore the ebx and esi registers, it worked without errors.
So even though it works with assembler as-is, I think there might be some problem getting it to load with other languages.
I decided to try to fix the code so it safely restores the general purpose registers esp, ebp, edi, esi, ebx. The assembler does not seem to change all of them, but it may change in the future. Hopefully any other miscellaneous registers do not need to be restored.
;find this in fasm.asm for the DLL mov [display_pipe],eax push ebp ;change this to save the registers mov [display_pipe],eax push ebp push ebx push esi push edi ;find the done label done: mov eax,[ebx+FASM_STATE.condition] ;change to this mov esp,[esp_save] done: mov eax,[ebx+FASM_STATE.condition] pop edi pop esi pop ebx pop ebp
|19 Nov 2008, 08:48||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.