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

  1.  
  2. ;    FILENAME: OBYTENRM.ASM
  3. ;    Copyright (c) 1988 by Borland International, Inc.
  4. ;
  5. ;    Description: This module implements the routine ByteNorm. ByteNorm
  6. ;    processes the current normal byte value in al.
  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 obytenrm
  11.  
  12. include globals.inc
  13.  
  14. _TEXT   segment
  15.  
  16.     ByteNorm proc
  17.  
  18.     ;    This procedure processes a normal byte character 
  19.     ;    (31 < ASCII value < 128) in al.
  20.     ;
  21.     ;    Input 
  22.     ;       al - normal byte character
  23.     ;       EOL -  defined to be the end of line character
  24.     ;       InpSta - input status
  25.     ;       INP_EOL - designates an end-of-line condition
  26.     ;       Options - the options being used
  27.     ;       REP_SPC - replace spaces with tabs
  28.     ;       SpcCnt - space count (for compressing spaces)
  29.     ;       TabOff - tab offset (decrements the tab column number)
  30.     ;       MAK_LWR - designates character is to be shifted to lower-case
  31.     ;       MAK_UPR - designates character is to be shifted to upper-case
  32.     ;       MAK_CAP - designates character is to be capitalized
  33.     ;       LAS_LET - designates the last character was a letter
  34.     ;
  35.     ;    Output 
  36.     ;       al - normal byte processed
  37.     ;       cx - byte count incremented
  38.     ;    Registers modified 
  39.     ;       ax, cx
  40.  
  41.  
  42.     ; Process normal byte.
  43.  
  44.     ;--- end of line
  45.  
  46.     cmp      al, EOL         ;check if end of line
  47.     jne      bytnor1
  48.     or       InpSta, INP_EOL
  49.     ret
  50.  
  51.     ;--- replace spaces with tabs
  52.  
  53. bytnor1:
  54.     test     Options, REP_SPC ;test if replace spaces
  55.     jz       bytnor4
  56.  
  57.     ;------ write tab stop
  58.  
  59.     call     TabNext        ;get next tab stop
  60.     jnc      bytnor2        ;jump if not at stop
  61.     call     StoreTab       ;store a tab
  62.  
  63.     ;------ space
  64.  
  65. bytnor2:
  66.     cmp      al, ' '         ;check if really space
  67.     jne      bytnor3         ;jump if not
  68.     inc      SpcCnt          ;increment space count
  69.     inc      TabOff          ;increment column
  70.     ret
  71.  
  72.     ;------ non-space
  73.  
  74. bytnor3:
  75.     call     StoreSpc        ;store any spaces
  76.  
  77.     ;--- convert to lower case
  78.  
  79. bytnor4:
  80.     test     Options, MAK_LWR ;test if make lower-case
  81.     jz       bytnor5
  82.     call     LoCase
  83.     stosb
  84.     inc      cx
  85.     ret
  86.  
  87.     ;--- convert to upper case
  88.  
  89. bytnor5:
  90.     test     Options, MAK_UPR ;test if make upper-case
  91.     jz       bytnor6
  92.     call     UpCase
  93.     stosb
  94.     inc      cx
  95.     ret
  96.  
  97.     ;--- capitalize
  98.  
  99. bytnor6:
  100.     test     Options, MAK_CAP ;test if capitalize
  101.     jz       bytnor8
  102.     test     InpSta, LAS_LET ;check if last character was letter
  103.     jz       bytnor7
  104.     call     LoCase
  105.     stosb
  106.     inc      cx
  107.     ret
  108.  
  109. bytnor7:
  110.     call     UpCase
  111.     stosb
  112.     inc      cx
  113.     ret
  114.  
  115.     ;--- write byte
  116.  
  117. bytnor8:
  118.     stosb
  119.     inc      cx
  120.     ret
  121.     ByteNorm endp
  122.  
  123. _TEXT    ends
  124.  
  125. end
  126.