home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 21950 < prev    next >
Encoding:
Text File  |  1993-01-22  |  2.5 KB  |  59 lines

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