home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / sampler0 / pr.asm < prev    next >
Assembly Source File  |  1985-04-20  |  9KB  |  320 lines

  1. ;
  2. ;
  3. CSEG     segment para public 'code'
  4.          assume cs:cseg,ds:cseg,ss:cseg,es:cseg
  5.          org     100h                    
  6. BEGIN:   jmp     PR_MAIN                 
  7.          COPYRIGHT       db      'PRint (C) 1985, Dickinson Associates'
  8.                          db      13,10,'$'
  9.          VALID_IN        db      '/abcdefghijklmnopqrstuvwxyz,;=',9
  10.          VALID_OUT       db      '\ABCDEFGHIJKLMNOPQRSTUVWXYZ',4 dup(32)
  11.          VALID_NUM       equ     $ - VALID_OUT + 1
  12.          FN_AREA         db      77 dup (0)
  13.          FN_LOC          dw      offset FN_AREA ;Initialize at FN_AREA
  14.          PRN             equ     4              ;PC-DOS printer device 
  15.          MAX_LINES       equ     55
  16.          MAX_CHARS       equ     80
  17.          FILE_HANDLE     dw      0
  18.          READ_LENGTH     equ     256
  19.          READ_BUFFER     db      READ_LENGTH dup (0),0
  20.          READ_PTR        dw      offset READ_BUFFER
  21.          PRINT_LENGTH    equ     256
  22.          PRINT_BUFFER    db      PRINT_LENGTH dup (0)
  23.          PRINT_PTR       dw      offset PRINT_BUFFER
  24.          EOF_FOUND       db      0
  25.          CHAR_COUNT      dw      0
  26.          LINE_COUNT      db      0
  27.          PAGE_COUNT      db      0
  28.          BIN_ASC         db      10
  29.          HEAD_1          db      13,10,13,10,'*',78 dup ('-'),'*',13,10
  30.          HEAD_2A         db      '|  File: '
  31.          HEAD_2B         db      70 dup (' '),'|',13,10
  32.          HEAD_3A         db      '| Saved: '
  33.          HEAD_3B         db      '00-00-00 at '
  34.          HEAD_3C         db      '00:00:00 '
  35.          HEAD_3D         db      '0m',39 dup (' '),'Page '
  36.          HEAD_3E         db      '00 |',13,10
  37.          HEAD_4          db      '*',78 dup ('-'),'*',13,10,13,10
  38.          HEAD_LGTH       dw      $ - HEAD_1
  39.          ERR_HEAD        db      10,13,'Print Error - $'   
  40.          NO_FILE         db      'Correct Syntax is:',13,10,10
  41.                          db      'PR [d:][path]filename[.ext]$'
  42.          FILE_NOT_FOUND  db      'File Not Found$'
  43.          OPEN_FAILURE    db      'File Open Failure$'
  44.          READ_FAILURE    db      'File Read Failure$'
  45.          ERR_TAIL        db      10,10,13,' . . . Aborting',10,13,13,'$'
  46. ;
  47. PR_MAIN          proc    near            
  48.          lea     dx,COPYRIGHT            
  49.          mov     ah,9h                   
  50.          int     21h                     
  51.          mov     si,80h                   
  52.          lea     di,FN_AREA               
  53.          mov     cl,byte ptr [si]        
  54.          xor     ch,ch                   
  55.          jcxz    NONE                     
  56.          cld                             
  57.          inc     si                      
  58.          mov     dx,0                    
  59. CLEAN:   lodsb                           
  60.          push    di                      
  61.          mov     di,offset VALID_IN      
  62.          push    cx                      
  63.          mov     cx,VALID_NUM             
  64. repne    scasb                             
  65.          jcxz    CLEAND
  66.          mov     bx,VALID_NUM
  67.          sub     bx,cx    
  68.          mov     al,VALID_OUT [bx - 1]    
  69. CLEAND:  pop     cx                      
  70.          pop     di                      
  71.          cmp     dx,1                     
  72.          je      CLEANC                   
  73.          cmp     al,' '                  
  74.          je      CLEANX                  
  75. CLEANC:  mov     dx,1                     
  76.          cmp     al,':'
  77.          je      DELIM
  78.          cmp     al,'\'
  79.          jne     DELIMX
  80. DELIM:   mov     FN_LOC,di
  81.          inc     FN_LOC
  82. DELIMX:  stosb
  83. CLEANX:  loop    CLEAN
  84.          jmp     FINDF
  85. NONE:    lea     dx,NO_FILE
  86.          jmp     EREXIT
  87. FINDF:   mov     ah,4eh
  88.          mov     cx,0
  89.          lea     dx,FN_AREA
  90.          int     21h
  91.          jnc     FOUNDF
  92.          lea     dx,FILE_NOT_FOUND
  93.          jmp     EREXIT
  94. FOUNDF:  mov     EOF_FOUND,0
  95.          mov     PAGE_COUNT,0
  96.          mov     FILE_HANDLE,0
  97.          mov     di,FN_LOC
  98.          mov     si,9eh
  99.          mov     cx,13
  100. rep      movsb
  101.          mov     ah,3dh
  102.          mov     al,0
  103.          lea     dx,FN_AREA
  104.          int     21h
  105.          mov     FILE_HANDLE,ax
  106.          jnc     DO_PR
  107.          lea     dx,OPEN_FAILURE
  108.          jmp     EREXIT
  109. DO_PR:   call    STAMP
  110.          call    PAGE_HEAD
  111.          mov     di,PRINT_PTR
  112. PRLOOP:  call    READ_FILE
  113.          jc      EREXIT
  114.          jcxz    FINISH
  115.          call    PRINT
  116.          cmp     EOF_FOUND,0
  117.          je      PRLOOP
  118. FINISH:  call    NEW_PAGE
  119.          call    CLOSE_FILE
  120.          mov     ah,4fh
  121.          mov     cx,0
  122.          int     21h
  123.          jnc     FOUNDF
  124. EXIT:    ret
  125. EREXIT:  push    dx
  126.          mov     dx,offset ERR_HEAD
  127.          mov     ah,9
  128.          int     21h
  129.          pop     dx
  130.          mov     ah,9
  131.          int     21h
  132.          mov     dx,offset ERR_TAIL
  133.          mov     ah,9
  134.          int     21h
  135.          call    CLOSE_FILE
  136.          jmp     EXIT
  137. PR_MAIN          endp
  138. READ_FILE        proc    near
  139.          mov     bx,FILE_HANDLE
  140.          mov     dx,READ_PTR
  141.          mov     cx,READ_LENGTH
  142.          mov     ah,3fh
  143.          int     21h
  144.          jnc     RD_OK
  145.          lea     dx,READ_FAILURE
  146.          jmp     EX_RD
  147. RD_OK:   cmp     cx,ax
  148.          je      NO_EOF
  149.          mov     EOF_FOUND,1
  150. NO_EOF:  mov     cx,ax
  151. EX_RD:   ret
  152. READ_FILE        endp
  153. PRINT    proc    near
  154.          mov     si,READ_PTR
  155. FORMAT:  cmp     LINE_COUNT,MAX_LINES
  156.          jb      LOAD
  157.          call    NEW_PAGE
  158.          call    PAGE_HEAD
  159. LOAD:    lodsb
  160.          cmp     al,26
  161.          je      AGAIN
  162.          cmp     al,9
  163.          jne     PUT_IT
  164.          mov     al,32
  165. TAB_X:   stosb
  166.          inc     CHAR_COUNT
  167.          test    CHAR_COUNT,7
  168.          jnz     TAB_X
  169.          jmp     WDTH
  170. PUT_IT:  stosb
  171.          inc     CHAR_COUNT
  172.          cmp     al,13
  173.          je      AGAIN
  174.          cmp     al,10
  175.          jne     FF
  176.          call    PRINT_LINE
  177.          jmp     AGAIN
  178. FF:      cmp     al,12
  179.          jne     WDTH
  180.          call    NEW_PAGE
  181.          call    PAGE_HEAD
  182.          jmp     AGAIN
  183. WDTH:    cmp     CHAR_COUNT,MAX_CHARS
  184.          jb      AGAIN
  185.          cmp     byte ptr [si],13
  186.          je      AGAIN
  187.          mov     ah,10
  188.          mov     al,13
  189.          stosw
  190.          add     CHAR_COUNT,2
  191.          call    PRINT_LINE
  192. AGAIN:   loop    FORMAT
  193.          ret
  194. PRINT    endp
  195. PRINT_LINE       proc    near
  196.          push    ax
  197.          push    cx
  198.          mov     dx,PRINT_PTR
  199.          mov     cx,CHAR_COUNT
  200.          mov     bx,PRN
  201.          mov     ah,40h
  202.          int     21h
  203.          mov     di,PRINT_PTR
  204.          mov     CHAR_COUNT,0
  205.          inc     LINE_COUNT
  206.          pop     cx
  207.          pop     ax
  208.          ret
  209. PRINT_LINE       endp
  210. NEW_PAGE         proc    near
  211.          cmp     al,12
  212.          je      FF_OK
  213.          mov     al,12
  214.          stosb
  215.          inc     CHAR_COUNT
  216. FF_OK:   call    PRINT_LINE
  217.          mov     LINE_COUNT,0
  218.          ret
  219. NEW_PAGE         endp
  220. PAGE_HEAD        proc    near
  221.          push    di
  222.          inc     PAGE_COUNT
  223.          mov     al,PAGE_COUNT
  224.          lea     di,HEAD_3E
  225.          call    BIN_2_ASC
  226.          pop     di
  227.          cmp     HEAD_3E[0],'0'
  228.          jne     NOT_0
  229.          mov     HEAD_3E[0],' '
  230. NOT_0:   push    cx
  231.          mov     ah,40h
  232.          mov     bx,PRN
  233.          lea     dx,HEAD_1
  234.          mov     cx,HEAD_LGTH
  235.          int     21h
  236.          pop     cx
  237.          ret
  238. PAGE_HEAD        endp
  239. STAMP            proc    near
  240.          lea     si,FN_AREA
  241.          lea     di,HEAD_2B
  242.          mov     cx,70
  243. LD_FN1:  lodsb
  244.          cmp     al,0
  245.          je      LD_FN2
  246.          stosb
  247.          loop    LD_FN1
  248.          jcxz    DATE
  249. LD_FN2:  mov     al,32
  250. rep      stosb
  251. DATE:    mov     si,98h
  252.          lea     di,HEAD_3B
  253.          lodsw
  254.          mov     bx,ax
  255.          and     ax,01e0h
  256.          mov     cl,5
  257.          shr     ax,cl
  258.          call    BIN_2_ASC
  259.          mov     ax,bx
  260.          and     ax,1fh
  261.          inc     di
  262.          call    BIN_2_ASC
  263.          mov     ax,bx
  264.          and     ax,0fe00h
  265.          shr     ah,1
  266.          add     ah,80
  267.          mov     al,ah
  268.          inc     di
  269.          call    BIN_2_ASC
  270. TIME:    mov     si,96h
  271.          lea     di,HEAD_3C
  272.          lodsw
  273.          mov     bx,ax
  274.          and     ax,0f800h
  275.          mov     cl,11
  276.          shr     ax,cl
  277.          mov     HEAD_3D[0],'a'
  278.          cmp     al,12
  279.          jb      AM_OK
  280.          je      PM_OK
  281.          sub     al,12
  282. PM_OK:   mov     HEAD_3D[0],'p'
  283. AM_OK:   call    BIN_2_ASC
  284.          mov     ax,bx
  285.          and     ax,7e0h
  286.          mov     cl,5
  287.          shr     ax,cl
  288.          inc     di
  289.          call    BIN_2_ASC
  290.          mov     ax,bx
  291.          and     ax,1fh
  292.          inc     di
  293.          call    BIN_2_ASC
  294.          ret
  295. STAMP    endp
  296. BIN_2_ASC        proc    near
  297.          cbw
  298.          div     BIN_ASC
  299.          add     al,48
  300.          stosb
  301.          add     ah,48
  302.          mov     al,ah
  303.          stosb
  304.          ret
  305. BIN_2_ASC        endp
  306. CLOSE_FILE       proc    near
  307.          cmp     FILE_HANDLE,0
  308.          je      CLOSEX
  309.          mov     bx,FILE_HANDLE
  310.          mov     ah,3eh
  311.          int     21h
  312. CLOSEX:  ret
  313. CLOSE_FILE       endp
  314. CSEG     ends
  315.          end     BEGIN
  316.  
  317.  
  318.  
  319.