home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / programming / aztecarp_436 / src / rstart.asm < prev    next >
Assembly Source File  |  1990-12-05  |  4KB  |  146 lines

  1. ;:ts=8
  2. ;
  3. ; Initial startup routine for Aztec 'C' and ARP using RESIDENT.
  4. ; NB: This should allow access to all Aztec Features, math, etc.
  5. ;     Could be made smaller if only for CLI, only for Workbench,
  6. ;     Could be made smaller if only this or that.
  7. ;
  8. ; Created 02-18-88 by -+=SDB+=- from arpcrt0.s
  9. ; Copyright (c) 1988 by Scott Ballantyne, may be freely
  10. ; used by Arp Supporters/users.
  11. ; Use at your own risk.
  12. ;
  13. ; NB: References to the ___fromdisk__ long have to be handled carefully,
  14. ;     since they are somewhat shizophrenic, sometimes referring to copied
  15. ;     data, sometimes not.  Note that they should fine for the C code without
  16. ;     special handling as long as small model is used.
  17. ;
  18. ; May 9, 1988:    Move OpenLibrary() call into _main() to fix WBench Bug.
  19. ;        Add AhOhNoARP() callout for better user interface.
  20. ;
  21. ; 10-Mar-90:    Put together from resgeta4.s & arprescrt0.s for
  22. ;        Aztec 5.0 release.
  23.  
  24.     include "exec/types.i"
  25.     include "exec/execbase.i"
  26.     include "exec/memory.i"
  27.     include "exec/tasks.i"
  28.     include "exec/alerts.i"
  29.     include "libraries/arpbase.i"
  30.     include "exec/execbase.i"
  31.  
  32. call    macro
  33.     xref    _LVO\1
  34.     jsr    _LVO\1(a6)
  35.     endm
  36.  
  37.     mc68881
  38.     entry    .begin
  39.     public    .begin
  40.     public    _geta4
  41.  
  42. *    If you need more or less stack, change the first number below
  43. *    For example, if your program only needs 4000 bytes of stack, the
  44. *    line below would read:
  45. *    RESIDENT 4000,__H2_end-__H1_org,loaded
  46. *
  47.  
  48. .begin
  49.     RESIDENT 10240,__H2_end-__H1_org,loaded
  50.     moveq.l #0,d7            ; flag resident code
  51.     move.l    a4,a3            ; copy base
  52.     add.l    #32766,a4        ; bias
  53.     bra.s    clonedata        ; and copy the data segment only
  54. loaded: moveq.l #-1,d7            ; flag not resident (start if from disk)
  55.     far data
  56.     move.l    d7,___fromdisk__    ; needs to be set for _geta4
  57.     near data
  58.     bsr    _geta4
  59. isresident:
  60.     lea    __H1_end,a1
  61.     lea    __H2_org,a2
  62.     cmp.l    a1,a2            ;check if BSS and DATA together
  63.     bne    normal            ; this would actually be an error.
  64.     move.w    #((__H2_end-__H2_org)/4)-1,d1
  65.     bmi    normal
  66.     move.l    #0,d2
  67.  
  68. loop    move.l    d2,(a1)+        ;clear out memory
  69.     dbra    d1,loop
  70.     bra.s    normal
  71.  
  72. clonedata:
  73.     move.l    #((__H1_end-__H1_org)/4)-1,d1
  74.     bmi.s    normal
  75.     far    data
  76.     lea    __H1_end,a1
  77.     lea    __H2_org,a2
  78.     cmp.l    a1,a2
  79.     beq.s    1$
  80.     move.l    #500,d0            ; error, must be same hunk, so scram
  81.     rts
  82.  
  83. 1$:    lea.l    __H1_org,a1        ; clone data and bss
  84.  
  85.     near    data
  86. 0$    move.l    (a1)+,(a3)+        ; a3 set to point to base
  87.     dbra    d1,0$
  88.  
  89. normal: move.l    sp,__savsp        ; save stack pointer
  90.     move.l    (4).w,a6        ; get Exec's library base pointer
  91.     move.l    a6,_SysBase        ; put where we can get it
  92.     movem.l d0/a0,-(sp)        ; save CLI command parameters
  93.  
  94.     move.w    AttnFlags(a6),d0
  95.     btst    #AFB_68881,d0        ;check for 68881 flag in AttnFlags
  96.     beq    1$            ;skip if not
  97.     lea    2$,a5
  98.     call    Supervisor        ;do it in supervisor mode
  99.     bra    1$
  100.  
  101. 2$    clr.l    -(sp)
  102.     frestore (sp)+            ;reset the ffp stuff
  103.     rte                ;and return
  104.  
  105. 1$    jsr    __main            ;call the startup stuff
  106.     addq.l    #8,sp            ;pop args
  107.     rts                ;and return
  108.  
  109. _geta4:
  110.     far    data
  111.     movem.l d0-d1/a0-a1/a6,-(sp)    ; max safety here...
  112.     tst.l    ___fromdisk__
  113.     bne.s    1$
  114.     move.l    (4).w,a6
  115.     move.l    ThisTask(a6),a0
  116.     lea.l    TC_MEMENTRY(a0),a0
  117.     lea.l    PMEM(pc),a1
  118.     call    FindName
  119.     move.l    d0,a0
  120.     cmp.w    #2,pm_Num(a0)        ; check for data
  121.     bne.s    1$            ; resident, but no data allocated.
  122.     move.l    pm_Data(a0),a4        ; get data pointer
  123.     add.l    #32766,a4        ; bias 
  124.     bra.s    2$
  125. 1$    lea.l    __H1_org+32766,a4
  126. 2$    movem.l (sp)+,d0-d1/a0-a1/a6
  127.     rts
  128.  
  129. PMEM    PMEM_NAME
  130.  
  131.     public    __main,__H0_org
  132.  
  133.     dseg
  134.     
  135.     public    _SysBase,_DOSBase,__savsp,___fromdisk__
  136.     public    __H1_org,__H1_end,__H2_org,__H2_end
  137.  
  138.     near    data
  139.  
  140.     even
  141.  
  142. ___fromdisk__:
  143.     dc.l    0    ; default is resident
  144.  
  145.     end
  146.