home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Bug_Fixes / Net.v7bugs / 0017 < prev    next >
Encoding:
Text File  |  1981-05-21  |  1.4 KB  |  31 lines

  1. Autzoo.643
  2. NET.v7bugs
  3. utzoo!henry
  4. Thu May 21 20:22:51 1981
  5. ldiv/lrem on 44,23
  6. The V7 long-int divide and remainder routines, as distributed by Bell,
  7. make an invalid assumption about the DIV instruction on the 11.  DIV
  8. aborts if the quotient is too big for a signed 16-bit number;  the
  9. routines assume that the dividend register pair is untouched afterwards.
  10. This was generally true on early 11's, but Dec has never guaranteed it
  11. and it is NOT TRUE on the 11/44.  111111111 [that's nine 1's] % 10 yields 11.
  12.  
  13. The fix is fairly easy;  it's the same fix for all six occurrences: the 
  14. libc ldiv, lrem, aldiv, and alrem, and the kernel ldiv and lrem in mch.s .
  15. Look for a DIV followed by a BVC.  If the BVC falls through, r0 and r1
  16. must be put back as they were before the DIV.  Specifically:
  17.  
  18.     1. Before DIV, add "mov r0,-(sp)".
  19.     2. After BVC, add "mov r2,r1" and "mov (sp),r0".
  20.     3. After label "1", about 6 lines down, add "tst (sp)+".
  21.  
  22. The fixed-up routines function properly whether the particular cpu manifests
  23. the problem or not, so this fix can be universally applied.
  24.  
  25. This also may have cured the largest-negative-dividend bug that the
  26. V7-addenda-tape README alludes to;  at least, I can't reproduce said bug.
  27.  
  28. Another local installation has discovered that similar divide anomalies
  29. occur on the 11/23 and can be cured with the same fixes.  I do not have
  30. a test case for the 23;  111111111%10 works fine on it.
  31.