home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / sounds.zip / UNWS.ASM < prev    next >
Assembly Source File  |  1983-04-04  |  9KB  |  193 lines

  1.  
  2. TITLE NWS - ASSEMBLER PROGRAM TO STRIP HI-ORDER BITS FROM WORDSTAR FILES
  3. SUBTTL DESCRIPTION OF THE STACK SEGMENT
  4.         PAGE
  5. STACK   SEGMENT PARA STACK 'STACK'
  6.         DB      64 DUP('STACK   ')
  7. STACK   ENDS
  8. SUBTTL DESCRIPTION OF THE DATA SEGMENT
  9.         PAGE
  10. WORKAREA SEGMENT PARA PUBLIC 'DATA'
  11. LOGO    DB      '       ***********************************************************************',10,13
  12.         db      '       *                                                                     *',10,13
  13.         db      '       *                        UN - Wordstar                                *',10,13
  14.         db      '       *   A program to remove the high-order bits from Wordstar data        *',10,13
  15.         db      '       *   files.  You are prompted for the input and output file names.     *',10,13
  16.         db      '       *                                                                     *',10,13
  17.         db      '       *     Written as an assembler language example by Gene Plantz         *',10,13
  18.         db      '       ***********************************************************************',10,10,10,10,13,'$'
  19. donem   db      '-------->    DONE    <-------------',10,13,'$'
  20. eofflag db      0
  21. crlf    db      10,13,'$'       ;issue carriage return-linefeed after input
  22. fcb1    db      40 dup(0)       ;input file  only needs to be 36 (but safe)
  23. fcb2    db      40 dup(0)       ;file control block for output
  24. err0    db      7,7,'--->  ERROR Opening INPUT file  <--------',10,13,'$'
  25. err1    db      7,7,'--->  ERROR.. not enough disk space for output <---',10,13,'$'
  26. err2    db      7,7,'--->  ERROR.... bad file name given. <----',10,13,'$'
  27. parms   db      14              ;max size of reply
  28. repson  db      ?               ;size of what they typed
  29. name1   db      20  dup(' ')    ;this is where the users reply goes
  30. parms2  db      14              ;max size of input
  31. resp2   db      ?               ;size of what they really typed in
  32. name2   db      20  dup(' ')    ;this is where the reply goes
  33. ask1    db      10,10,13,'Please Enter the name of the input file    $'
  34. ask2    db      'Please Enter the name of the output file   $'
  35. buffer  db      128 dup(' ')            ;record  buffer
  36. workarea ends
  37. ;
  38. subttl desciption of dos interfaces
  39. cseg    segment para public 'CODE'
  40. start   proc    far
  41.         assume cs:cseg,ds:workarea,ss:stack,es:workarea
  42.         org     100h
  43.         push    ds                      ;set up starting linkage as per dxample
  44.         sub     ax,ax                   ;zero this and place on stack
  45.         push    ax                      ;so that when we do a RET we go to 
  46.         mov     ax,workarea             ;location 0;  point to our workarea
  47.         mov     ds,ax                   ;move the workarea address into DS
  48.         mov     es,ax                   ;also into ES for the function 29H
  49.         call    cls                     ;call subroutine to clear the screen
  50.         mov     dh,3                    ;set cursor to row 8
  51.         mov     dl,0                    ;set cursor to column 0
  52.         mov     bh,0                    ;use screen number 0
  53.         mov     ah,2                    ;function 2 to locate cursor
  54.         int     10h                     ; go do it
  55.         mov     dx,offset logo          ;display the logo where we put cursor
  56.         mov     ah,9                    ;function 9 is print string
  57.         int     21h                     ;call dos to do it
  58. ;
  59.         mov     dx,offset ask1          ;point to message to display
  60.         mov     ah,9                    ;tell DOS what function (print string)
  61.         int     21h                     ;call DOS
  62. ;
  63.         mov     dx,offset parms         ;point to console input buffer
  64.         mov     ah,10                   ;read console buffer
  65.         int     21h                     ;do it
  66. ;
  67.         mov     si,offset name1         ;put address of name1 into SI
  68.         mov     di,offset fcb1          ;put address of file control block DI
  69.         mov     ah,29h                  ;tell DOS to parse filename
  70.         int     21h                     ;do it
  71. ;
  72.         mov    dx,offset crlf           ;do a carriage return-line feed
  73.         mov     ah,9                    ;after the reply 
  74.         int     21h                     ;to DOS
  75. ;
  76.         mov     al,[di+1]               ;if DI+1 = blank, no file name
  77.         cmp     al,20h                  ;if blank, error
  78.         jnz     isok
  79.         jmp     error2
  80. ;
  81. isok:
  82.         mov     dx,offset ask2          ;ask user for name of new file
  83.         mov     ah,9                    ;display question
  84.         int     21h                     ;DOS
  85. ;
  86.         mov     dx,offset parms2        ;put address of input buffer into DX
  87.         mov     ah,10                   ;get input from user
  88.         int     21h                     ;DOS
  89. ;
  90.         mov     dx,offset crlf          ;another cr,lf
  91.         mov     ah,9
  92.         int     21h
  93. ;
  94.         mov     si,offset name2         ;SI = address of field NAME2
  95.         mov     di,offset fcb2          ;DI = address of second file control 
  96.         mov     ah,29h                  ;ask DOS to parse filename
  97.         int     21h                     ;DOS
  98. ;
  99.         mov     al,[di+1]               ;if DI+1 = blank, error
  100.         cmp     al,20h                  ;is it blank??        jz      error2                  ;tell him and leave     yyyyy
  101. ;
  102.         mov     dx,offset fcb1          ;point to first fcb
  103.         mov     ah,15                   ;open the input file
  104.         int     21h                     ;call dos to do it 
  105. ;
  106.         cmp     al,0                    ;see if ok
  107.         jnz     error0                  ;tell him and leave
  108. ;
  109.         mov     dx,offset fcb2          ;address of fcb2
  110.         mov     ah,16h                  ;create out put file
  111.         int     21h                     ;this does open, too
  112. ;
  113.         mov     dx,offset buffer        ;point to out record buffer
  114.         mov     ah,1ah                  ;tell DOS to put disk data there
  115.         int     21h                     ;DOS
  116. ;
  117. readl:  cmp     eofflag,1               ;see if end-of-file was reached
  118.         jz      closeall                ;yes, wrap it up and leave
  119.         mov     dx,offset fcb1          ;read from file 1
  120.         mov     ah,14h                  ;sequential read from disk
  121.         int     21h                     ;DOS
  122. ;
  123.         cmp     al,0                    ;see if normal return
  124.         jz      readok                  ;if zero, ok
  125.         mov     eofflag,1               ;no, set end-of-file flag
  126.         jmp     readl                   ;back to read
  127. ;
  128. readok: 
  129.         mov     cx,128                  ;size of logical record
  130.         mov     si,offset buffer        ;SI = address of our buffer
  131. andloop:
  132.                                         ;these 3 lines were used because
  133.                                         ;   AND [SI],7FH    wouldn't assemble
  134.                                         ;
  135.         mov     al,[si]                 ;and out the hi-bit 
  136.         and     al,7fh
  137.         mov     [si],al                 ;put it back
  138. ;
  139.         inc     si                      ;bump pointer to next char in buffer
  140.         loop    andloop                 ;do it 128 times (in CX)
  141. ;
  142.         mov     dx,offset fcb2          ;point to output fcb
  143.         mov     ah,15h                  ;sequential write
  144.         int     21h
  145.         cmp     al,1                    ;this means disk full
  146.         jz      error1
  147. ;
  148.         jmp     readl                   ;do it again
  149. ;
  150. closeall:
  151.         mov     dx,offset fcb2          ;close output file
  152.         mov     ah,10h          
  153.         int     21h
  154. ;
  155.         mov     dx,offset donem         ;iisue DONE message
  156.         mov     ah,9
  157.         int     21h
  158.         jmp     exit
  159. ;
  160. error2: mov     dx,offset err2          ;err mess 2
  161.         jmp     errorm
  162. error1: mov     dx,offset err1          ;point to error mess number 1
  163.         jmp     errorm
  164. error0: mov     dx,offset err0
  165. errorm:
  166.         mov     ah,9                    ;print it
  167.         int     21h
  168.         jmp     closeall
  169. exit:   ret
  170. start   endp
  171. ;
  172. ;
  173. subttl clear screen routine
  174. cls     proc    near
  175.         mov     cx,0
  176.         mov     dx,2479h
  177.         mov     bh,7
  178.         mov     ax,600h
  179.         int     10h
  180.         ret
  181. cls     endp
  182. ;
  183. ;
  184. cseg    ends
  185.         end     start
  186. 65399 '** DONE - PRESS ENTER TO RETURN TO MENU **
  187.  10h
  188.         ret
  189. cls     endp
  190. ;
  191. ;
  192. cseg    ends
  193.