home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / OKTIMDAT.ZIP / SI2VAL.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-10-29  |  1.7 KB  |  41 lines

  1. Title   SI2Val.ASM -- Get Values from DS:SI String
  2. COMMENT ~
  3.         Call With:  DS:SI = Pointer to String
  4.                        BP = String Bytes Left
  5.  
  6.         Returns:    DS:SI = Advanced
  7.                        BP = Bytes Left
  8.                        AX = HEX Value
  9.                 Zero Flag reflects Value
  10.                 Other Registers Preserved
  11.         ~
  12.         .MODEL  small
  13.         .CODE
  14.             PUBLIC  SI2Val
  15. SI2Val  Proc
  16.         push    bx                      ; Preserve
  17.         push    cx                      ; Registers
  18.         xor     bx,bx                   ; Zero Result and
  19.         mov     cx,10                   ; Set Multiplier
  20. ParSIL: dec     bp                      ; If NO More Bytes
  21.         jl      ParSIE                  ; then String Ended
  22.         lodsb                           ; else if
  23.         cmp     al,"0"                  ; byte < "0"
  24.         jc      ParSIX                  ; or if byte
  25.         cmp     al,"9"+1                ; NOT <= "9"
  26.         jnc     ParSIX                  ; then exit
  27.         xor     ah,ah                   ; else make
  28.         sub     al,"0"                  ; word value
  29.         xchg    ax,bx                   ; Adjust Last
  30.         mul     cl                      ; Place and
  31.         add     bx,ax                   ; accumulate
  32.         jmp     SHORT ParSIL            ; until finished
  33. ParSIE: xor     bp,bp                   ; Zero Bytes Left
  34. ParSIX: mov     ax,bx                   ; Get Result
  35.         pop     cx                      ; Restore
  36.         pop     bx                      ; Registers
  37.         or      ax,ax                   ; Test Result
  38.         ret
  39. SI2Val  Endp
  40.         END
  41.