home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff353.lzh / AztecArp / rstart.asm < prev    next >
Assembly Source File  |  1990-06-02  |  5KB  |  179 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. ;        Note:    define ARPONLY to create startup code for Arp
  25. ;            tool, the default is standard Aztec startup code.
  26. ;            The reason for this is: Arp opens dos.library in
  27. ;            _main() while the standard Aztec startup code
  28. ;            opens it before entering _main().
  29. ;
  30.  
  31.         INCLUDE "exec/types.i"
  32.         INCLUDE "exec/exec_lib.i"
  33.         INCLUDE "exec/execbase.i"
  34.         INCLUDE "exec/memory.i"
  35.         INCLUDE "exec/tasks.i"
  36.         INCLUDE "exec/alerts.i"
  37.  
  38.         INCLUDE "libraries/arpbase.i"
  39.  
  40. ARPONLY    EQU    1    ; This is the arp startup code
  41.  
  42.         mc68881
  43.         entry   .begin
  44.         public  .begin
  45.         public  _geta4
  46.  
  47. *       If you need more or less stack, change the first number below
  48. *       For example, if your program only needs 4000 bytes of stack, the
  49. *       line below would read:
  50. *       RESIDENT 4000,__H2_end-__H1_org,loaded
  51. *
  52.  
  53. .begin
  54.         RESIDENT 10240,__H2_end-__H1_org,loaded
  55.         moveq.l #0,d7                   ; flag resident code
  56.         move.l  a4,a3                   ; copy base
  57.         add.l   #32766,a4               ; bias
  58.         bra.s   clonedata               ; and copy the data segment only
  59. loaded: moveq.l #-1,d7                  ; flag not resident (start if from disk)
  60.         far data
  61.         move.l  d7,___fromdisk__        ; needs to be set for _geta4
  62.         near data
  63.         bsr     _geta4
  64. isresident:
  65.         lea     __H1_end,a1
  66.         lea     __H2_org,a2
  67.         cmp.l   a1,a2                   ;check if BSS and DATA together
  68.         bne     normal                  ; this would actually be an error.
  69.         move.w  #((__H2_end-__H2_org)/4)-1,d1
  70.         bmi     normal
  71.         move.l  #0,d2
  72. loop
  73.         move.l  d2,(a1)+                ;clear out memory
  74.         dbra    d1,loop
  75.         bra.s   normal
  76. clonedata:
  77.         move.l  #((__H1_end-__H1_org)/4)-1,d1
  78.         bmi.s   normal
  79.         far     data
  80.         lea     __H1_end,a1
  81.         lea     __H2_org,a2
  82.         cmp.l   a1,a2
  83.         beq.s   1$
  84.         move.l  #500,d0                 ; error, must be same hunk, so scram
  85.         rts
  86. 1$:     lea.l   __H1_org,a1             ; clone data and bss
  87.         near    data
  88. 0$      move.l  (a1)+,(a3)+             ; a3 set to point to base
  89.         dbra    d1,0$
  90. normal: move.l  sp,__savsp              ; save stack pointer
  91.         move.l  4,a6                    ; get Exec's library base pointer
  92.         move.l  a6,_SysBase             ; put where we can get it
  93.         movem.l d0/a0,-(sp)             ; save CLI command parameters
  94.  
  95.         btst.b  #4,$129(a6)             ;check for 68881 flag in AttnFlags
  96.         beq     1$                      ;skip if not
  97.         lea     2$,a5
  98.         jsr     -30(a6)                 ;do it in supervisor mode
  99.         bra     1$
  100. 2$
  101.         clr.l   -(sp)
  102.         frestore (sp)+                  ;reset the ffp stuff
  103.         rte                             ;and return
  104. 1$
  105.     IFND ARPONLY
  106.     lea    dos_name,a1        ;get name of dos library
  107.     moveq    #0,d0            ;any version
  108.     jsr    -$228(a6)        ;open the library
  109.     move.l    d0,_DOSBase        ;set it up
  110.     bne    3$            ;skip if okay
  111.  
  112.       move.l  #$38007,d7        ;AG_OpenLib | AO_DOSLib
  113.     jsr     -108(a6)        ;Alert
  114.     bra    4$
  115. 3$
  116.     jsr    __main            ;call the startup stuff
  117.     tst.l    _DOSBase        ;lib still open?
  118.     beq.s    4$            ;nope
  119.     move.l    _DOSBase,a1
  120.     move.l    4,a6
  121.     jsr    -$19e(a6)        ;close it then
  122. 4$
  123.     add.w     #8,sp            ;pop args
  124.     rts                ;and return
  125.  
  126. dos_name:
  127.     dc.b    'dos.library',0
  128.     ENDC
  129.  
  130.     IFD ARPONLY
  131.         jsr     __main                  ;call the startup stuff
  132.         add.w   #8,sp                   ;pop args
  133.         rts                             ;and return
  134.     ENDC
  135.  
  136. _geta4:
  137.     far    data
  138.     movem.l    d0-d1/a0-a1/a6,-(sp)    ; max safety here...
  139.     tst.l    ___fromdisk__
  140.     bne.s    1$
  141.     move.l    4,a6
  142.     move.l    ThisTask(a6),a0
  143.     lea.l    TC_MEMENTRY(a0),a0
  144.     lea.l    PMEM(pc),a1
  145.     SYSCALL    FindName
  146.     move.l    d0,a0
  147.     cmp.w    #2,pm_Num(a0)        ; check for data
  148.     bne.s    1$            ; resident, but no data allocated.
  149.     move.l    pm_Data(a0),a4        ; get data pointer
  150.     add.l    #32766,a4        ; bias 
  151.     bra.s    2$
  152. 1$:    lea.l    __H1_org+32766,a4
  153. 2$:    movem.l    (sp)+,d0-d1/a0-a1/a6
  154.     rts
  155.  
  156. PMEM    PMEM_NAME
  157.  
  158.         public  __main,__H0_org
  159.  
  160.         dseg
  161.         
  162.         public  _SysBase,_DOSBase,__savsp,___fromdisk__,___sloppy__
  163.         public  __H1_org,__H1_end,__H2_org,__H2_end
  164.  
  165.     near    data
  166.  
  167.     even
  168.  
  169. ___fromdisk__:
  170.     dc.l    0    ; default is resident
  171. ___sloppy__:
  172.     IFND ARPONLY
  173.     dc.l    0
  174.     ENDC
  175.  
  176.     IFD ARPONLY
  177.     dc.l    1
  178.     ENDC
  179.