home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / bluebook / asm-subr / dechalf < prev    next >
Encoding:
Text File  |  1985-12-27  |  1.5 KB  |  59 lines

  1. ;-------------------------dechalf routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 101
  4. ;
  5. ; NAME  DECHALF
  6. ;
  7. ; ROUTINE FOR Halving A Temporary Decimal Floating Point Number
  8. ;
  9. ; FUNCTION: This routine divides a temporary decimal floating point number
  10. ; by two.
  11. ;
  12. ; INPUT: Upon input DI points to a temporary decimal floating point number.
  13. ;
  14. ; OUTPUT: Upon exit the number has been divided by two.
  15. ;
  16. ; REGISTERS USED:  AX, CX and DI are modified.
  17. ;
  18. ; SEGMENTS REFERENCED:  The data segment contains a temporary decimal
  19. ; floating point number.
  20. ;
  21. ; ROUTINES CALLED:  None
  22. ;
  23. ; SPECIAL NOTES: This is a NEAR routine called by FPOUT.
  24. ;
  25. ; ROUTINE TO DIVIDE TEMPORARY FP DECIMAL NUMBER BY 2 - RESULT NOT HALVED.
  26. ;
  27. dechalf    proc    near
  28. ;
  29. ; first shift up one digit
  30.     mov    cx,25        ; for a count of 25
  31.     mov    al,0        ; zero previous byte
  32. ;
  33. dechalf1:
  34.     xchg    al,[di]        ; exchange with current digit
  35.     inc    di        ; point to next digit
  36.     loop    dechalf1
  37. ;
  38.     dec    decexp        ; decrement decimal digit
  39. ;
  40. ; now divide by two
  41.     mov    cx,25        ; for a count of 25
  42.     mov    ah,0        ; clear
  43. ;
  44. dechalf2:
  45.     push    cx        ; save count
  46.     dec    di        ; point to next digit
  47.     mov    al,[di]        ; get the digit
  48.     mov    cl,2        ; divisor of 2
  49.     aad            ; adjust for division
  50.     div    cl        ; divide
  51.     mov    [di],al        ; put back
  52.     pop    cx        ; restore count
  53.     loop     dechalf2
  54. ;
  55.     ret            ; return
  56. ;
  57. dechalf    endp
  58. ;-------------------------dechalf routine ends---------------------------+
  59.