home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / utility / fastload / fastload.st next >
Text File  |  1989-03-29  |  4KB  |  175 lines

  1.     module fastload
  2.  
  3.     section s.ccode
  4.  
  5. gemdos        equ 1
  6. bios        equ 13
  7. super        equ $20
  8. ptermres    equ $31
  9. conws        equ 9
  10. pterm        equ $4c
  11. vbl_queue    equ $456
  12. nvbl        equ $454
  13. bpaglen        equ $100
  14. textlen        equ 12
  15. datalen        equ 20
  16. bsslen        equ 28
  17. fillhigh    equ $fc859c
  18. filllow        equ $fc858a
  19. bigint        equ $7cccccc0
  20.  
  21. fastinit
  22.     clr.l    -(sp)
  23.     move.w    #super,-(sp)
  24.     trap    #gemdos
  25.     addq.l    #6,sp
  26.     move.l    d0,-(sp)    * Save ssp on stack
  27.     move.w    nvbl,d0
  28.     movea.l    vbl_queue,a0
  29.     addq.l    #4,a0
  30.     subq.l    #1,d0
  31.     bmi.s    tstque2
  32.     bra.s    tstque1
  33. tstque0
  34.     tst.l    (a0)+
  35. tstque1
  36.     dbeq    d0,tstque0
  37.     beq.s    tstok
  38. tstque2
  39.     pea    noque(pc)
  40.     move.w    #conws,-(sp)
  41.     trap    #gemdos
  42.     addq.l    #6,sp
  43.     move.w    #1,-(sp)
  44.     move.w    #pterm,-(sp)
  45.     trap    #gemdos        * Ends here
  46. tstok
  47.     lea    fastload(pc),a1
  48.     move.l    a1,-(a0)
  49.     move.w    #super,-(sp)
  50.     trap    #gemdos        * Restore ssp that is on stack
  51.     addq.l    #6,sp
  52.     move.l    4(sp),a0    * Basepage start
  53.     move.l    #bpaglen,d0    * Basepage length
  54.     add.l    textlen(a0),d0    * + text length
  55.     add.l    datalen(a0),d0    * + data length
  56.     add.l    bsslen(a0),d0    * + bss length
  57.     clr.w    -(sp)        * Return value: 0 for success
  58.     move.l    d0,-(sp)    * # bytes to keep
  59.     move.w    #ptermres,-(sp)    * Keep process
  60.     trap    #gemdos        * Stops here
  61.  
  62. fastload
  63.     movea.l    74(sp),a0    * PC
  64.     cmpa.l    #fillhigh,a0
  65.     bhi.s    fastdone
  66.     cmpa.l    #filllow,a0
  67.     blt.s    fastdone
  68.     move.l    #bigint,32(sp)    * Maximize D5 on stack
  69. fastdone
  70.     rts
  71.  
  72.     section s.data
  73.  
  74. noque    dc.b    'No vbl entry available!',13,10,0
  75.  
  76.     end
  77.  
  78. I hope no little beasties have crept in while I was typing it over (have no
  79. modem connection yet). Have fun!
  80.  
  81.     Leo.
  82.  
  83.  
  84. From mcvax!philmds.UUCP!leo Fri Jun  3 10:54:28 1988
  85. Path: ruuinf!mcvax!philmds!leo
  86. From: leo@philmds.UUCP (Leo de Wit)
  87. Newsgroups: comp.sys.atari.st
  88. Subject: Re: null fill eliminated
  89. Keywords: addition
  90. Message-ID: <491@philmds.UUCP>
  91. Date: 3 Jun 88 09:54:28 GMT
  92. References: <490@philmds.UUCP>
  93. Reply-To: leo@philmds.UUCP (L.J.M. de Wit)
  94. Organization: Philips I&E DTS Eindhoven
  95. Lines: 76
  96.  
  97. Here are some small corrections for the fast loader I put on the net this week.
  98. 1) There is a header for the module now. It says:
  99.  
  100. * Even when loading from ramdisk or harddisk the ROM program null fills all
  101. * uninitialized data, heap, stack (often the major part of your RAM).
  102. * This null filler makes loading programs faster. Its null filling is 7 times
  103. * as fast as the ROM's, using the quick movem.l instruction. Besides it only
  104. * clears the BSS space.
  105. * At least the fillhigh and filllow addresses have to be adapted to suit your
  106. * ROM version.
  107.  
  108. 2) The bigint definition should read:
  109.  
  110. bigint        equ $7ffffff0
  111.  
  112. 3) I abandoned the idea of no null filling at all. Some programs generated
  113. bus errors when started with this VBL routine active, so I've looked things 
  114. up in K & R. In paragraph 4.9 (Initialization):
  115. ...In the absence of explicit initialization, external and static variables 
  116. are guaranteed to be initialized to zero; ...
  117. So the routine now clears the BSS space; the programs that generated errors
  118. now work OK. The null filling is performed by null filling chunks of 128
  119. bytes using movem.l instructions; that seems to be the fastest way, especially
  120. if you move many registers at a time. The 'modulo 128' part is cleared first,
  121. at the top of the BSS. Here it is (I have left the initialization routine out):
  122.  
  123. fastload
  124.     movea.l    74(sp),a0    * PC
  125.     cmpa.l    #fillhigh,a0
  126.     bhi.s    fastdone
  127.     cmpa.l    #filllow,a0
  128.     blt.s    fastdone
  129.     lea.l    32(sp),a0    * Address D5 on stack
  130.     cmp.l    #bigint,(a0)
  131.     bge.s    fastdone    * Already filled
  132.     move.l    #bigint,(a0)    * Maximize D5 on stack
  133.     move.l    68(sp),a6    * Value of A6 on stack to A6
  134.     move.l    -4(a6),a4    * Start of block to fill
  135.     move.l    -58(a6),d0    * # bytes to fill: BSS size
  136.     move.l    d0,d1
  137.     and.w    #$7f,d1        * d1 = d0 & 0x7f
  138.     moveq.l    #0,d2
  139.     lea.l    (a4,d0.l),a5    * End (one past)
  140.     bra.s    fastl1
  141. fastl0
  142.     move.b    d2,-(a5)    * Clear top d1 bytes
  143. fastl1
  144.     dbra    d1,fastl0
  145.     moveq.l    #0,d0        * Nullify d0-d7/a0-a3
  146.     move.l    d0,d1
  147.     move.l    d0,d2
  148.     move.l    d0,d3
  149.     move.l    d0,d4
  150.     move.l    d0,d5
  151.     move.l    d0,d6
  152.     move.l    d0,d7
  153.     move.l    d0,a0
  154.     move.l    d0,a1
  155.     move.l    d0,a2
  156.     move.l    d0,a3
  157.     bra.s    fastl3        * a5 - a4 is now a multiple of 128
  158. fastl2
  159.     movem.l    do-d7/a0-a3,-(a5)  * Clear 4 * (12 + 12 + 8) = 128 bytes / turn
  160.     movem.l    do-d7/a0-a3,-(a5)
  161.     movem.l    do-d7,-(a5)
  162. fastl3
  163.     cmpa.l    a4,a5
  164.     bgt.s    fastl2        * Until start address A4 reached
  165. fastdone
  166.     rts
  167.  
  168.     section s.data
  169.  
  170. noque    dc.b    'No vbl entry available!',13,10,0
  171.  
  172.     end
  173.  
  174.  
  175.