home *** CD-ROM | disk | FTP | other *** search
/ Atari FTP / ATARI_FTP_0693.zip / ATARI_FTP_0693 / Mint / mntlib25.zoo / sozobon / crt0.s < prev    next >
Text File  |  1992-02-12  |  2KB  |  60 lines

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