Einzelnen Beitrag anzeigen

Kas Ob.

Registriert seit: 3. Sep 2023
346 Beiträge
 
#25

AW: In Asm-Prozedur eine Exception auslösen

  Alt 5. Nov 2023, 11:32
OK, there much to say about this but really i don't like write essays

You can force the compiler to not introduce a stack frame by using .noframe in the x64 assembly block.

so the code can be like this
Code:
PROCEDURE test;
const
   pExClass : ExceptClass = (Exception);
   sErr : String = ' My message ';
asm
    {$IfDef CPUX86}
   mov ecx,sErr
   mov dl ,1
   mov eax,pExClass
   call Exception .Create
   call System.@RaiseExcept
   {$Else}
   .noframe            //  crucial here
   push rbp
   sub rsp,$20
   mov rbp,rsp
   mov r8,sErr
   mov dl ,$01
   mov rcx,pExClass
   call Exception .Create
   mov rcx,rax
   call System.@RaiseExcept
   lea rsp,[rbp+$20]
   pop rbp
   {$EndIf}
end ;
Yet again, use that on your risk !

Edit: to fix an extra pop useless in that example but will cause problem in real life code.
Kas
  Mit Zitat antworten Zitat