home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / CLISP-2.LHA / CLISP960530-ki.lha / ffcall / trampoline / tramp-hppa.s < prev    next >
Encoding:
Text File  |  1996-04-15  |  1.3 KB  |  48 lines

  1. ; Trampoline for hppa CPU
  2.  
  3. ; Copyright 1995 Bruno Haible, <haible@ma2s2.mathematik.uni-karlsruhe.de>
  4. ;
  5. ; This is free software distributed under the GNU General Public Licence
  6. ; described in the file COPYING. Contact the author if you don't have this
  7. ; or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
  8. ; on this software.
  9.  
  10. ; Available registers: %r19, %r20, %r21, %r22.
  11.  
  12.     .SPACE $PRIVATE$
  13.     .SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31
  14.     .SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82
  15.     .SPACE $TEXT$
  16.     .SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44
  17.     .SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY
  18.  
  19.     .SPACE $TEXT$
  20.     .SUBSPA $CODE$
  21.  
  22.     .align 4
  23.     .EXPORT tramp
  24. tramp
  25.     .PROC
  26.     .CALLINFO
  27.     .ENTRY
  28. ; Move <data> into <variable>
  29.     ldil L'0x73554711,%r20
  30.     ldil L'0x12345678,%r19
  31.     ldo R'0x73554711(%r20),%r20
  32.     stw %r20,R'0x12345678(%r19)
  33. ; Get <function>
  34.     ldil L'0xbabebec0,%r21
  35.     ldo R'0xbabebec0(%r21),%r21
  36. ; Jump to %r21, just like the gcc-2.6.3 trampoline does it:
  37.     bb,>=,n %r21,30,tramp2    ; check bit 1 of %r21
  38.     depi 0,31,2,%r21    ; if set, clear bits 1..0
  39.     ldw 4(0,%r21),%r19    ; ... dereference the function struct
  40.     ldw 0(0,%r21),%r21    ; ... to get the actual code address
  41. tramp2
  42.     ldsid (0,%r21),%r1
  43.     mtsp %r1,%sr0        ; set segment register
  44.     be,n 0(%sr0,%r21)    ; now do an inter-module jump
  45.     nop
  46.     .EXIT
  47.     .PROCEND
  48.