Amiga.org
Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: Byakhee on March 21, 2012, 02:32:41 PM
-
Hello,
I'm developing with Storm C++ v4, and I need to add some functions in Asm.
There I have 2 questions:
Is possible to add sources in 68k assembly and call from c that assemblies as functions?
Or
Is possible add inline assembly in .c source and compile it?
What of this things is possible, and how.
Thanks,
-
Is possible to add sources in 68k assembly and call from c that assemblies as functions?
Yes.
You can use 'as' to compile assembly code, however the syntax isn't very comfortable with that. You can use whatever tools you like to build the assembly code, however, for example vasm (http://sun.hasenbraten.de/vasm/).
In the C function prototype you need to use special syntax to denote the registers. See http://gcc.gnu.org/onlinedocs/gcc/Local-Reg-Vars.html
Is possible add inline assembly in .c source and compile it?
Yes.
What of this things is possible, and how.
Read the gcc documentation about inline assembly:
http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
-
Thanks for your rapid answer, but my answer is about using Asm from StormC and you talk about using GNU.
-
Thanks for your rapid answer, but my answer is about using Asm from StormC and you talk about using GNU.
StormC ditched their rather sh*tty custom compiler for V4 and switched to GNU toolchain. StormC 4 == GNU + IDE.
-
StormC ditched their rather sh*tty custom compiler for V4 and switched to GNU toolchain. StormC 4 == GNU + IDE.
LOL, I feel your love of StormC 3! :-)
Version 3 of the compiler is still available in Storm. If you go to the project environment option under the settings menu, you can check which compiler you're currently using; either the gcc-based version or their custom compiler.
cheers
billy
-
LOL, I feel your love of StormC 3! :-)
Version 3 of the compiler is still available in Storm. If you go to the project environment option under the settings menu, you can check which compiler you're currently using; either the gcc-based version or their custom compiler.
cheers
billy
Yes, I'm ussing stormc v3, the version that I have.
But I found the method to include asm.
Adding files whit .s extension, and ussing the next format you can call functions from c.
machine 68000
section function_name,code
xdef _function_name
....
code
....
to call from c you need to do the next:
void function_name(register __d0 type, register __a0 type, ....)
It worked with compiler of stormc v3.
Thanks for your help.
-
Yes, I'm ussing stormc v3, the version that I have.
But I found the method to include asm.
Adding files whit .s extension, and ussing the next format you can call functions from c.
machine 68000
section function_name,code
xdef _function_name
....
code
....
to call from c you need to do the next:
void function_name(register __d0 type, register __a0 type, ....)
It worked with compiler of stormc v3.
Thanks for your help.
No worries. I would suggest that you write your code so that so that you can switch between compilers without needing to edit your source. If you have a header file that has something like:
#ifdef _DCC /* DICE */
#define REG(x) __ ## x
#define ASM
#define SAVEDS __geta4
#elif defined(__SASC) /* SAS/C */
#define REG(x) register __ ## x
#define ASM __asm
#define SAVEDS __saveds
#elif defined(__GNUC__) /* GCC */
#define REG(x) register __ ## x
#define ASM
#define SAVEDS
#elif defined(__STORM__)
#define REG(x) register __ ## x
#define ASM
#define SAVEDS __saveds
#endif
and then define your function as
SAVEDS ASM LONG DroppedFile (REG(a2) APTR object_p, REG(a1) struct AppMessage **msg_pp);
then you shouldn't need to worry about changing your compiler at any point.
cheers
billy
-
Yes, I'm ussing stormc v3, the version that I have.
Well okay fine. In the original post you however state:
I'm developing with Storm C++ v4
Regardless, I'm glad it got sorted out.
-
Sorry, is my mistake. My version is V3, not V4 as said in my original post.
Sorry...:shocked:
I'm considering to going to V4... thanks.