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

  1.  
  2. ;    FILENAME: OCMDNUM.ASM
  3. ;    Copyright (c) 1988 by Borland International, Inc.
  4. ;
  5. ;    Description: This module implements the routine CmdNum. CmdNum  
  6. ;    parses the command line. 
  7. ;  
  8. ;    ASSEMBLY INSTRUCTIONS:  To assemble this module use the following   
  9. ;    TASM command line.      
  10. ;   
  11. ;        TASM ocmdnum
  12.  
  13. include globals.inc
  14.  
  15. _TEXT   segment
  16.  
  17.     CmdNum proc
  18.  
  19.     ;    This function reads in a command line number.
  20.     ;    The command line number is returned in cx
  21.     ;    Input 
  22.     ;        si - address of start of command line
  23.     ;    Output
  24.     ;        command processed
  25.     ;        cx - command line number
  26.     ;    Registers modified
  27.     ;        ax, bx, cx
  28.  
  29.     sub     cx, cx
  30.  
  31. cmdnum1:
  32.     cmp     bx, si              ;check if done
  33.     je      cmdnum2
  34.     cmp     BYTE PTR [si], '0'  ;check if below zero
  35.     jb      cmdnum2
  36.     cmp     BYTE PTR [si], '9'  ;check if above nine
  37.     ja      cmdnum2
  38.  
  39.     mov     ax, 10              ;base ten
  40.     mul     cx                  ;multiply
  41.     jc      cmdnum3             ;jump if overflow
  42.     mov     cx, ax              ;back into total
  43.     lodsb                       ;load number
  44.     sub     al, '0'             ;convert to binary
  45.     sub     ah, ah
  46.     add     cx, ax              ;add to total
  47.     jmp     cmdnum1
  48.  
  49.     ;--- finished
  50.  
  51. cmdnum2:
  52.     ret
  53.  
  54.     ;--- overflow
  55.  
  56. cmdnum3:
  57.     mov     al, 0               ;error number
  58.     call    ErrorExit           ;call error routine
  59.     CmdNum endp
  60.  
  61. _TEXT    ends
  62.  
  63. end
  64.