YaK:: GCC 6809 calling convention [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
[mega_changes]
[photos]

GCC 6809 calling convention

This uses the default one (there are other options).

     1	#include <stdarg.h>
     2
     3	typedef unsigned char byte;
     4
     5	int addi(int a, int b) {
     6		return a+b;
     7	}
     8
     9	byte addb(byte a, byte b) {
    10		return a+b;
    11	}
    12
    13	long addl(long a, long b) {
    14		return a+b;
    15	}
    16
    17	struct two {
    18		byte x, y;
    19	};
    20
    21	struct three {
    22		byte x, y;
    23	};
    24
    25	struct two add2(struct two a, struct two b) {
    26		struct two z = { a.x + b.x, a.y + b.y };
    27		return z;
    28	}
    29	struct three add3(struct three a, struct three b) {
    30		struct three z = { a.x + b.x, a.y + b.y };
    31		return z;
    32	}
    33
    34	int scribblef(const char* format, va_list ap) {
    35
    36		int x = va_arg(ap, int);
    37		int y = va_arg(ap, int);
    38		int z = va_arg(ap, int);
    39
    40		return (int)format + ((x ^ y) | z);
    41	}

     1
     2	;;; gcc for m6809 : Dec 25 2023 18:10:03
     3	;;; 4.6.4 (gcc6809lw pl9)
     4	;;; ABI version 1
     5	;;; -mint16
     6		.module	calling.c
     7
     8		.area	.text
     9
    10		.globl	_addi
    11	_addi:
    12		pshs	u
    13		leau	,s
    14		tfr	x,d
    15		addd	4,u
    16		tfr	d,x
    17		puls	u,pc
    18
    19		.globl	_addb
    20	_addb:
    21		pshs	u
    22		leau	,s
    23		addb	4,u
    24		puls	u,pc
    25
    26		.globl	_addl
    27	_addl:
    28		pshs	y,u
    29		leas	-8,s
    30		leau	,s
    31		ldy	14,u
    32		sty	4,u
    33		ldd	16,u
    34		std	6,u
    35		ldy	18,u
    36		sty	,u
    37		ldd	20,u
    38		std	2,u
    39		ldd	6,u
    40		addd	2,u
    41		std	2,x
    42		ldd	4,u
    43		adcb	1,u
    44		adca	,u
    45		std	,x
    46		leas	8,s
    47		puls	y,u,pc
    48
    49		.globl	_add2
    50	_add2:
    51		pshs	y,u
    52		leas	-4,s
    53		leau	,s
    54		ldy	10,u
    55		ldd	12,u
    56		stb	3,u	;movlsbqihi: R:d -> 3,u
    57		tfr	y,d	;movlsbqihi: R:y -> R:b
    58		stb	2,u
    59		ldd	12,u
    60		tfr	a,b
    61		clra		;zero_extendqihi: R:b -> R:d
    62		stb	1,u
    63		tfr	y,d
    64		tfr	a,b
    65		clra		;zero_extendqihi: R:b -> R:d
    66		addb	1,u
    67		stb	,x
    68		ldb	3,u
    69		addb	2,u
    70		stb	1,x
    71		leas	4,s
    72		puls	y,u,pc
    73
    74		.globl	_add3
    75	_add3:
    76		pshs	y,u
    77		leas	-4,s
    78		leau	,s
    79		ldy	10,u
    80		ldd	12,u
    81		stb	3,u	;movlsbqihi: R:d -> 3,u
    82		tfr	y,d	;movlsbqihi: R:y -> R:b
    83		stb	2,u
    84		ldd	12,u
    85		tfr	a,b
    86		clra		;zero_extendqihi: R:b -> R:d
    87		stb	1,u
    88		tfr	y,d
    89		tfr	a,b
    90		clra		;zero_extendqihi: R:b -> R:d
    91		addb	1,u
    92		stb	,x
    93		ldb	3,u
    94		addb	2,u
    95		stb	1,x
    96		leas	4,s
    97		puls	y,u,pc
    98
    99		.globl	_scribblef
   100	_scribblef:
   101		pshs	y,u
   102		leau	,s
   103		ldy	6,u
   104		ldd	2,y
   105		eora	,y
   106		eorb	1,y
   107		ora	4,y
   108		orb	5,y
   109		leax	d,x
   110		puls	y,u,pc
(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2024-06-08)       [Login]
(No back references.)