home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asm_kit / save.asm < prev    next >
Assembly Source File  |  1985-06-21  |  3KB  |  87 lines

  1. ;
  2.               extrn  stdinck:far
  3.               extrn  emessout:far,getspec:far
  4.               extrn  createfile:far,closefile:far
  5.               extrn  cominit:far,comon:far,comoff:far
  6.               extrn  initcbuff:far,incbuff:far,outcbuff:far
  7.               extrn  flushit:far
  8.               extrn  dta:dword
  9. ;
  10. ;***************************************************************
  11. ;
  12. datas   datas         segment          public
  13. ;
  14. namebuff      db     256 dup(0)
  15. ;
  16. data          ends
  17. ;
  18. ;***************************************************************
  19. ;
  20. stacks        segment                  stack
  21.               db                       20dup('stack')
  22. stacks        ends
  23. ;
  24. ;***************************************************************
  25. ;
  26. codes         segment
  27. ;
  28.               assume cs;codes,ds:datas
  29. ;
  30. ;ROUTINE TO SAVE FILE FROM COMMUNICATIONS LINE TO DISK
  31. ;
  32. save          proc   far
  33. ;
  34. ;set up return
  35.               push   ds                ;save for proper return
  36.               mov    ax,0              ;points to beginning of segment
  37.               push   ax                ;for the offset
  38. ;
  39. ;set up segments
  40.               mov    dx,ds             ;program segment prefix was data seg
  41.               mov    ax,datas          ;new data segment
  42.               mov    ds,ax             ;put in DS
  43.               mov    es,ax             ;put in ES
  44.               mov    dta+2,dx          ;set the segment of the data
  45. ;
  46. ;set up the file
  47.               lea    dx,namebuff       ;point to the ASCIIZ buffer
  48.               call   getspec           ;get file specifications
  49.               jc     exception         ;error?
  50.               lea    dx,namebuff       ;ASCIIZ buffer has file specifiers
  51.               call   createfile        ;set up the file
  52.               jc     exception         ;error?
  53.               mov    bx,ax             get the file handle
  54. ;
  55. ;set up the communications line
  56.               mov    dx,1              ;for com2:
  57.               mov    al,oBBh           ;2400:E:8:1
  58.               call   cominit           ;intialize it
  59.               call   outcbuff          ;check to send it out
  60.               jc     exception         ;error?
  61.               jmp    saveloop
  62. ;
  63. ;handle exceptions
  64. exception:
  65.               cmp    ax,19             ;end of file?
  66.               je     save1             ;if so close it up and return
  67. ;
  68.               call   emessout          ;report the error
  69.               jmp    saveexit          ;and return
  70. ;
  71. ;normal return
  72. save1:
  73.               call   comoff            ;com line off
  74.               call   flushit           ;flush the buffer
  75.               jc     exception         ;error?
  76.               call   closefile         close the file
  77.               jc     exception         ;error?
  78.               jmp    saveexit          ;exit
  79. ;
  80. ;saveexit:
  81.               call   comon             ;com line on
  82.               ret
  83. ;
  84. save          endp
  85. codes         ends                     ;end code segement
  86.               end    save
  87.