+Vorticon Posted November 8 Share Posted November 8 2 minutes ago, apersson850 said: Yes, the compiler treats the constant -32768 as a long integer, since it can't negate that number within the 16 bit range. You may call it a "bug", but since it's by design it's probably if not a "feature" then at least a "characteristic". But if I assign -32767 to an integer then subtract 1, -32768 does get stored in that integer as I've demonstrated earlier. Quote Link to comment https://forums.atariage.com/topic/193355-pascal-on-the-994a/page/45/#findComment-5562377 Share on other sites More sharing options...
apersson850 Posted November 8 Author Share Posted November 8 Yes, the exception for the integer value -32768 applies only when it's compiled as a constant. What you demonstrated is a runtime calculation and they execute as expected. They are literally translated to the A (add) instruction in the TMS 9900. Note that UCSD Pascal doesn't do any range checking on integer arithmetic, so you can do unsigned math too. If you add 10 to 32767 you'll get the binary result that's equivalent to 32777 if you look at the 16-bit value as an unsigned one and there is no error. If you use write to print it out Pascal will report it as -32759, but the value 8009H unsigned represents 32777. You'll have to write your own printout functions if you want proper printing of unsigned numbers. But the math you can do with the standard functions. 2 Quote Link to comment https://forums.atariage.com/topic/193355-pascal-on-the-994a/page/45/#findComment-5562460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.