home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 122.lha / Arp_v1.1 / Libraries / Manx_SRC / arprescrt0.s < prev    next >
Encoding:
Text File  |  1986-11-21  |  3.3 KB  |  139 lines

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