[Coco] Calling convention used by older 6809 C compilers

johnmarkmelanie at gmail.com johnmarkmelanie at gmail.com
Fri Jun 7 23:17:05 EDT 2024


Pierre,

I used the IIR C compiler, assembler, and linker for the Motorola 68HC16.

IIR renamed that if you want to write an assembly language program called by
a C program you should follow the following steps.

Steps:
1) Write a stub function.
  #ifdef stub
  Int add_stub(int a, int b)
  {
     Int results.
     results = a+b;
     return results;
  )
 #endif
2) compile and link the program.
3) view the assembly
4) Write the function in assembly following the stub example.


Also, you can hold temporary variables on the stack. Perhaps you can make
room on the stack to hold a return value.

-John Mark Mobley


-----Original Message-----
From: Coco <coco-bounces at maltedmedia.com> On Behalf Of Pierre Sarrazin via
Coco
Sent: Friday, June 7, 2024 9:27 PM
To: coco at maltedmedia.com
Cc: Pierre Sarrazin <sarrazip at sarrazip.com>
Subject: [Coco] Calling convention used by older 6809 C compilers

Hi. I'm in the process of adding a second calling convention to CMOC, a
C-like compiler that targets the 6809.

I have seen C programs for the 6809 that had some code written in assembly
that assumed a calling convention where the first parameter of a function is
received in register B or X, depending on its size, instead of on the stack,
as in CMOC's default convention.

platotermCoCo is such a program:
https://github.com/beretta42/platotermCoCo/tree/master/src/coco2

I'm looking for a detailed description of that calling convention, with the
goal of clarifying a few questions that I have on corner cases.

1. Is the first parameter still passed in B or X when the parameter is
   a 1- or 2-byte struct or union?

2. When the return value is one or two bytes, which register is it
   returned in?

3. When the function must return a struct, a union, a long, a float
   or a double, does it receive a hidden first parameter that points
   to the location to be filled with the return value?
   If so, is that hidden parameter received in X?
   What if the return type is a 1- or 2-byte struct or union?

Thanks for any leads...

The CMOC home page: http://sarrazip.com/dev/cmoc.html

--
Pierre Sarrazin <sarrazip @ sarrazip . com>

--
Coco mailing list
Coco at maltedmedia.com
https://pairlist5.pair.net/mailman/listinfo/coco



More information about the Coco mailing list