Registers to protect lazarus / 1-Linux ---------------------------------------------------------------------- sean_vn · 2014-07-19 05:30 I have written some assembly language code in FP for x64 Linux.  I couldn't find the exact calling conventions.  I presumed the standard AMD64 Linux conventions, the same as C on that platform. It seemed to work at first for simple test programs but now things are getting messed up when I try larger programs. What is the exact calling convention and what registers must be protected.  I assume parameters are passed as rdi,rsi,rdx,r8,r9,r10,r11 I assume a function result is returned in rax. I assume I can anyway trash rax,rcx,rdx,r8,r9,r10,r11 I assume I must preserve  rbp,rbx,r12,r13,r14,r15 across a function or procedure call but can use them inside a function or procedure.  Perhaps I'm goofing up because I am using class types.  Perhaps the reference to self (this) is in a register and I need to protect it? ---------------------------------------------------------------------- Leledumbo · 2014-07-19 08:46 AFAIK there's only 1 ABI for x86_64-linux, I'm not sure though about register use and order in parameters, but as been documented here, you can tell the compiler which registers to preserve. ---------------------------------------------------------------------- sean_vn · 2014-07-19 15:06 I thought I was getting illegal memory access exceptions.  I think what is happening is that numerical overflows involving floating point usage of the SSE registers are throwing an exception/interrupt rather than giving the expected NaN result.  I have to go and set something in a control register do I?  Me go look. ---------------------------------------------------------------------- sean_vn · 2014-07-19 16:05 implementation var modeData:LongWord=$9fc0;  {$ASMMODE Intel}  procedure setmode();assembler; asm   ldmxcsr modeData end; Mask all SSE F.P exceptions, flush to zero, denormals are zero ---------------------------------------------------------------------- Leledumbo · 2014-07-19 17:31 Quote from: sean_vn on July 19, 2014, 06:05:17 pmimplementation var modeData:LongWord=$9fc0;  {$ASMMODE Intel}  procedure setmode();assembler; asm   ldmxcsr modeData end; Mask all SSE F.P exceptions, flush to zero, denormals are zero Or the Pascal level API: http://www.freepascal.org/docs- html/rtl/math/setexceptionmask.html