Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.posted.palinacquisition!news.posted.palinacquisition.POSTED!not-for-mail NNTP-Posting-Date: Fri, 08 Jul 2011 19:42:27 -0500 Date: Fri, 08 Jul 2011 17:42:27 -0700 From: Peter Duniho User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <2rydnez7l-H5BYnTnZ2dnUVZ_vGdnZ2d@earthlink.com> <9LWdnZH2hdfmyYvTnZ2dnUVZ_vidnZ2d@posted.palinacquisition> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 23 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 50.46.118.188 X-Trace: sv3-KzAbNLDxnhZtlyu6OBiYtOuivziaK34cv8mZ0H/MpaisvrMsyUQyh6Uarqp79IqbH0ChPkU4sV1uet/!PMawjfj7ZEY/QwSUHWpltsD7sJ/2KrMOotpjioP5PC8j+r2EH47frlUo8arp9ocqOuTyUYy2IfJD!55+eYXWizH5Tr/yUFhph56KZY+bsrlUxm3fO3hPQunc= X-Complaints-To: abuse@iinet.com X-DMCA-Complaints-To: abuse@iinet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2585 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6003 On 7/8/11 7:38 AM, markspace wrote: > On 7/8/2011 1:29 AM, Peter Duniho wrote: > >> AFAIK, mainstream hardware (e.g. x86-compatible) doesn't include special >> overflow-checking instructions as you're describing. I agree it's > > Er, x86 and i32/64 certainly does. I just happen to be browsing their > hardware architecture documents last weak. > > Not a single instruction to AddWithTrap, but a it does have a global > state register, and a test/branch instrution, so you just pair up an ADD > followed by a JO (Jump if Overflow) and that's it. Two easy instructions > paired together, and it works the same for MUL and SUB too. (DIV can't > overflow; think about it). Go back and read what you're replying to. The context is _specifically_ about "a single instruction to AddWithTrap". x86 and lots of other hardware has the global state you're talking about. But that's not what we're talking about. Pete