home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / alt / folklore / computer / 16635 < prev    next >
Encoding:
Text File  |  1992-11-22  |  2.5 KB  |  55 lines

  1. Newsgroups: alt.folklore.computers
  2. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!rpi!batcomputer!reed!henson!news.u.washington.edu!news.uoregon.edu!nntp.uoregon.edu!nntp.uoregon.edu!stevev
  3. From: stevev@miser.uoregon.edu (Steve VanDevender)
  4. Subject: Re: Sync Three Times...
  5. In-Reply-To: john@gu.uwa.edu.au's message of 20 Nov 1992 14:19:07 GMT
  6. Message-ID: <STEVEV.92Nov22235456@miser.uoregon.edu>
  7. Sender: news@nntp.uoregon.edu
  8. Organization: University of Oregon Chemistry Stores
  9. References: <Bxypzx.L4p@NeoSoft.com> <1eis4rINNfni@uniwa.uwa.edu.au>
  10. Date: 22 Nov 92 23:54:56
  11. Lines: 42
  12.  
  13. In article <1eis4rINNfni@uniwa.uwa.edu.au> john@gu.uwa.edu.au
  14. (John West) writes:
  15.  
  16.    peter@NeoSoft.com (Peter da Silva) writes:
  17.  
  18.    >There's always the old bit-rot stuff. Lots of debugging techniques (just
  19.    >try recompiling it) are practically superstitious...
  20.  
  21.    Or if you've got a 6502, and the program doesn't work, flip random BCx
  22.    instructions. Unless, of course, you are one of the three people in this
  23.    world who can actually remember whether its BCS or BCC for 'greater or
  24.    equal'.
  25.  
  26. Oh, come on.  It's easy.
  27.  
  28. If you have a number m in A, and you do a CMP with value n, then
  29. the carry depends on the value of m - n.  Since we're using
  30. two's-complement arithmetic, then think of the value as instead
  31. being m + 2^8 - n (assuming 8-bit values; this is, after all, a
  32. 6502).  If m - n is less than 0, then there will be no carry out.
  33. If m - n is greater than or equal to zero, then there _will_ be a
  34. carry out.  Therefore, if m >= n, the carry will be set after the
  35. CMP.  So BCS could be aliased to BGE.
  36.  
  37. Motorola is kind enough to include many more conditional branches
  38. in their processors (at least the 6800 and 68000) _and_ document
  39. the logic formulas used on the condition code bits to determine
  40. whether a condition is true.
  41.  
  42. You can get by with just a carry flag in a processor using
  43. two's-complement arithmetic.  You can test if a number is
  44. non-zero by adding a word of all ones -- if true, the carry flag
  45. will be set.  cjl can undoubtedly describe many other tricks,
  46. including his favorite method of testing for a value in a given
  47. range using only one conditional branch, which uses only a test
  48. of the carry flag (of course, this makes it easy to do on a
  49. PDP-8).
  50. --
  51. Steve VanDevender     stevev@greylady.uoregon.edu
  52. "Bipedalism--an unrecognized disease affecting over 99% of the population.
  53. Symptoms include lack of traffic sense, slow rate of travel, and the
  54. classic, easily recognized behavior known as walking."
  55.