home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / list / ep-src.ark / EPEXEC.MAC < prev    next >
Encoding:
Text File  |  1988-05-21  |  1.8 KB  |  87 lines

  1.  
  2. ;simplified version of exec with no command line args
  3. ; to call EPERROR
  4.  
  5.     include    BDS.LIB
  6.  
  7. epexec::
  8.  
  9.     lxi    d,$efname
  10.  
  11. ;DE has fname ptr
  12.     push    b
  13.     lxi    h,-60    ;compute &nfcb for use here
  14.     dad    sp
  15.     push    h    ; save for much later (will pop    into BC)
  16.       push    h    ;make a few copies for local use below
  17.     call    setfcu    ;set up COM file for execl-ing
  18.     lda    usrnum
  19.     call    setusr    ;set destination user area
  20.     pop    d    ;get new fcb addr
  21.     mvi    c,openc    ;open the file for reading
  22.     call    .bdos
  23.     call    rstusr    ;reset user number to previous
  24.     cpi    errorv
  25.     jnz    noerrr
  26. err:    pop    h    ;discard fcb addr
  27.     pop    b
  28.     jmp    error
  29.  
  30. noerrr:
  31.     lxi    d,code0    ;copy loader down to end of tbuff
  32.     lxi    h,tpa-49
  33.     mvi    b,49    ;length of loader
  34. excl4:    ldax    d
  35.     mov    m,a
  36.     inx    d
  37.     inx    h
  38.     dcr    b
  39.     jnz    excl4
  40.  
  41.     pop    b    ;get fcb pointer in BC
  42.             ;reset the SP:
  43.     lhld    base+6    ;get BDOS pointer in HL
  44. go1:    sphl
  45.  
  46.     lxi    h,base
  47.     push    h    ;set base of ram as return addr
  48.     jmp    tpa-49    ;(go to `code0:')
  49.  
  50. $efname:    db    'EPERROR.COM',0
  51.  
  52. ;
  53. ; This loader code is now: 49 bytes long.
  54. ;
  55.  
  56. code0:    lxi    d,tpa    ;destination address of new program
  57. code1:    push    d    ;push    dma addr
  58.     push    b    ;push    fcb pointer
  59.     mvi    c,sdma    ;set DMA address for new sector
  60.     call    .bdos
  61.     pop    d    ;get pointer to working fcb in DE
  62.     push    d    ;and re-push    it
  63.     mvi    c,reads    ;read a sector
  64.     call    .bdos
  65.     pop    b    ;restore fcb pointer into BC
  66.     pop    d    ;and dma address into DE
  67.     ora    a    ;end of file?
  68.     jz    tpa-8    ;if not, get next sector (goto `code2:')
  69.  
  70.     mov    d,b
  71.     mov    e,c
  72.     mvi    c,closec
  73.     call    .bdos
  74.  
  75.     mvi    c,sdma    ;reset DMA pointer
  76.     lxi    d,tbuff
  77.     call    .bdos
  78.     jmp    tpa    ;and go invoke the program
  79.  
  80. code2:    lxi    h,80h    ;bump dma address
  81.     dad d
  82.     xchg
  83.     jmp    tpa-46     ;and go loop (at code1)
  84.  
  85.  
  86.     end
  87.