home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / CONV14.ASM < prev    next >
Assembly Source File  |  1994-10-31  |  1KB  |  53 lines

  1.     page    66,132
  2. ;******************************** CONV14.ASM *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12.  
  13. comment 
  14. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( CONVERT )
  15. ;DEC_STR1_TO_DWORD -  convert unsigned ascii string to binary DWORD
  16. ;
  17. ; inputs  ds:si points    at string ending with zero
  18. ;         direction flag = CLD state
  19. ; output  bx,dx = binary value
  20. ;       si = updated to point at end of value
  21. ;       al = 0 if success
  22. ;* * * * * * * * * * * * * *
  23. 
  24.     extrn    DMUL_10_PLUS:FAR
  25.     public    DEC_STR1_TO_DWORD
  26. DEC_STR1_TO_DWORD    proc    far
  27.     xor    ah,ah               ;
  28.     xor    dx,dx            ;running sum = 0
  29.     xor    bx,bx            ;running sum = 0
  30. ;
  31. ; remove blanks in front of number
  32. ;
  33. sb11:    lodsb
  34.     cmp    al,' '
  35.     je    sb11            ;remove leading spaces
  36.  
  37. sb12:    or    al,al
  38.     jz    sb5_done        ;jmp if done, end of string
  39.     sub    al,'0'
  40.     js    sb5_done        ;jmp if error, not number
  41.     cmp    al,9
  42.     ja    sb5_done        ;jmp if error, not number
  43.  
  44.     call    dmul_10_plus        ;compute (dx,ax) * 10 + bx
  45.     jnc    sb11            ;jmp if no errors
  46. sb5_done:
  47.     RETF
  48. DEC_STR1_TO_DWORD ENDP
  49.  
  50. LIBSEG    ENDS
  51.     end
  52.