home *** CD-ROM | disk | FTP | other *** search
/ Between Heaven & Hell 2 / BetweenHeavenHell.cdr / 300 / 295 / load.asm < prev    next >
Assembly Source File  |  1984-02-20  |  5KB  |  121 lines

  1.         name     load
  2.         page     55,128
  3.         title   'LOAD -- load .COM file for MS-DOS 2.0'
  4. ;
  5. ;
  6. ; LOAD -- load .COM file bigger than 64K
  7. ; Requires MS-DOS 2.0
  8. ; Version 1.1   Dec 83 RGD
  9. ; Version 1     March 1983 RJW
  10.  
  11. ; copyright (c) 1983
  12. ; Laboratory Microsystems
  13. ; 4147 Beethoven Street
  14. ; Los Angeles, CA  90066
  15. ;
  16. cr      equ     0dh     ;ASCII carriage return
  17. lf      equ     0ah     ;ASCII line feed
  18.  
  19. cseg    segment byte
  20.  
  21.         org     100h
  22.  
  23.         assume  cs:cseg,ds:cseg
  24.  
  25. load    proc    far             ; sets up far return ...
  26.  
  27.         push    es              ; save segment of PSP
  28.         mov     dx,offset mes2  ; startup message
  29.         mov     ah,9
  30.         int     21h
  31.         xor     dx,dx           ; zero DX
  32.         mov     ah,25h          ; set terminate address ...
  33.         mov     al,22h          ; ... for new program segment
  34.         int     21h
  35.  
  36.         mov     dx,offset endofs ; offset to end of this loader
  37.         mov     cl,4            ; no of bits to shift
  38.         shr     dx,cl           ; convert byte addr to paragraph
  39.         inc     dx              ; offset of 1st available segment
  40.         mov     ax,cs           ; current segment to AX
  41.         add     dx,ax           ; actual value of 1st available segment
  42.         mov     useg,dx         ; save it for later ...
  43.         mov     es,dx           ; ... and for subsequent move
  44.         mov     ah,26h          ; call to DOS
  45.         int     21h             ; create new program segment
  46.  
  47.         mov     si,6ch          ; 2nd param FCB in current segment
  48.         mov     di,5ch          ; 1st param FCB in new segment
  49.         mov     cx,0ch          ; byte count for move
  50.         repz movsb              ; copy the filename
  51.  
  52.         mov     ax,cs           ; copy current code seg ...
  53.         mov     ds,ax           ; ... to DS
  54.         mov     dx,5ch          ; DS:DX points to FCB of .COM file
  55.         mov     bx,dx           ; make FCB addressible
  56.         mov     byte ptr  9 [bx],'C' ; force COM extension
  57.         mov     byte ptr 10 [bx],'O'
  58.         mov     byte ptr 11 [bx],'M'
  59.         mov     ah,0fh          ; open the .COM file
  60.         int     21h
  61.         or      al,al           ; test return code
  62.         jnz     load8           ; exit if non-zero
  63.         mov     word ptr 33 [bx],0000 ; zero the random
  64.         mov     word ptr 35 [bx],0000 ; record field in the FCB
  65.         pop     es              ; get loader's PSP segment
  66.         mov     bx,useg         ; let SS:SP = default buffer of
  67.         mov     ss,bx           ; new PSP
  68.         mov     sp,100h
  69.         push    es              ; save loader's PSP again
  70.         add     bx,10h          ; BX = segment of current DTA
  71.         mov     ds,bx           ; set up DS:DX to point to the DTA
  72.         xor     dx,dx
  73.         mov     ah,1ah          ; set up DOS call and do it
  74.         int     21h
  75.  
  76. load5:  mov     cx,100h         ; number of records of length 80h
  77.         mov     ax,cs           ; copy current CS to DS
  78.         mov     ds,ax
  79.         mov     dx,5ch          ; DS:DH points to FCB of .COM file
  80.         mov     ah,27h          ; do random block read
  81.         int     21h
  82.         test    al,1            ; end of file?
  83.         jnz     load9           ; yes, so exit
  84.         add     bx,800h         ; increment location of DTA
  85.         mov     ds,bx           ; copy to DS
  86.         xor     dx,dx           ; DS:DX now points to next DTA
  87.         mov     ah,1ah          ; set up DOS call to set DTA
  88.         int     21h
  89.         jmp     load5           ; do it again
  90.  
  91. load8:  mov     dx,offset mes1  ; "file not found"
  92.         mov     ah,9            ; write to terminal
  93.         int     21h
  94.         int     20h             ; exit to DOS
  95.  
  96. load9:  mov     ax,useg         ; set up registers for new segment
  97.         mov     ds,ax
  98.         pop     es              ; pass loader's PSP segment to overlay
  99.         push    ax              ; push new CS onto stack
  100.         mov     ax,100h
  101.         push    ax              ; push offset onto stack
  102.         ret                     ; FAR return causes CS:IP to be set
  103. load    endp
  104.  
  105. mes1    db      cr,lf,
  106.         db      '.COM file not found'
  107.         db      cr,lf,'$'
  108. mes2    db      cr,lf
  109.         db      'Multi-Segment Loader version 1.1 for MS-DOS 2.0'
  110.         db      cr,lf
  111.         db      'Copyright (c) 1983 Laboratory Microsystems Inc.'
  112.         db      cr,lf,'$'
  113.  
  114. useg    dw      0
  115.  
  116. endofs  equ     $
  117.  
  118. cseg    ends                    ; end of code segment
  119.  
  120.         end     load
  121.