Welcome, Guest. Please login or register.

Author Topic: Storm C Asm 68k  (Read 3116 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline ByakheeTopic starter

  • Newbie
  • *
  • Join Date: Mar 2012
  • Posts: 4
    • Show only replies by Byakhee
Storm C Asm 68k
« 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,
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Storm C Asm 68k
« Reply #1 on: March 21, 2012, 03:55:03 PM »
Quote from: Byakhee;684629
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.

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

Quote
Is possible add inline assembly in .c source and compile it?
Yes.

Quote
What of this things is possible, and how.
Read the gcc documentation about inline assembly:
http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
 

Offline ByakheeTopic starter

  • Newbie
  • *
  • Join Date: Mar 2012
  • Posts: 4
    • Show only replies by Byakhee
Re: Storm C Asm 68k
« Reply #2 on: March 22, 2012, 12:22:58 PM »
Thanks for your rapid answer, but my answer is about using Asm from StormC and you talk about using GNU.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Storm C Asm 68k
« Reply #3 on: March 22, 2012, 12:32:46 PM »
Quote from: Byakhee;684762
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.
 

Offline billyfish

  • Jr. Member
  • **
  • Join Date: Oct 2005
  • Posts: 51
    • Show only replies by billyfish
Re: Storm C Asm 68k
« Reply #4 on: March 22, 2012, 01:34:08 PM »
Quote from: Piru;684766
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
 

Offline ByakheeTopic starter

  • Newbie
  • *
  • Join Date: Mar 2012
  • Posts: 4
    • Show only replies by Byakhee
Re: Storm C Asm 68k
« Reply #5 on: March 23, 2012, 02:07:16 PM »
Quote from: billyfish;684770
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.

Code: [Select]

machine 68000

section function_name,code

xdef _function_name


....

code

....


to call from c you need to do the next:

Code: [Select]

void function_name(register __d0 type, register __a0 type, ....)


It worked with compiler of stormc v3.

Thanks for your help.
 

Offline billyfish

  • Jr. Member
  • **
  • Join Date: Oct 2005
  • Posts: 51
    • Show only replies by billyfish
Re: Storm C Asm 68k
« Reply #6 on: March 23, 2012, 03:34:30 PM »
Quote from: Byakhee;684911
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.

Code: [Select]

machine 68000

section function_name,code

xdef _function_name


....

code

....


to call from c you need to do the next:

Code: [Select]

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:

Code: [Select]

#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

Code: [Select]

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
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Storm C Asm 68k
« Reply #7 on: March 23, 2012, 04:26:08 PM »
Quote from: Byakhee;684911
Yes, I'm ussing stormc v3, the version that I have.
Well okay fine. In the original post you however state:
Quote
I'm developing with Storm C++ v4

Regardless, I'm glad it got sorted out.
 

Offline ByakheeTopic starter

  • Newbie
  • *
  • Join Date: Mar 2012
  • Posts: 4
    • Show only replies by Byakhee
Re: Storm C Asm 68k
« Reply #8 on: March 23, 2012, 04:34:03 PM »
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.