home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / lattice / crt0.s < prev    next >
Text File  |  1992-06-15  |  2KB  |  68 lines

  1. ;
  2. ; Initilization code; this is common to both 16 and 32 bit libraries,
  3. ; so be careful!
  4. ;
  5.     xref    __app        ; short, declared in crtinit.c
  6.     xref    __base        ; BASEPAGE *, declared in crtinit.c
  7.     xref    __heapbase    ; void *
  8.     xref    __stksize    ; long, declared by user or in stack.c
  9.     xref    __acc_main
  10.     xref    __crtinit
  11. ;
  12. ; Assumption: basepage is passed in a0 for accessories; for programs
  13. ; a0 is always 0.
  14.  
  15.     text
  16.     even
  17.     xdef    __start
  18. __start:
  19.     sub.l    a6,a6        ; clear a6 for debuggers
  20.     cmp.w    #0,a0        ; test if acc or program
  21.     beq.s    __startprg    ; if a program, go elsewhere
  22.     tst.l    36(a0)        ; also test parent basepage pointer
  23.     bne.s    __startprg    ; for acc's, it must be 0
  24.     move.l    a0,__base    ; acc basepage is in A0
  25.     move.l    __heapbase,sp    ; stack must be set from heap
  26.     add.l    __stksize,sp
  27.     jmp    __acc_main    ; function is in crtinit.c
  28. ;
  29. ; program startup code: doesn't actually do much, other than push
  30. ; the basepage onto the stack and call _start1 in crtinit.c
  31. ;
  32. __startprg:
  33.     move.l    4(sp),a0    ; get basepage
  34.     move.l    a0,__base    ; save it
  35.     move.l    4(a0),d0    ; get _base->p_hitpa
  36.     and.l    #$fffffffe,d0    ; round off
  37.     move.l    d0,sp        ; set stack (temporarily)
  38.     jmp    __crtinit    ; in crtinit.c
  39.  
  40. ;
  41. ; _setstack: changes the stack pointer; called as
  42. ;     void setstack( void *newsp )
  43. ; called from crtinit.c once the new stack size has been decided upon
  44. ;
  45. ; WARNING WARNING WARNING: after you do this, local variables may no longer
  46. ; be accessible!
  47. ; destroys a0 and a7
  48.  
  49.     xdef    __setstack
  50. __setstack:
  51.     move.l    (sp)+,a0    ; save return address
  52.     move.l    (sp)+,sp    ; new stack pointer
  53.     subq.l    #4,sp        ; fixup for tidy upon return
  54.     jmp    (a0)        ; back to caller
  55.  
  56. ;
  57. ; interfaces for gprof: for crt0.s, does nothing, but for gcrt0.s branches
  58. ; to the appropriate subroutines
  59. ;
  60.     xdef     __monstartup
  61.     xdef    __moncontrol
  62.     xdef     ___mcleanup
  63. __monstartup:
  64. __moncontrol:
  65. ___mcleanup:
  66.     rts
  67.     end
  68.