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

  1.     PAGE    66,132
  2. ;******************************** MATH01.ASM *********************************
  3. LIBSEG           segment byte public "LIB"
  4.         assume cs:LIBSEG , ds:nothing
  5. ;----------------------------------------------------------------------------
  6.  
  7.  
  8. comment 
  9. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  MATH   )
  10. ; dmul_10_plus - multiply times ten and add update value
  11. ;  inputs:  dx,bx = current sum
  12. ;              ax = update value to add to new sum
  13. ;  output:  dx,bx = result of (dx,bx) * (10) + ax
  14. ;           carry set if overflow
  15. ;* * * * * * * * * * * * * *
  16. 
  17.     public    dmul_10_plus
  18. dmul_10_plus    proc    far
  19.     push    cx
  20.  
  21.     shl    bx,1
  22.     rcl    dx,1        ;sum * 2 -> dx,bx
  23.     push    dx
  24.     push    bx
  25.  
  26.     shl    bx,1
  27.     rcl    dx,1        ;dx,bx = sum * 4
  28.     shl    bx,1
  29.     rcl    dx,1        ;dx,bx = sum * 8
  30.  
  31.     pop    cx        ;get low word of (sum * 2)
  32.     add    bx,cx
  33.     pop    cx        ;get high word of (sum * 2)
  34.     adc    dx,cx        ;dx,bx = sum * 10
  35.     jc    dmul_err    ;jmp if overflow
  36.  
  37.     add    bx,ax        ;add in ax
  38.     adc    dx,0
  39. dmul_err:
  40.     pop    cx
  41.     retf
  42. dmul_10_plus    endp    
  43.  
  44. LIBSEG    ENDS
  45.     end
  46.