home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / tasm / oprcbyte.asm < prev    next >
Assembly Source File  |  1988-08-28  |  3KB  |  111 lines

  1.  
  2. ;    FILENAME: OPRCBYTE.ASM
  3. ;    Copyright (c) 1988 by Borland International, Inc.
  4. ;
  5. ;    Description: This module implements the routine ProcByte. ProcByte
  6. ;    processes a byte.
  7. ;    This module uses MASM mode syntax and standard segment directives. 
  8. ;    ASSEMBLY INSTRUCTIONS: To assemble this module use the following 
  9. ;    TASM command line. 
  10. ;        TASM oprcbyte
  11.  
  12. include globals.inc
  13.  
  14. _TEXT   segment
  15.  
  16.     ProcByte proc
  17.  
  18.     ;    This procedure processes an ASCII character. 
  19.     ;    ProcByte performs the following tasks
  20.     ;       reads the byte
  21.     ;       determines the type of character
  22.     ;       and checks whether or not an error has occurred
  23.     ;
  24.     ;    Input 
  25.     ;       al - an ASCII character
  26.     ;       di - the buffer location
  27.     ;       InpBlk - input control block
  28.     ;       InpBuf - input buffer
  29.     ;       cx - bytes in the buffer
  30.     ;       Options - the options being used
  31.     ;       STR_BIT - constant set to strip high bits
  32.     ;       INP_EOF - designates the end of the input file
  33.     ;       InpSta - input status
  34.     ;       INP_ERR - constant set to designate an input error
  35.     ;       INP_EOL - constant set to designate an end-of-line condition
  36.     ;    Output 
  37.     ;       di - the buffer is updated
  38.     ;       cx - updated
  39.     ;       ax - byte processed
  40.     ;    Registers modified 
  41.     ;       ax
  42.  
  43.     ;--- read byte
  44.  
  45.     push    cx
  46.     push    di
  47.     lea     bx, InpBlk      ;input control block
  48.     mov     cx, 1           ;bytes to read
  49.     lea     di, InpBuf      ;input buffer
  50.     call    FileRead        ;read byte
  51.     pop     di
  52.     pop     cx
  53.     jc      probyt5         ;jump if error or EOF
  54.  
  55.     ;--- check type of character
  56.  
  57.     mov     al, InpBuf      ;load byte
  58. probyt1:
  59.     cmp     al, 32
  60.     jb      probyt2
  61.     cmp     al, 127
  62.     ja      probyt3
  63.  
  64.     ;--- normal byte, 31 < AL < 128
  65.  
  66.     call    ByteNorm
  67.     ret
  68.  
  69.     ;--- low byte, AL < 32
  70.  
  71. probyt2:
  72.     call    ByteLow
  73.     ret
  74.  
  75.     ;--- high byte, AL > 127
  76.  
  77. probyt3:
  78.     test    Options, STR_BIT ;check if strip high bit
  79.     jnz     probyt4
  80.     call    ByteHigh
  81.     ret
  82.  
  83. probyt4:
  84.     and     al, 7fh         ;clear bit
  85.     jmp     probyt1         ;loop back
  86.  
  87.     ;--- error reading
  88.  
  89. probyt5:
  90.     cmp     ax, 0           ;check if EOF
  91.     jne     probyt7
  92.     or      InpSta, INP_EOF ;set end of file flag
  93.     or      cx, cx          ;check if any bytes remaining
  94.     jz      probyt6
  95.     or      InpSta, INP_EOL ;set end of line also
  96. probyt6:
  97.     ret
  98.     ret
  99.  
  100. probyt7:
  101.     or      InpSta, INP_ERR ;set error flag
  102.     ret
  103.  
  104.     ProcByte endp
  105.  
  106. _TEXT    ends
  107.  
  108. end
  109.