To access global variables in a PIC environment you need to get the value of the program counter. "call" puts the value on the stack and jumps to the label. You don't want to jump, just push the program counter, so you declare a label immedeately after the call instruction.

The "pop ebx" after it retrieves the pushed program counter from the stack again in ebx. So this code is correct. The reason why it didn't compile was case sensitivity of the ATT assembler reader, which Jonas did correct.

Jonas did disable it on Darwin as it apparently still did not work for him. It has to be the Darwin PIC code, allthough to the eye it seems correct to me.

This call and pop is old-style PIC and not good for new cpus because it breaks the call-stack. Please use the new style that calls a function (fpc_geteipasebx). This also generated by the compiler. See i386/cgcpu.pas and search for g_maybe_got_init.


Peter

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to