AHCC calling conventions

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4873
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

AHCC calling conventions

Postby simonsunnyboy » Wed Aug 01, 2012 3:41 pm

Hello,

I'm using AHCC for quite a while and I'm playing it safe for machine code routines, always backuping all registers in use.

Are there registers that are meant to be preserved by default? E.q. if d1 is passed, d1 should have the same content after the rts? Or is it allowed to be trashed?
I long for gaining a bit of optimizations ;)

cheers,
ssb
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

Henk Robbers
AHCC Developer
AHCC Developer
Posts: 39
Joined: Mon Nov 14, 2011 2:37 pm

Re: AHCC calling conventions

Postby Henk Robbers » Fri Aug 03, 2012 9:04 pm

D0,D1,D2, A0,A1 are scratch registers in C functions and are supposed to be destroyed.

All other registers are saved and restored if used by C functions.

When you call a assembler function from C, you must do the same in the asm function.
ie: save and restore registers > D2 or > A1 if used by the function.

Henk Robbers
AHCC Developer
AHCC Developer
Posts: 39
Joined: Mon Nov 14, 2011 2:37 pm

Re: AHCC calling conventions

Postby Henk Robbers » Fri Aug 03, 2012 9:07 pm

PS:

Parameters passed to C functions in D0,D1,D2, A0 or A1 are not preserved after the call.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4873
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: AHCC calling conventions

Postby simonsunnyboy » Sat Aug 04, 2012 9:16 am

Thanks, this assertion is very useful! I can now optimize a lot of unnecessary register backups away :)
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 1 guest