home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol079 / chain.asm < prev    next >
Encoding:
Assembly Source File  |  1984-04-29  |  2.6 KB  |  96 lines

  1.     public chain ; (char(12))
  2.     extrn    ?signal
  3.             ; /* loads another COM file, and executes it */
  4. bdos    equ    5
  5. openf    equ    15
  6. readf    equ    20
  7. dmaf    equ    26
  8.  
  9.     cseg
  10. chain:
  11.     mov e,m ! inx h ! mov d,m ! xchg    ; get first arg address
  12.     lxi d,fcb ! mvi c,12 ! call move    ; move string to fcb
  13.     lxi d,fcb+12 ! mvi a,0 ! mvi c,21 ! call fill    
  14.                         ; zero rest of fcb
  15.     lhld bdos+1 ! lxi b,-code$len ! dad b    ; make space at top of TPA
  16.     shld jmpr+1                ; jump address 
  17.     push h                    ; save code address for RET
  18.     xchg ! lxi h,fcb-code ! dad d        ; make address of FCB
  19.     shld FCBR+1                ; and fix LXI
  20.     push h                    ; save FCB destination address
  21.     lxi h,code ! mvi c,code$len ! call move    ; dest. in DE
  22.     pop d                    ; recover address of FCB
  23.     mvi c,openf ! call BDOS            ; open file
  24.     inr a ! jz sig                ; if any error, signal error
  25.     pop h ! sphl ! push h            ; point stack to top of TPA 
  26.                         ; and save code addr
  27.     lxi h,100h                ; point to start of TPA
  28.     ret
  29. code:
  30.     push h ! xchg ! mvi c,dmaf ! call BDOS    ; set the DMA address
  31. FCBR:    lxi d,$-$ ! mvi c,readf ! call BDOS    ; read the next record
  32.     ora a ! jnz 100h            ; EOF -> start TPA
  33.     pop h ! lxi d,128 ! dad d        ; recover and bump DMA address
  34. jmpr:    jmp $-$                    ; jump to code
  35.  
  36.  
  37. FCB:
  38.     ds    1                ; drive code
  39.     ds    8                ; file name
  40.     ds    3                ; file type
  41.     ds    4                ; control info
  42.     ds    16                ; disk map
  43.     ds    1                ; rrec
  44. codelen    equ    $-code
  45.  
  46.                         ; c  = # bytes
  47.                         ; hl = source
  48. move:                        ; de = destination
  49.     mov a,m ! stax d
  50.     inx h ! inx d ! dcr c
  51.     jnz move
  52.     ret
  53.  
  54.                         ; c = # bytes
  55.                         ; d = start addr
  56. fill:                        ; a = byte to fill
  57.     stax d ! inx d
  58.     dcr c ! jnz fill
  59.     ret
  60.  
  61. sig:
  62.     lxi h,siglist ! call ?signal ! jmp 0    ; signal error
  63.  
  64. siglist:                    ; (fixed(6),bit(8),ptr,ptr)
  65.     dw sigcode,sigsub,sigfil,message
  66.  
  67. sigcode db    6                ; undefined file error
  68. sigsub    db    2                ; arbitrary subcode for id
  69. sigfil    dw    fpb                ; ptr to file parameter block
  70. message    dw    quack                ; auxiliary operator message
  71.     
  72. fpb:                        ; PL/I file parameter block
  73.  
  74. fcbptr    dw    FCB-1                ; .fcb-1
  75. fpblst  dw    0                ; (unused) ptr
  76. column  dw    0                ; current column fixed(15)
  77. curline dw    0                ; current line     "
  78. curpage dw      0                ; current page     "
  79. currec    dw    0                 ; (unused)         "
  80. lookchr    db    0                ; lookahead char char(1)
  81. ioend   dw    0                ; i/o end address
  82. iostk    dw    0                ; user stack upon sio entry
  83. spacer    ds    4                ; spacer
  84. linesz    dw    0                ; line size fixed(15)
  85. pagesz    dw    0                ; page size   "
  86. fixedsz    dw    0                ; fixed size  "
  87. blocksz    dw    0                ; block size  "
  88. filedes    dw    0                ; file descriptor
  89. dtitle    db    0,''                    ; default title 
  90.                         ;   char(14) varying
  91.  
  92. quack    db    17,'Bad Chain Attempt',0    ; error message
  93.  
  94.  
  95.  
  96.