delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/12/21:20:51

Mime-Version: 1.0
To: john DOT kismul AT bergen DOT mail DOT telia DOT com, djgpp AT delorie DOT com
From: Nate Eldredge <nate AT cartsys DOT com>
Subject: Re: INLINE ASSEMBLY QUESTION
Date: Tue, 12 May 1998 18:14:39 -0700
Message-ID: <19980513011428.AAE27360@ppp118.cartsys.com>

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019