Artifact 48dd74b299f5f2959a2f6d96507268756956db7e:


0000: 23 69 66 6e 64 65 66 20 5f 61 76 63 61 6c 6c 5f  #ifndef _avcall_
0010: 6d 36 38 6b 5f 61 6d 69 67 61 5f 63 09 09 09 09  m68k_amiga_c....
0020: 2f 2a 2d 2a 2d 20 43 20 2d 2a 2d 2a 2f 0a 23 64  /*-*- C -*-*/.#d
0030: 65 66 69 6e 65 20 5f 61 76 63 61 6c 6c 5f 6d 36  efine _avcall_m6
0040: 38 6b 5f 61 6d 69 67 61 5f 63 0a 2f 2a 2a 0a 20  8k_amiga_c./**. 
0050: 20 43 6f 70 79 72 69 67 68 74 20 31 39 39 33 20   Copyright 1993 
0060: 42 69 6c 6c 20 54 72 69 67 67 73 2c 20 3c 42 69  Bill Triggs, <Bi
0070: 6c 6c 2e 54 72 69 67 67 73 40 69 6e 72 69 61 6c  ll.Triggs@inrial
0080: 70 65 73 2e 66 72 3e 0a 20 20 43 6f 70 79 72 69  pes.fr>.  Copyri
0090: 67 68 74 20 31 39 39 35 2d 31 39 39 39 20 42 72  ght 1995-1999 Br
00a0: 75 6e 6f 20 48 61 69 62 6c 65 2c 20 3c 62 72 75  uno Haible, <bru
00b0: 6e 6f 40 63 6c 69 73 70 2e 6f 72 67 3e 0a 20 20  no@clisp.org>.  
00c0: 43 6f 70 79 72 69 67 68 74 20 31 39 39 37 20 4a  Copyright 1997 J
00d0: c3 b6 72 67 20 48 c3 b6 68 6c 65 2c 20 3c 4a 6f  örg Höhle, <Jo
00e0: 65 72 67 2e 48 6f 65 68 6c 65 40 67 6d 64 2e 64  erg.Hoehle@gmd.d
00f0: 65 3e 0a 0a 20 20 54 68 69 73 20 69 73 20 66 72  e>..  This is fr
0100: 65 65 20 73 6f 66 74 77 61 72 65 20 64 69 73 74  ee software dist
0110: 72 69 62 75 74 65 64 20 75 6e 64 65 72 20 74 68  ributed under th
0120: 65 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75  e GNU General Pu
0130: 62 6c 69 63 0a 20 20 4c 69 63 65 6e 63 65 20 64  blic.  Licence d
0140: 65 73 63 72 69 62 65 64 20 69 6e 20 74 68 65 20  escribed in the 
0150: 66 69 6c 65 20 43 4f 50 59 49 4e 47 2e 20 43 6f  file COPYING. Co
0160: 6e 74 61 63 74 20 74 68 65 20 61 75 74 68 6f 72  ntact the author
0170: 20 69 66 0a 20 20 79 6f 75 20 64 6f 6e 27 74 20   if.  you don't 
0180: 68 61 76 65 20 74 68 69 73 20 6f 72 20 63 61 6e  have this or can
0190: 27 74 20 6c 69 76 65 20 77 69 74 68 20 69 74 2e  't live with it.
01a0: 20 54 68 65 72 65 20 69 73 20 41 42 53 4f 4c 55   There is ABSOLU
01b0: 54 45 4c 59 0a 20 20 4e 4f 20 57 41 52 52 41 4e  TELY.  NO WARRAN
01c0: 54 59 2c 20 65 78 70 6c 69 63 69 74 20 6f 72 20  TY, explicit or 
01d0: 69 6d 70 6c 69 65 64 2c 20 6f 6e 20 74 68 69 73  implied, on this
01e0: 20 73 6f 66 74 77 61 72 65 2e 0a 2a 2a 2f 0a 2f   software..**/./
01f0: 2a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  *---------------
0200: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0210: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0220: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0230: 2d 2d 2d 2d 2d 2d 2d 0a 20 20 21 21 21 20 54 48  -------.  !!! TH
0240: 49 53 20 52 4f 55 54 49 4e 45 20 4d 55 53 54 20  IS ROUTINE MUST 
0250: 42 45 20 43 4f 4d 50 49 4c 45 44 20 67 63 63 20  BE COMPILED gcc 
0260: 2d 4f 20 21 21 21 0a 0a 20 20 46 6f 72 65 69 67  -O !!!..  Foreig
0270: 6e 20 66 75 6e 63 74 69 6f 6e 20 69 6e 74 65 72  n function inter
0280: 66 61 63 65 20 66 6f 72 20 61 20 6d 36 38 6b 20  face for a m68k 
0290: 41 6d 69 67 61 20 77 69 74 68 20 67 63 63 2e 0a  Amiga with gcc..
02a0: 0a 20 20 54 68 69 73 20 63 61 6c 6c 73 20 61 20  .  This calls a 
02b0: 43 20 66 75 6e 63 74 69 6f 6e 20 77 69 74 68 20  C function with 
02c0: 61 6e 20 61 72 67 75 6d 65 6e 74 20 6c 69 73 74  an argument list
02d0: 20 62 75 69 6c 74 20 75 70 20 75 73 69 6e 67 20   built up using 
02e0: 6d 61 63 72 6f 73 0a 20 20 64 65 66 69 6e 65 64  macros.  defined
02f0: 20 69 6e 20 61 76 5f 63 61 6c 6c 2e 68 2e 0a 0a   in av_call.h...
0300: 20 20 4d 36 38 6b 20 41 72 67 75 6d 65 6e 74 20    M68k Argument 
0310: 50 61 73 73 69 6e 67 20 43 6f 6e 76 65 6e 74 69  Passing Conventi
0320: 6f 6e 73 3a 0a 0a 20 20 41 6c 6c 20 61 72 67 75  ons:..  All argu
0330: 6d 65 6e 74 73 20 61 72 65 20 70 61 73 73 65 64  ments are passed
0340: 20 6f 6e 20 74 68 65 20 73 74 61 63 6b 20 77 69   on the stack wi
0350: 74 68 20 77 6f 72 64 20 61 6c 69 67 6e 6d 65 6e  th word alignmen
0360: 74 2e 20 44 6f 75 62 6c 65 73 20 74 61 6b 65 0a  t. Doubles take.
0370: 20 20 74 77 6f 20 77 6f 72 64 73 2e 20 53 74 72    two words. Str
0380: 75 63 74 75 72 65 20 61 72 67 73 20 61 72 65 20  ucture args are 
0390: 70 61 73 73 65 64 20 61 73 20 74 72 75 65 20 73  passed as true s
03a0: 74 72 75 63 74 75 72 65 73 20 65 6d 62 65 64 64  tructures embedd
03b0: 65 64 20 69 6e 20 74 68 65 0a 20 20 61 72 67 75  ed in the.  argu
03c0: 6d 65 6e 74 20 73 74 61 63 6b 2e 20 54 6f 20 72  ment stack. To r
03d0: 65 74 75 72 6e 20 61 20 73 74 72 75 63 74 75 72  eturn a structur
03e0: 65 2c 20 74 68 65 20 63 61 6c 6c 65 64 20 66 75  e, the called fu
03f0: 6e 63 74 69 6f 6e 20 63 6f 70 69 65 73 20 74 68  nction copies th
0400: 65 0a 20 20 72 65 74 75 72 6e 20 76 61 6c 75 65  e.  return value
0410: 20 74 6f 20 74 68 65 20 61 64 64 72 65 73 73 20   to the address 
0420: 73 75 70 70 6c 69 65 64 20 69 6e 20 72 65 67 69  supplied in regi
0430: 73 74 65 72 20 22 61 31 22 2e 20 47 63 63 20 77  ster "a1". Gcc w
0440: 69 74 68 6f 75 74 0a 20 20 2d 66 70 63 63 2d 73  ithout.  -fpcc-s
0450: 74 72 75 63 74 2d 72 65 74 75 72 6e 20 72 65 74  truct-return ret
0460: 75 72 6e 73 20 3c 3d 20 34 20 62 79 74 65 20 73  urns <= 4 byte s
0470: 74 72 75 63 74 75 72 65 73 20 61 73 20 69 6e 74  tructures as int
0480: 65 67 65 72 73 2e 0a 0a 20 20 53 6f 6d 65 20 73  egers...  Some s
0490: 70 65 63 69 66 69 63 20 61 72 67 75 6d 65 6e 74  pecific argument
04a0: 73 20 6d 61 79 20 62 65 20 70 61 73 73 65 64 20  s may be passed 
04b0: 69 6e 20 72 65 67 69 73 74 65 72 73 2e 0a 0a 20  in registers... 
04c0: 20 43 6f 6d 70 69 6c 65 20 74 68 69 73 20 72 6f   Compile this ro
04d0: 75 74 69 6e 65 20 77 69 74 68 20 67 63 63 20 2d  utine with gcc -
04e0: 4f 20 28 6f 72 20 2d 4f 32 20 6f 72 20 2d 67 20  O (or -O2 or -g 
04f0: 2d 4f 29 20 74 6f 20 67 65 74 20 74 68 65 20 72  -O) to get the r
0500: 69 67 68 74 0a 20 20 72 65 67 69 73 74 65 72 20  ight.  register 
0510: 76 61 72 69 61 62 6c 65 73 2c 20 6f 72 20 75 73  variables, or us
0520: 65 20 74 68 65 20 61 73 73 65 6d 62 6c 65 72 20  e the assembler 
0530: 76 65 72 73 69 6f 6e 2e 0a 20 20 2d 2d 2d 2d 2d  version..  -----
0540: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0550: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0560: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0570: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d  ----------------
0580: 2d 2a 2f 0a 23 69 6e 63 6c 75 64 65 20 22 61 76  -*/.#include "av
0590: 63 61 6c 6c 2e 68 2e 69 6e 22 0a 0a 23 64 65 66  call.h.in"..#def
05a0: 69 6e 65 20 52 45 54 55 52 4e 28 54 59 50 45 2c  ine RETURN(TYPE,
05b0: 56 41 4c 29 09 28 2a 28 54 59 50 45 2a 29 6c 2d  VAL).(*(TYPE*)l-
05c0: 3e 72 61 64 64 72 20 3d 20 28 54 59 50 45 29 28  >raddr = (TYPE)(
05d0: 56 41 4c 29 29 0a 0a 69 6e 74 0a 5f 5f 62 75 69  VAL))..int.__bui
05e0: 6c 74 69 6e 5f 61 76 63 61 6c 6c 28 61 76 5f 61  ltin_avcall(av_a
05f0: 6c 69 73 74 2a 20 6c 29 0a 7b 0a 20 20 72 65 67  list* l).{.  reg
0600: 69 73 74 65 72 20 5f 5f 61 76 77 6f 72 64 2a 09  ister __avword*.
0610: 73 70 09 5f 5f 61 73 6d 5f 5f 28 22 73 70 22 29  sp.__asm__("sp")
0620: 3b 20 20 2f 2a 20 43 20 6e 61 6d 65 73 20 66 6f  ;  /* C names fo
0630: 72 20 72 65 67 69 73 74 65 72 73 20 2a 2f 0a 20  r registers */. 
0640: 20 72 65 67 69 73 74 65 72 20 5f 5f 61 76 77 6f   register __avwo
0650: 72 64 2a 09 73 72 65 74 09 5f 5f 61 73 6d 5f 5f  rd*.sret.__asm__
0660: 28 22 61 31 22 29 3b 09 2f 2a 20 73 74 72 75 63  ("a1");./* struc
0670: 74 75 72 65 20 72 65 74 75 72 6e 20 70 6f 69 6e  ture return poin
0680: 74 65 72 20 2a 2f 0a 20 20 72 65 67 69 73 74 65  ter */.  registe
0690: 72 20 5f 5f 61 76 77 6f 72 64 09 69 72 65 74 09  r __avword.iret.
06a0: 5f 5f 61 73 6d 5f 5f 28 22 64 30 22 29 3b 0a 20  __asm__("d0");. 
06b0: 20 72 65 67 69 73 74 65 72 20 5f 5f 61 76 77 6f   register __avwo
06c0: 72 64 09 69 72 65 74 32 09 5f 5f 61 73 6d 5f 5f  rd.iret2.__asm__
06d0: 28 22 64 31 22 29 3b 0a 20 20 72 65 67 69 73 74  ("d1");.  regist
06e0: 65 72 20 66 6c 6f 61 74 09 66 72 65 74 09 5f 5f  er float.fret.__
06f0: 61 73 6d 5f 5f 28 22 64 30 22 29 3b 09 2f 2a 20  asm__("d0");./* 
0700: 64 30 20 2a 2f 0a 20 20 72 65 67 69 73 74 65 72  d0 */.  register
0710: 20 64 6f 75 62 6c 65 09 64 72 65 74 09 5f 5f 61   double.dret.__a
0720: 73 6d 5f 5f 28 22 64 30 22 29 3b 09 2f 2a 20 64  sm__("d0");./* d
0730: 30 2c 64 31 20 2a 2f 0a 0a 20 20 23 64 65 66 69  0,d1 */..  #defi
0740: 6e 65 20 5f 5f 4e 55 4d 5f 53 41 56 45 44 5f 52  ne __NUM_SAVED_R
0750: 45 47 53 09 28 36 2b 37 29 09 2f 2a 20 73 61 76  EGS.(6+7)./* sav
0760: 65 20 64 32 2d 64 37 2f 61 30 2d 61 36 20 2a 2f  e d2-d7/a0-a6 */
0770: 0a 20 20 23 64 65 66 69 6e 65 20 5f 5f 53 41 56  .  #define __SAV
0780: 45 44 5f 52 45 47 53 09 09 30 78 37 66 66 63 09  ED_REGS..0x7ffc.
0790: 2f 2a 20 6d 6f 76 65 6d 6c 20 6d 61 73 6b 20 66  /* moveml mask f
07a0: 6f 72 20 64 32 2d 64 37 2f 61 30 2d 61 36 20 2a  or d2-d7/a0-a6 *
07b0: 2f 0a 20 20 2f 2a 20 73 70 61 63 65 20 66 6f 72  /.  /* space for
07c0: 20 63 61 6c 6c 65 65 27 73 20 73 74 61 63 6b 20   callee's stack 
07d0: 66 72 61 6d 65 20 61 6e 64 20 74 65 6d 70 20 73  frame and temp s
07e0: 70 61 63 65 20 66 6f 72 20 73 61 76 69 6e 67 20  pace for saving 
07f0: 72 65 67 69 73 74 65 72 73 20 2a 2f 0a 20 20 73  registers */.  s
0800: 70 20 2d 3d 20 5f 5f 41 56 5f 41 4c 49 53 54 5f  p -= __AV_ALIST_
0810: 57 4f 52 44 53 20 2b 20 5f 5f 4e 55 4d 5f 53 41  WORDS + __NUM_SA
0820: 56 45 44 5f 52 45 47 53 3b 0a 20 20 23 64 65 66  VED_REGS;.  #def
0830: 69 6e 65 20 72 65 67 73 70 61 63 65 20 28 73 70  ine regspace (sp
0840: 2b 5f 5f 41 56 5f 41 4c 49 53 54 5f 57 4f 52 44  +__AV_ALIST_WORD
0850: 53 29 20 2f 2a 20 74 65 6d 70 20 73 70 61 63 65  S) /* temp space
0860: 20 66 6f 72 20 73 61 76 69 6e 67 20 72 65 67 69   for saving regi
0870: 73 74 65 72 73 20 2a 2f 0a 0a 20 20 7b 0a 20 20  sters */..  {.  
0880: 20 20 5f 5f 61 76 77 6f 72 64 2a 20 61 72 67 66    __avword* argf
0890: 72 61 6d 65 20 3d 20 73 70 3b 09 09 2f 2a 20 73  rame = sp;../* s
08a0: 74 61 63 6b 20 6f 66 66 73 65 74 20 66 6f 72 20  tack offset for 
08b0: 61 72 67 75 6d 65 6e 74 20 6c 69 73 74 20 2a 2f  argument list */
08c0: 0a 20 20 20 20 69 6e 74 20 61 72 67 6c 65 6e 20  .    int arglen 
08d0: 3d 20 6c 2d 3e 61 70 74 72 20 2d 20 6c 2d 3e 61  = l->aptr - l->a
08e0: 72 67 73 3b 0a 20 20 20 20 69 6e 74 20 69 3b 0a  rgs;.    int i;.
08f0: 0a 20 20 20 20 66 6f 72 20 28 69 20 3d 20 30 3b  .    for (i = 0;
0900: 20 69 20 3c 20 61 72 67 6c 65 6e 3b 20 69 2b 2b   i < arglen; i++
0910: 29 09 2f 2a 20 70 75 73 68 20 66 75 6e 63 74 69  )./* push functi
0920: 6f 6e 20 61 72 67 73 20 6f 6e 74 6f 20 73 74 61  on args onto sta
0930: 63 6b 20 2a 2f 0a 20 20 20 20 20 20 61 72 67 66  ck */.      argf
0940: 72 61 6d 65 5b 69 5d 20 3d 20 6c 2d 3e 61 72 67  rame[i] = l->arg
0950: 73 5b 69 5d 3b 0a 20 20 7d 0a 0a 20 20 69 66 20  s[i];.  }..  if 
0960: 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41  (l->rtype == __A
0970: 56 73 74 72 75 63 74 29 09 09 2f 2a 20 70 75 74  Vstruct)../* put
0980: 20 73 74 72 75 63 74 20 72 65 74 75 72 6e 20 61   struct return a
0990: 64 64 72 65 73 73 20 69 6e 74 6f 20 61 31 20 2a  ddress into a1 *
09a0: 2f 0a 20 20 20 20 6c 2d 3e 72 65 67 61 72 67 73  /.    l->regargs
09b0: 5b 38 2b 31 5d 20 3d 20 28 5f 5f 61 76 77 6f 72  [8+1] = (__avwor
09c0: 64 29 28 6c 2d 3e 72 61 64 64 72 29 3b 0a 0a 20  d)(l->raddr);.. 
09d0: 20 2f 2a 20 53 61 76 65 20 6d 6f 73 74 20 72 65   /* Save most re
09e0: 67 69 73 74 65 72 73 20 62 79 20 68 61 6e 64 2e  gisters by hand.
09f0: 20 54 68 65 72 65 20 69 73 20 6e 6f 20 77 61 79   There is no way
0a00: 20 74 6f 20 70 65 72 73 75 61 64 65 20 67 63 63   to persuade gcc
0a10: 20 74 68 61 74 0a 20 20 20 2a 20 74 68 65 79 20   that.   * they 
0a20: 61 72 65 20 63 6c 6f 62 62 65 72 65 64 2c 20 6e  are clobbered, n
0a30: 6f 20 6d 61 74 74 65 72 20 68 6f 77 20 6c 61 72  o matter how lar
0a40: 67 65 20 77 65 20 6d 61 6b 65 20 74 68 65 20 63  ge we make the c
0a50: 6c 6f 62 62 65 72 20 6c 69 73 74 20 6f 66 0a 20  lobber list of. 
0a60: 20 20 2a 20 6f 66 20 74 68 65 20 61 73 6d 20 73    * of the asm s
0a70: 74 61 74 65 6d 65 6e 74 73 2e 0a 20 20 20 2a 2f  tatements..   */
0a80: 0a 20 20 5f 5f 61 73 6d 5f 5f 28 22 6d 6f 76 65  .  __asm__("move
0a90: 6d 6c 20 25 31 2c 25 30 22 20 2f 2a 20 25 31 20  ml %1,%0" /* %1 
0aa0: 3d 3d 20 23 30 78 37 66 66 63 20 3d 3d 20 64 32  == #0x7ffc == d2
0ab0: 2d 64 37 2f 61 30 2d 61 36 20 2a 2f 0a 20 20 20  -d7/a0-a6 */.   
0ac0: 20 20 20 20 20 20 20 3a 20 22 3d 6d 22 20 28 72         : "=m" (r
0ad0: 65 67 73 70 61 63 65 5b 30 5d 29 20 3a 20 22 6e  egspace[0]) : "n
0ae0: 22 20 28 5f 5f 53 41 56 45 44 5f 52 45 47 53 29  " (__SAVED_REGS)
0af0: 29 3b 0a 0a 20 20 5f 5f 61 73 6d 5f 5f 28 22 6d  );..  __asm__("m
0b00: 6f 76 65 6c 20 25 30 2c 73 70 40 2d 22 20 3a 20  ovel %0,sp@-" : 
0b10: 3a 20 22 67 22 20 28 26 26 72 65 74 75 72 6e 5f  : "g" (&&return_
0b20: 68 65 72 65 29 29 3b 20 2f 2a 20 70 72 65 70 61  here)); /* prepa
0b30: 72 65 20 66 75 6e 63 74 69 6f 6e 20 63 61 6c 6c  re function call
0b40: 20 2a 2f 0a 20 20 5f 5f 61 73 6d 5f 5f 28 22 6d   */.  __asm__("m
0b50: 6f 76 65 6c 20 25 30 2c 73 70 40 2d 22 20 3a 20  ovel %0,sp@-" : 
0b60: 3a 20 22 67 22 20 28 6c 2d 3e 66 75 6e 63 29 29  : "g" (l->func))
0b70: 3b 0a 0a 09 09 09 09 09 2f 2a 20 70 75 74 20 73  ;......./* put s
0b80: 6f 6d 65 20 61 72 67 75 6d 65 6e 74 73 20 69 6e  ome arguments in
0b90: 74 6f 20 72 65 67 69 73 74 65 72 73 20 2a 2f 0a  to registers */.
0ba0: 20 20 5f 5f 61 73 6d 5f 5f 28 22 6d 6f 76 65 6d    __asm__("movem
0bb0: 6c 20 25 30 2c 23 78 37 66 66 66 22 20 2f 2a 20  l %0,#x7fff" /* 
0bc0: 30 78 37 66 66 66 20 3d 3d 20 64 30 2d 64 37 2f  0x7fff == d0-d7/
0bd0: 61 30 2d 61 36 20 2a 2f 0a 20 20 20 20 20 20 20  a0-a6 */.       
0be0: 20 20 20 3a 0a 20 20 20 20 20 20 20 20 20 20 3a     :.          :
0bf0: 20 22 6d 22 20 28 6c 2d 3e 72 65 67 61 72 67 73   "m" (l->regargs
0c00: 5b 30 5d 29 0a 20 20 20 20 20 20 20 20 20 20 2f  [0]).          /
0c10: 2a 20 6e 6f 20 6e 65 65 64 20 66 6f 72 20 61 20  * no need for a 
0c20: 63 6c 6f 62 62 65 72 20 6c 69 73 74 20 73 69 6e  clobber list sin
0c30: 63 65 20 77 65 20 73 61 76 65 20 74 68 65 20 72  ce we save the r
0c40: 65 67 69 73 74 65 72 73 20 6f 75 72 73 65 6c 76  egisters ourselv
0c50: 65 73 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 29  es */.         )
0c60: 3b 0a 0a 20 20 5f 5f 61 73 6d 5f 5f 28 22 72 74  ;..  __asm__("rt
0c70: 73 22 20 3a 20 22 3d 64 22 20 28 69 72 65 74 29  s" : "=d" (iret)
0c80: 20 3a 20 20 3a 20 22 64 31 22 29 3b 09 2f 2a 20   :  : "d1");./* 
0c90: 63 61 6c 6c 20 66 75 6e 63 74 69 6f 6e 20 2a 2f  call function */
0ca0: 0a 20 20 72 65 74 75 72 6e 5f 68 65 72 65 3a 09  .  return_here:.
0cb0: 09 09 09 09 2f 2a 20 66 75 6e 63 74 69 6f 6e 20  ..../* function 
0cc0: 72 65 74 75 72 6e 73 20 68 65 72 65 20 2a 2f 0a  returns here */.
0cd0: 0a 20 20 5f 5f 61 73 6d 5f 5f 28 22 6d 6f 76 65  .  __asm__("move
0ce0: 6d 6c 20 25 30 2c 25 31 22 20 2f 2a 20 25 31 20  ml %0,%1" /* %1 
0cf0: 3d 3d 20 23 30 78 37 66 66 63 20 3d 3d 20 64 32  == #0x7ffc == d2
0d00: 2d 64 37 2f 61 30 2d 61 36 20 2a 2f 0a 20 20 20  -d7/a0-a6 */.   
0d10: 20 20 20 20 20 20 20 3a 20 3a 20 22 6d 22 20 28         : : "m" (
0d20: 72 65 67 73 70 61 63 65 5b 30 5d 29 2c 20 22 6e  regspace[0]), "n
0d30: 22 20 28 5f 5f 53 41 56 45 44 5f 52 45 47 53 29  " (__SAVED_REGS)
0d40: 20 29 3b 09 2f 2a 20 72 65 73 74 6f 72 65 20 72   );./* restore r
0d50: 65 67 69 73 74 65 72 73 20 2a 2f 0a 0a 20 20 73  egisters */..  s
0d60: 70 20 2b 3d 20 5f 5f 41 56 5f 41 4c 49 53 54 5f  p += __AV_ALIST_
0d70: 57 4f 52 44 53 20 2b 20 5f 5f 4e 55 4d 5f 53 41  WORDS + __NUM_SA
0d80: 56 45 44 5f 52 45 47 53 3b 09 2f 2a 20 72 65 73  VED_REGS;./* res
0d90: 74 6f 72 65 20 73 74 61 63 6b 20 70 6f 69 6e 74  tore stack point
0da0: 65 72 20 2a 2f 0a 0a 20 20 2f 2a 20 73 61 76 65  er */..  /* save
0db0: 20 72 65 74 75 72 6e 20 76 61 6c 75 65 20 2a 2f   return value */
0dc0: 0a 20 20 69 66 20 28 6c 2d 3e 72 74 79 70 65 20  .  if (l->rtype 
0dd0: 3d 3d 20 5f 5f 41 56 76 6f 69 64 29 20 7b 0a 20  == __AVvoid) {. 
0de0: 20 7d 20 65 6c 73 65 0a 20 20 69 66 20 28 6c 2d   } else.  if (l-
0df0: 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56 77 6f  >rtype == __AVwo
0e00: 72 64 29 20 7b 0a 20 20 20 20 52 45 54 55 52 4e  rd) {.    RETURN
0e10: 28 5f 5f 61 76 77 6f 72 64 2c 20 69 72 65 74 29  (__avword, iret)
0e20: 3b 0a 20 20 7d 20 65 6c 73 65 0a 20 20 69 66 20  ;.  } else.  if 
0e30: 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41  (l->rtype == __A
0e40: 56 63 68 61 72 29 20 7b 0a 20 20 20 20 52 45 54  Vchar) {.    RET
0e50: 55 52 4e 28 63 68 61 72 2c 20 69 72 65 74 29 3b  URN(char, iret);
0e60: 0a 20 20 7d 20 65 6c 73 65 0a 20 20 69 66 20 28  .  } else.  if (
0e70: 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56  l->rtype == __AV
0e80: 73 63 68 61 72 29 20 7b 0a 20 20 20 20 52 45 54  schar) {.    RET
0e90: 55 52 4e 28 73 69 67 6e 65 64 20 63 68 61 72 2c  URN(signed char,
0ea0: 20 69 72 65 74 29 3b 0a 20 20 7d 20 65 6c 73 65   iret);.  } else
0eb0: 0a 20 20 69 66 20 28 6c 2d 3e 72 74 79 70 65 20  .  if (l->rtype 
0ec0: 3d 3d 20 5f 5f 41 56 75 63 68 61 72 29 20 7b 0a  == __AVuchar) {.
0ed0: 20 20 20 20 52 45 54 55 52 4e 28 75 6e 73 69 67      RETURN(unsig
0ee0: 6e 65 64 20 63 68 61 72 2c 20 69 72 65 74 29 3b  ned char, iret);
0ef0: 0a 20 20 7d 20 65 6c 73 65 0a 20 20 69 66 20 28  .  } else.  if (
0f00: 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56  l->rtype == __AV
0f10: 73 68 6f 72 74 29 20 7b 0a 20 20 20 20 52 45 54  short) {.    RET
0f20: 55 52 4e 28 73 68 6f 72 74 2c 20 69 72 65 74 29  URN(short, iret)
0f30: 3b 0a 20 20 7d 20 65 6c 73 65 0a 20 20 69 66 20  ;.  } else.  if 
0f40: 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41  (l->rtype == __A
0f50: 56 75 73 68 6f 72 74 29 20 7b 0a 20 20 20 20 52  Vushort) {.    R
0f60: 45 54 55 52 4e 28 75 6e 73 69 67 6e 65 64 20 73  ETURN(unsigned s
0f70: 68 6f 72 74 2c 20 69 72 65 74 29 3b 0a 20 20 7d  hort, iret);.  }
0f80: 20 65 6c 73 65 0a 20 20 69 66 20 28 6c 2d 3e 72   else.  if (l->r
0f90: 74 79 70 65 20 3d 3d 20 5f 5f 41 56 69 6e 74 29  type == __AVint)
0fa0: 20 7b 0a 20 20 20 20 52 45 54 55 52 4e 28 69 6e   {.    RETURN(in
0fb0: 74 2c 20 69 72 65 74 29 3b 0a 20 20 7d 20 65 6c  t, iret);.  } el
0fc0: 73 65 0a 20 20 69 66 20 28 6c 2d 3e 72 74 79 70  se.  if (l->rtyp
0fd0: 65 20 3d 3d 20 5f 5f 41 56 75 69 6e 74 29 20 7b  e == __AVuint) {
0fe0: 0a 20 20 20 20 52 45 54 55 52 4e 28 75 6e 73 69  .    RETURN(unsi
0ff0: 67 6e 65 64 20 69 6e 74 2c 20 69 72 65 74 29 3b  gned int, iret);
1000: 0a 20 20 7d 20 65 6c 73 65 0a 20 20 69 66 20 28  .  } else.  if (
1010: 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56  l->rtype == __AV
1020: 6c 6f 6e 67 29 20 7b 0a 20 20 20 20 52 45 54 55  long) {.    RETU
1030: 52 4e 28 6c 6f 6e 67 2c 20 69 72 65 74 29 3b 0a  RN(long, iret);.
1040: 20 20 7d 20 65 6c 73 65 0a 20 20 69 66 20 28 6c    } else.  if (l
1050: 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41 56 75  ->rtype == __AVu
1060: 6c 6f 6e 67 29 20 7b 0a 20 20 20 20 52 45 54 55  long) {.    RETU
1070: 52 4e 28 75 6e 73 69 67 6e 65 64 20 6c 6f 6e 67  RN(unsigned long
1080: 2c 20 69 72 65 74 29 3b 0a 20 20 7d 20 65 6c 73  , iret);.  } els
1090: 65 0a 20 20 69 66 20 28 6c 2d 3e 72 74 79 70 65  e.  if (l->rtype
10a0: 20 3d 3d 20 5f 5f 41 56 6c 6f 6e 67 6c 6f 6e 67   == __AVlonglong
10b0: 20 7c 7c 20 6c 2d 3e 72 74 79 70 65 20 3d 3d 20   || l->rtype == 
10c0: 5f 5f 41 56 75 6c 6f 6e 67 6c 6f 6e 67 29 20 7b  __AVulonglong) {
10d0: 0a 20 20 20 20 28 28 5f 5f 61 76 77 6f 72 64 2a  .    ((__avword*
10e0: 29 6c 2d 3e 72 61 64 64 72 29 5b 30 5d 20 3d 20  )l->raddr)[0] = 
10f0: 69 72 65 74 3b 0a 20 20 20 20 28 28 5f 5f 61 76  iret;.    ((__av
1100: 77 6f 72 64 2a 29 6c 2d 3e 72 61 64 64 72 29 5b  word*)l->raddr)[
1110: 31 5d 20 3d 20 69 72 65 74 32 3b 0a 20 20 7d 20  1] = iret2;.  } 
1120: 65 6c 73 65 0a 20 20 69 66 20 28 6c 2d 3e 72 74  else.  if (l->rt
1130: 79 70 65 20 3d 3d 20 5f 5f 41 56 66 6c 6f 61 74  ype == __AVfloat
1140: 29 20 7b 0a 20 20 20 20 69 66 20 28 6c 2d 3e 66  ) {.    if (l->f
1150: 6c 61 67 73 20 26 20 5f 5f 41 56 5f 53 55 4e 43  lags & __AV_SUNC
1160: 43 5f 46 4c 4f 41 54 5f 52 45 54 55 52 4e 29 20  C_FLOAT_RETURN) 
1170: 7b 0a 20 20 20 20 20 20 52 45 54 55 52 4e 28 66  {.      RETURN(f
1180: 6c 6f 61 74 2c 20 28 66 6c 6f 61 74 29 64 72 65  loat, (float)dre
1190: 74 29 3b 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b  t);.    } else {
11a0: 0a 20 20 20 20 20 20 52 45 54 55 52 4e 28 66 6c  .      RETURN(fl
11b0: 6f 61 74 2c 20 66 72 65 74 29 3b 0a 20 20 20 20  oat, fret);.    
11c0: 7d 0a 20 20 7d 20 65 6c 73 65 0a 20 20 69 66 20  }.  } else.  if 
11d0: 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20 5f 5f 41  (l->rtype == __A
11e0: 56 64 6f 75 62 6c 65 29 20 7b 0a 20 20 20 20 52  Vdouble) {.    R
11f0: 45 54 55 52 4e 28 64 6f 75 62 6c 65 2c 20 64 72  ETURN(double, dr
1200: 65 74 29 3b 0a 20 20 7d 20 65 6c 73 65 0a 20 20  et);.  } else.  
1210: 69 66 20 28 6c 2d 3e 72 74 79 70 65 20 3d 3d 20  if (l->rtype == 
1220: 5f 5f 41 56 76 6f 69 64 70 29 20 7b 0a 20 20 20  __AVvoidp) {.   
1230: 20 52 45 54 55 52 4e 28 76 6f 69 64 2a 2c 20 69   RETURN(void*, i
1240: 72 65 74 29 3b 0a 20 20 7d 20 65 6c 73 65 0a 20  ret);.  } else. 
1250: 20 69 66 20 28 6c 2d 3e 72 74 79 70 65 20 3d 3d   if (l->rtype ==
1260: 20 5f 5f 41 56 73 74 72 75 63 74 29 20 7b 0a 20   __AVstruct) {. 
1270: 20 20 20 2f 2a 20 4e 42 3a 20 4f 6e 20 6d 36 38     /* NB: On m68
1280: 6b 2c 20 61 6c 6c 20 73 74 72 75 63 74 75 72 65  k, all structure
1290: 20 73 69 7a 65 73 20 61 72 65 20 64 69 76 69 73   sizes are divis
12a0: 69 62 6c 65 20 62 79 20 32 2e 20 2a 2f 0a 20 20  ible by 2. */.  
12b0: 20 20 69 66 20 28 6c 2d 3e 66 6c 61 67 73 20 26    if (l->flags &
12c0: 20 5f 5f 41 56 5f 52 45 47 49 53 54 45 52 5f 53   __AV_REGISTER_S
12d0: 54 52 55 43 54 5f 52 45 54 55 52 4e 29 20 7b 0a  TRUCT_RETURN) {.
12e0: 20 20 20 20 20 20 69 66 20 28 6c 2d 3e 72 73 69        if (l->rsi
12f0: 7a 65 20 3d 3d 20 73 69 7a 65 6f 66 28 63 68 61  ze == sizeof(cha
1300: 72 29 29 20 7b 20 2f 2a 20 63 61 6e 27 74 20 6f  r)) { /* can't o
1310: 63 63 75 72 20 2a 2f 0a 20 20 20 20 20 20 20 20  ccur */.        
1320: 52 45 54 55 52 4e 28 63 68 61 72 2c 20 69 72 65  RETURN(char, ire
1330: 74 29 3b 0a 20 20 20 20 20 20 20 20 67 6f 74 6f  t);.        goto
1340: 20 64 6f 6e 65 3b 0a 20 20 20 20 20 20 7d 20 65   done;.      } e
1350: 6c 73 65 0a 20 20 20 20 20 20 69 66 20 28 6c 2d  lse.      if (l-
1360: 3e 72 73 69 7a 65 20 3d 3d 20 73 69 7a 65 6f 66  >rsize == sizeof
1370: 28 73 68 6f 72 74 29 29 20 7b 0a 20 20 20 20 20  (short)) {.     
1380: 20 20 20 52 45 54 55 52 4e 28 73 68 6f 72 74 2c     RETURN(short,
1390: 20 69 72 65 74 29 3b 0a 20 20 20 20 20 20 20 20   iret);.        
13a0: 67 6f 74 6f 20 64 6f 6e 65 3b 0a 20 20 20 20 20  goto done;.     
13b0: 20 7d 20 65 6c 73 65 0a 20 20 20 20 20 20 69 66   } else.      if
13c0: 20 28 6c 2d 3e 72 73 69 7a 65 20 3d 3d 20 73 69   (l->rsize == si
13d0: 7a 65 6f 66 28 69 6e 74 29 29 20 7b 0a 20 20 20  zeof(int)) {.   
13e0: 20 20 20 20 20 52 45 54 55 52 4e 28 69 6e 74 2c       RETURN(int,
13f0: 20 69 72 65 74 29 3b 0a 20 20 20 20 20 20 20 20   iret);.        
1400: 67 6f 74 6f 20 64 6f 6e 65 3b 0a 20 20 20 20 20  goto done;.     
1410: 20 7d 20 65 6c 73 65 0a 20 20 20 20 20 20 69 66   } else.      if
1420: 20 28 6c 2d 3e 72 73 69 7a 65 20 3d 3d 20 32 2a   (l->rsize == 2*
1430: 73 69 7a 65 6f 66 28 5f 5f 61 76 77 6f 72 64 29  sizeof(__avword)
1440: 29 20 7b 0a 20 20 20 20 20 20 20 20 28 28 5f 5f  ) {.        ((__
1450: 61 76 77 6f 72 64 2a 29 6c 2d 3e 72 61 64 64 72  avword*)l->raddr
1460: 29 5b 30 5d 20 3d 20 69 72 65 74 3b 0a 20 20 20  )[0] = iret;.   
1470: 20 20 20 20 20 28 28 5f 5f 61 76 77 6f 72 64 2a       ((__avword*
1480: 29 6c 2d 3e 72 61 64 64 72 29 5b 31 5d 20 3d 20  )l->raddr)[1] = 
1490: 69 72 65 74 32 3b 0a 20 20 20 20 20 20 20 20 67  iret2;.        g
14a0: 6f 74 6f 20 64 6f 6e 65 3b 0a 20 20 20 20 20 20  oto done;.      
14b0: 7d 0a 20 20 20 20 7d 0a 20 20 20 20 69 66 20 28  }.    }.    if (
14c0: 6c 2d 3e 66 6c 61 67 73 20 26 20 5f 5f 41 56 5f  l->flags & __AV_
14d0: 50 43 43 5f 53 54 52 55 43 54 5f 52 45 54 55 52  PCC_STRUCT_RETUR
14e0: 4e 29 20 7b 0a 20 20 20 20 20 20 2f 2a 20 70 63  N) {.      /* pc
14f0: 63 20 73 74 72 75 63 74 20 72 65 74 75 72 6e 20  c struct return 
1500: 63 6f 6e 76 65 6e 74 69 6f 6e 3a 20 6e 65 65 64  convention: need
1510: 20 61 20 20 2a 28 54 59 50 45 2a 29 6c 2d 3e 72   a  *(TYPE*)l->r
1520: 61 64 64 72 20 3d 20 2a 28 54 59 50 45 2a 29 69  addr = *(TYPE*)i
1530: 72 65 74 3b 20 20 2a 2f 0a 20 20 20 20 20 20 69  ret;  */.      i
1540: 66 20 28 6c 2d 3e 72 73 69 7a 65 20 3d 3d 20 73  f (l->rsize == s
1550: 69 7a 65 6f 66 28 63 68 61 72 29 29 20 7b 20 2f  izeof(char)) { /
1560: 2a 20 63 61 6e 27 74 20 6f 63 63 75 72 20 2a 2f  * can't occur */
1570: 0a 20 20 20 20 20 20 20 20 52 45 54 55 52 4e 28  .        RETURN(
1580: 63 68 61 72 2c 20 2a 28 63 68 61 72 2a 29 69 72  char, *(char*)ir
1590: 65 74 29 3b 0a 20 20 20 20 20 20 7d 20 65 6c 73  et);.      } els
15a0: 65 0a 20 20 20 20 20 20 69 66 20 28 6c 2d 3e 72  e.      if (l->r
15b0: 73 69 7a 65 20 3d 3d 20 73 69 7a 65 6f 66 28 73  size == sizeof(s
15c0: 68 6f 72 74 29 29 20 7b 0a 20 20 20 20 20 20 20  hort)) {.       
15d0: 20 52 45 54 55 52 4e 28 73 68 6f 72 74 2c 20 2a   RETURN(short, *
15e0: 28 73 68 6f 72 74 2a 29 69 72 65 74 29 3b 0a 20  (short*)iret);. 
15f0: 20 20 20 20 20 7d 20 65 6c 73 65 0a 20 20 20 20       } else.    
1600: 20 20 69 66 20 28 6c 2d 3e 72 73 69 7a 65 20 3d    if (l->rsize =
1610: 3d 20 73 69 7a 65 6f 66 28 69 6e 74 29 29 20 7b  = sizeof(int)) {
1620: 0a 20 20 20 20 20 20 20 20 52 45 54 55 52 4e 28  .        RETURN(
1630: 69 6e 74 2c 20 2a 28 69 6e 74 2a 29 69 72 65 74  int, *(int*)iret
1640: 29 3b 0a 20 20 20 20 20 20 7d 20 65 6c 73 65 0a  );.      } else.
1650: 20 20 20 20 20 20 69 66 20 28 6c 2d 3e 72 73 69        if (l->rsi
1660: 7a 65 20 3d 3d 20 73 69 7a 65 6f 66 28 64 6f 75  ze == sizeof(dou
1670: 62 6c 65 29 29 20 7b 0a 20 20 20 20 20 20 20 20  ble)) {.        
1680: 28 28 69 6e 74 2a 29 6c 2d 3e 72 61 64 64 72 29  ((int*)l->raddr)
1690: 5b 30 5d 20 3d 20 28 28 69 6e 74 2a 29 69 72 65  [0] = ((int*)ire
16a0: 74 29 5b 30 5d 3b 0a 20 20 20 20 20 20 20 20 28  t)[0];.        (
16b0: 28 69 6e 74 2a 29 6c 2d 3e 72 61 64 64 72 29 5b  (int*)l->raddr)[
16c0: 31 5d 20 3d 20 28 28 69 6e 74 2a 29 69 72 65 74  1] = ((int*)iret
16d0: 29 5b 31 5d 3b 0a 20 20 20 20 20 20 7d 20 65 6c  )[1];.      } el
16e0: 73 65 20 7b 0a 20 20 20 20 20 20 20 20 69 6e 74  se {.        int
16f0: 20 6e 20 3d 20 28 6c 2d 3e 72 73 69 7a 65 20 2b   n = (l->rsize +
1700: 20 73 69 7a 65 6f 66 28 5f 5f 61 76 77 6f 72 64   sizeof(__avword
1710: 29 2d 31 29 2f 73 69 7a 65 6f 66 28 5f 5f 61 76  )-1)/sizeof(__av
1720: 77 6f 72 64 29 3b 0a 20 20 20 20 20 20 20 20 77  word);.        w
1730: 68 69 6c 65 20 28 2d 2d 6e 20 3e 3d 20 30 29 0a  hile (--n >= 0).
1740: 20 20 20 20 20 20 20 20 20 20 28 28 5f 5f 61 76            ((__av
1750: 77 6f 72 64 2a 29 6c 2d 3e 72 61 64 64 72 29 5b  word*)l->raddr)[
1760: 6e 5d 20 3d 20 28 28 5f 5f 61 76 77 6f 72 64 2a  n] = ((__avword*
1770: 29 69 72 65 74 29 5b 6e 5d 3b 0a 20 20 20 20 20  )iret)[n];.     
1780: 20 7d 0a 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a   }.    } else {.
1790: 20 20 20 20 20 20 2f 2a 20 6e 6f 72 6d 61 6c 20        /* normal 
17a0: 73 74 72 75 63 74 20 72 65 74 75 72 6e 20 63 6f  struct return co
17b0: 6e 76 65 6e 74 69 6f 6e 20 2a 2f 0a 20 20 20 20  nvention */.    
17c0: 7d 0a 20 20 20 20 64 6f 6e 65 3a 20 3b 0a 20 20  }.    done: ;.  
17d0: 7d 0a 20 20 72 65 74 75 72 6e 20 30 3b 0a 7d 0a  }.  return 0;.}.
17e0: 0a 23 65 6e 64 69 66 20 2f 2a 5f 61 76 63 61 6c  .#endif /*_avcal
17f0: 6c 5f 6d 36 38 6b 5f 61 6d 69 67 61 5f 63 20 2a  l_m68k_amiga_c *
1800: 2f 0a                                            /.