home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!mcsun!sun4nl!utrcu1!infnews!heksterb
- From: heksterb@cs.utwente.nl (Ben Hekster)
- Subject: Re: (Debug) Why am I getting a TRAPV error here?!!
- Message-ID: <1993Jan22.120631.17355@cs.utwente.nl>
- Sender: usenet@cs.utwente.nl
- Nntp-Posting-Host: cerberus
- Organization: University of Twente, Dept. of Computer Science
- References: <1993Jan21.041257.6776@leland.Stanford.EDU>
- Date: Fri, 22 Jan 1993 12:06:31 GMT
- Lines: 46
-
- Hi, Ramon--
-
- In article <1993Jan21.041257.6776@leland.Stanford.EDU> felciano@summit.stanford.edu (Ramon M. Felciano) writes:
- > HLock(handle(aGDevice));
-
- BTW, you might first want to do an HGetState, and an HSetState at
- the end instead of the HUnlock.
-
- > InterArea := (commonRect.bottom - commonRect.top) *
- > (commonRect.right - commonRect.left);
- >
- >InterArea [is a] longint
- >
- >
- > +0080 011CC560 MOVE.W -$002C(A6),D7 |
- > +0084 011CC564 SUB.W -$0030(A6),D7 |
- > +0088 011CC568 TRAPV |
- > +008A 011CC56A MOVE.W -$002A(A6),D0 |
- > +008E 011CC56E SUB.W -$002E(A6),D0 |
- > +0092 011CC572 TRAPV |
- > +0094 011CC574 MULS.W D0,D7 |
- > +0096 011CC576 DIVS.W #$0001,D7 |
- > +009A 011CC57A TRAPV |
- > +009C 011CC57C *EXT.L D7 |
-
- >It would appear that a division overflow has occured at +0096. I don't
- >understand why THINK Pascal even puts the "DIVS.W #$0001,D7" line in
- >there -- I don't want to do any division at all as far as I'm
- >concerned!
-
- The compiler is using the DIVS.W instruction to convert the longword
- multiplication result to a word (note, the division by 1). This sets
- the overflow (`V') flag if the result of the division doesn't fit in
- the word, which it apparently doesn't, since the TRAPV excepts.
-
- The EXT.L at the end indicates that the result is subsequently
- being converted back to a longword. I'm not too strong on Pascal's
- integral promotion rules, but the multiplication itself is being
- carried out in words, and only converted to long at the assignment,
- which is obviously not what you intended. Perhaps you need to convert
- one of the multiplicands to a LONGINT to force long multiplication?
-
- Ben
- --
- Ben `Hackster' Hekster | "In the comfort of this room
- heksterb@cs.utwente.nl | the challenge died"
-