Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/3/85; site ukma.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!ihnp4!cbosgd!ukma!sambo From: sambo@ukma.UUCP (Inventor of micro-S) Newsgroups: net.arch,net.lang,net.micro,net.micro.pc Subject: Integer division on the Intel iAPX8[6,8] Message-ID: <2018@ukma.UUCP> Date: Mon, 5-Aug-85 01:07:58 EDT Article-I.D.: ukma.2018 Posted: Mon Aug 5 01:07:58 1985 Date-Received: Tue, 6-Aug-85 20:05:51 EDT Organization: U of Kentucky, Mathematical Sciences, Lexington KY Lines: 31 Xref: watmath net.arch:1648 net.lang:1666 net.micro:11321 net.micro.pc:4833 I am currently working on a compiler for a language I have designed, and whose target machine is the IBM PC. I happened to look at the description of the IDIV instruction for the Intel 8086 and 8088. It says that the minimum negative quotient for a byte division is -127, and the minimum negative quo- tient for a word division is -32767. I tested this, and lo and behold, both -128 / 1 and -32768 / 1 do indeed generate a division-by-zero interrupt. I am wondering three things: 1) Why does this happen - i.e. what hardware algorithm does this proces- sor use? 2) Are there any compilers for a machine using the 8086 or 8088 that can handle both -128 / 1 and -32768 / 1 correctly? (IBM Pascal Version 1.00 does not.) 3) Are there any other processors that behave the way the 8086 and 8088 do in this respect? (I tested this on both our VAX 11/750 and our 3B2/300 by writing a C program and modifying the assembly language output, and both of them work correctly.) By the way, the algorithm on page 2-73 of the iAPX88 Book dated July 1981 is wrong - it implies that the maximum negative quotient is -128 and -32768 for byte and word division respectively, which is clearly contradicted in the prose description for the instruction. P.S.: I know some of you may be tempted to express your great admiration for the totality of Intel's product line, but this is not what I am looking for. ----------------------------------------- Samuel A. Figueroa, Dept. of CS, Univ. of KY, Lexington, KY 40506-0027 ARPA: ukma!sambo<@ANL-MCS>, or sambo%ukma.uucp@anl-mcs.arpa, or even anlams!ukma!sambo@ucbvax.arpa UUCP: {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!sambo, or cbosgd!ukma!sambo "Micro-S is great, if only people would start using it."