home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.folklore.computers
- 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
- From: stevev@miser.uoregon.edu (Steve VanDevender)
- Subject: Re: Sync Three Times...
- In-Reply-To: john@gu.uwa.edu.au's message of 20 Nov 1992 14:19:07 GMT
- Message-ID: <STEVEV.92Nov22235456@miser.uoregon.edu>
- Sender: news@nntp.uoregon.edu
- Organization: University of Oregon Chemistry Stores
- References: <Bxypzx.L4p@NeoSoft.com> <1eis4rINNfni@uniwa.uwa.edu.au>
- Date: 22 Nov 92 23:54:56
- Lines: 42
-
- In article <1eis4rINNfni@uniwa.uwa.edu.au> john@gu.uwa.edu.au
- (John West) writes:
-
- peter@NeoSoft.com (Peter da Silva) writes:
-
- >There's always the old bit-rot stuff. Lots of debugging techniques (just
- >try recompiling it) are practically superstitious...
-
- Or if you've got a 6502, and the program doesn't work, flip random BCx
- instructions. Unless, of course, you are one of the three people in this
- world who can actually remember whether its BCS or BCC for 'greater or
- equal'.
-
- Oh, come on. It's easy.
-
- If you have a number m in A, and you do a CMP with value n, then
- the carry depends on the value of m - n. Since we're using
- two's-complement arithmetic, then think of the value as instead
- being m + 2^8 - n (assuming 8-bit values; this is, after all, a
- 6502). If m - n is less than 0, then there will be no carry out.
- If m - n is greater than or equal to zero, then there _will_ be a
- carry out. Therefore, if m >= n, the carry will be set after the
- CMP. So BCS could be aliased to BGE.
-
- Motorola is kind enough to include many more conditional branches
- in their processors (at least the 6800 and 68000) _and_ document
- the logic formulas used on the condition code bits to determine
- whether a condition is true.
-
- You can get by with just a carry flag in a processor using
- two's-complement arithmetic. You can test if a number is
- non-zero by adding a word of all ones -- if true, the carry flag
- will be set. cjl can undoubtedly describe many other tricks,
- including his favorite method of testing for a value in a given
- range using only one conditional branch, which uses only a test
- of the carry flag (of course, this makes it easy to do on a
- PDP-8).
- --
- Steve VanDevender stevev@greylady.uoregon.edu
- "Bipedalism--an unrecognized disease affecting over 99% of the population.
- Symptoms include lack of traffic sense, slow rate of travel, and the
- classic, easily recognized behavior known as walking."
-