Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!zaphod.mps.ohio-state.edu!ncar!unmvax!uservx.afwl.af.mil!galetti From: galetti@uservx.afwl.af.mil Newsgroups: comp.sys.mac.programmer Subject: Re: 68000 Assembly question -- overflow Message-ID: <1991May29.164914.22930@uservx.afwl.af.mil> Date: 29 May 91 16:49:14 GMT References: <12423.284125F3@stjhmc.fidonet.org> Organization: Phillips Laboratory - Kirtland AFB Lines: 54 In article <12423.284125F3@stjhmc.fidonet.org>, Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) writes: > Seth Tisue writes in a message to All > > ST> Thanks to everyone who straightened me out on this. It still > ST> seems like a poor situation to have a negative number, -214783648, > ST> which has no valid corresponding positive representation; I'll > ST> have my program check for it. (I don't think the user should > ST> have to worry about taking the negative of something yield an > overflow.) > > Think about it: you have 2^32 numbers available (an even number), this gives > one either an equal number of positive and negative numbers and 2 possible zeros > (one's compliment) or an even number of negative numbers, an odd number of positive > numbers and only one zero (two's compliment). It seems to me that the average > "user" would worry more about the existance of two zeros than about the imbalance > of positive and negative. After all, one might have (and ofen does) a use for > that last odd number, but how many times do you need a second way of representing > "zero?" And for that matter, imagine the headaches of the chip designer who > must add a second test for zero if one's compliment arithmatic were standard. > Yeah, and worse yet, think of the added complexity needed to implement an ALU that has to deal with one's complement. A simple adder can add two positive numbers. The beauty of two's complement is that you can use the same adder to add two negative numbers, or a positive and a negative number, and provided you don't generate an overflow, you get the right answer! The simplest example: Add -1 to a number. In 8-bit one's complement you would have: 10000001 (-1) + 00000001 (+1) You would first have to decide which number is negative, invert the sign bit, move it to the subtrahend field, and then subtract it from the positive number. With two's complement: 11111111 (-1) + 00000001 (+1) You simply add these two numbers and get zero! Of course there are a few tests the ALU must do to generate overflow flags, but they can be done in parallel with the add, and thus no additional delay is incurred. > Lawson > > > -- > Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English > Internet: Lawson.English@p88.f15.n300.z1.fidonet.org -- ___________________________________________________________________________ / Ralph Galetti Internet: galetti@uservx.afwl.af.mil \ | PL/ARCB Interests: computers, music, computers | | Kirtland AFB, NM 87117-6008 and music, golf, sleep. | \______________"I hate cliches--I avoid them like the plague"_______________/