OpenAmiga (248/964)

From:Patrick Roberts
Date:10 Sep 2000 at 20:25:29
Subject:Re: AMIOPEN: C Inline VP

Thanks yet again Rudi :)

You don't happen to know if there is a pragma (is that the right term) to turn
off optimizations around blocks of code by any chance? (The optimizer seems to
break a lot of bit-wise code)

Thanks,
Pat

BTW- I'll put this info on the Faq-O-Matic.

Rudi Chiarito wrote:
>
> On Sun, Sep 10, 2000 at 03:55:23AM -0700, artix wrote:
> > I think this has been asked before but I don't remember the answer.
> > Is there a way to include inline VP code in a C program? (like asm()
> > under X86 gcc)
>
> I knew somebody had to ask it, sooner or later! ;)
>
> I did it this way (old, incomplete code):
>
> void *pointer_to_gc_mark = &gc_mark;
>
> __asm__ __volatile__
> (
> /*
> WARNING: funky code ahead!
> \t and \n are needed to make the final output easier to read
> while debugging. Hopefully you'll never have to bother with all
> of this.
> */
>
> "\tsync\n" // spill all the registers
> "\tsyncreg\n" // to the stack
>
> "\tcpy.p %0,p1\n" // pointer to gc_mark
>
> [...]
>
> "\tret\n"
>
> : // no output
> : "a" (pointer_to_gc_mark)
> : "p0", "p1", "p2", "i0"
>
> );
>
> In the example above, variable pointer_to_gc_mark is accessed as %0 in
> the assembly source.
>
> The help page file:/usr/doc/intent/lang/cc/doc/internal.html has a
> section covering inline assembly code. I strongly suggest you also take a
> look at gcc's documentation (the info manual, not the man pages, section
> "C Extensions::Extended Asm") to learn more about helping the compiler
> generate better code, with the use of constraints. Last but not least,
> there's an excellent tutorial, which discusses x86 code, but is
> nevertheless extremely helpful:
>
> http://boudicca.tux.org/hypermail/linux-kernel/1998/1998week17/0377.html
>
> (the name of the author, Colin Plumb, might be familiar to some, as he's
> an ex Amiga programmer).
>
> --
> "Without deviation from the norm, progress is not possible." (F. Zappa)
> Rudi Chiarito SGML/XML, user interface, i18n Amiga Inc.
> rudi@amiga.com http://amiga.com/
> Subscribe/Unsubscribe: open-request@amiga.com
> Amiga FAQ: http://www.amiga.com/faq.html
Subscribe/Unsubscribe: open-request@amiga.com
Amiga FAQ: http://www.amiga.com/faq.html