Mail Archives: djgpp/1998/05/12/21:20:51
At 08:02 5/12/1998 +0200, John Kismul wrote:
>When doing inline assembly in DJGPP, how do I 'return'
>
>Doing something like this....
>
>__asm__("
>(ASM code here)
>
>ret\n
>
>");
>
>only results in a crash
In general, you'd better not. The compiler inserts an "epilogue" at the end
of a function, and what it contains can differ depending on the compile
options. A better solution is to jump to the end of the `asm' statement
(being sure to use a local label).
If you are writing an entire function in assembly, however (like with an
asm(...) outside any function), it's just a matter of restoring the stack to
its position upon entry, and executing a `ret'. For example, a no-op
function would just be the single instruction `ret'.
Nate Eldredge
nate AT cartsys DOT com
- Raw text -