[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] Inline assembler (was MiNTOS versions)



>
>> BTW: does anyone know if it is possible to declare an inline function in gcc?
>
>Inline functions are easy:
>
<snip>
>
>GCC would even inline test() without the 'inline' if you gave it the
>right compile options.
>
>> e.g. some compilers allow this:
>> 	void dummyfunc(void) = 0xA913;
>
>It seems you really want inline assembly (or machine code in the case of
>compilers that don't include an assembler).

Yes, I think that's what I meant... :)
>
>GCC has very advanced support for that, which means that it's not exactly
>very simple to use.
>
>> which makes a function that calls an a-trap, but my gcc (2.5.8) whines at this,
>> saying something like "function initialized like a variable."
>
>Well, standard C doesn't allow anything like that.
>Naturally, it would have been simple to allow it in GCC (and it even might
>be possible using some other syntax), but with nothing more than that you
>can't leave the optimizer on (GCC would have no idea about what registers
>might get modified) which is a very _bad_ thing.
>
>> It would be nice if someone knows how to do this, because this is what I need
>> to be able to call Mac functions from inside MacMiNT, which is necessary for
>> a few things...
>
>Aren't there some simple examples of this kind of thing in the standard
>GCC MiNT library headers? I would have thought that they called TOS via
>inline assembly.

Yes, there are, but I know next to nothing about 68k assembler
(looks like this is about to change... :).
In fact, the standard MacMiNT distribution includes a perl script for processing
Mac include files (with directly initialized inline assembly functions) into
standard include files and assembler source code. It was needed mainly because
all mac system calls have pascal calling conventions and gcc didn't understand
"pascal" (there is now a patch for this, which I have). I was hoping there might be a simpler way, and besides the script broke when the format of the include
files changed.

>
>If you don't find anything useful in there (and noone else can help), I'll
>look around at home and see what I can find. I have used GCC inline assembly
>once or twice before.
>
>Do you really have to have these things inlined, by the way?
>It's much easier to do it from an assembly function in a separate file.

Well, looks like I'm going to have to learn 68k assembler...
Any assembler tutorials on the web? I've looked, but couldn't find any..



Jonathan