English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language

 
 
Thread Tools
Old 11 January 2020, 19:05   #1
sparhawk
Registered User

sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 51
Posts: 243
Calling convention for gcc (m68k-amigaos)

When I call an assembler function, d0/d1 and a0/a1 don't need to be saved?


The first four params are passed in d0/d1 and a0/a1, or does this depend on wether it's a pointer or value?


Is there some compiler hint to tell the compiler which registers a param might be expected in?
sparhawk is offline  
Old 11 January 2020, 19:13   #2
Samurai_Crow
Total Chaos forever!

Samurai_Crow's Avatar
 
Join Date: Aug 2007
Location: Ft. Collins, CO USA
Age: 45
Posts: 1,336
Send a message via Yahoo to Samurai_Crow
Quote:
Originally Posted by sparhawk View Post
When I call an assembler function, d0/d1 and a0/a1 don't need to be saved?


The first four params are passed in d0/d1 and a0/a1, or does this depend on wether it's a pointer or value?


Is there some compiler hint to tell the compiler which registers a param might be expected in?
D0/D1/A0/A1 are scratch registers so yes. All other registers need to be preserved.

Whether it's a pointer or not matters.

Yes, GCC has register directives for passing parameters in to subroutines and especially inline Assembly.
Samurai_Crow is offline  
Old 11 January 2020, 19:13   #3
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 48
Posts: 3,528
With gcc, the params are passed on stack if you don't specify anything (that's empiric, it worked for a quick test I did).

Bebbo gcc 6 supports SDI_compiler include. You can specify "passing by register" and which register. Return value is always taken from D0 (here the return type is void so it doesn't matter)

Code:
#ifndef SDI_COMPILER_H
#include <SDI_compiler.h>
#endif


  void ASM mt_install_cia(REG(a6, void *custom),
			  REG(a0, void *VectorBase), REG(d0, UBYTE PALflag));
I suggest that you preserve ALL registers when calling asm. Compiler may use some.
jotd is offline  
Old 11 January 2020, 19:36   #4
sparhawk
Registered User

sparhawk's Avatar
 
Join Date: Sep 2019
Location: Essen/Germany
Age: 51
Posts: 243
Thanks! When I use that REG() notation, do I still need to preserve the register, or does the compiler know in this case that it can get scratched?
It's still faster if I don't have to translate the registers, so it still makes sense to use this anyway.
Which include is this defined in? I'm using the 1.3 includes, is this also supported there because I can't find any traces of this (also not in the OS 2.x+ includes).
sparhawk is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
m68k-amigaos-gdb bebbo Coders. C/C++ 69 06 February 2020 20:45
Motorola m68k support saved from being removed In GCC 11 nogginthenog Coders. General 4 28 November 2019 20:29
trying to make m68k-amigaos-gdb on windows jotd Coders. C/C++ 8 17 November 2019 15:17
m68k-amigaos-ld.exe bug ? FrenchShark Coders. General 2 30 November 2009 10:54
Shorten ported to AmigaOS m68k and WarpOS Paul News 0 20 August 2006 13:05

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:54.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.06584 seconds with 15 queries