AHCC calling conventions

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

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

Post Reply
simonsunnyboy
Moderator
Moderator
Posts: 5228
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

AHCC calling conventions

Post by simonsunnyboy »

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/

Stay cool, stay Atari!

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

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

Re: AHCC calling conventions

Post by Henk Robbers »

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

Post by Henk Robbers »

PS:

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

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

Re: AHCC calling conventions

Post by simonsunnyboy »

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

Stay cool, stay Atari!

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

Post Reply

Return to “C / PASCAL etc.”