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

  1.     page    66,132
  2. ;******************************** CONV03.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_STR2_TO_DWORD -  convert unsigned ascii string to binary DWORD
  16. ;
  17. ; inputs  ds:si = string ptr
  18. ;            cx = string length
  19. ; output  bx,dx = binary value
  20. ;       si = updated to point at end of value
  21. ;       al = zero if success
  22. ;* * * * * * * * * * * * * *
  23. 
  24.     extrn    dmul_10_plus:far
  25.     public    DEC_STR2_TO_DWORD
  26. DEC_STR2_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. sb13:    lodsb
  34.     dec    cx
  35.     cmp    al,' '
  36.     je    sb13            ;remove leading spaces
  37.  
  38. sb14:    sub    al,'0'
  39.     js    sb6_done        ;jmp if error, not number
  40.     cmp    al,9
  41.     ja    sb6_done        ;jmp if error, not number
  42.  
  43.     call    dmul_10_plus        ;compute (dx,ax) * 10 + bx
  44.     jcxz    sb6_done        ;jmp if done
  45.     jnc    sb13            ;jmp if no errors
  46. sb6_done:
  47.     RETF
  48. DEC_STR2_TO_DWORD    endp
  49.  
  50. LIBSEG    ENDS
  51.     end
  52.