gft_robert@gsbacd.uchicago.edu (10/10/89)
Here's a really simple problem that's bugging me:
I want to write out an integer to a specific location in memory, something like
this:
var
myPtr:Ptr;
myInt:integer;
begin
myPtr:=some location in memory;
myInt:= some value <=32k;
myPtr^:=SignedByte(myInt);
end;
OK, so far so good. My compiler (THINK Pascal) doesn't choke on this, so it
would seem to be OK. But it still doesn't choke on it if I make myInt > 255.
Since SignedByte is defined in IM as 0..255, it shouldn't let me do that (range
checking is turned on), and if I do do it, won't I be overwriting two bytes in
memory, not one?
Your elucidations and explanations gratefully awaited,
Robert
============================================================================
= gft_robert@gsbacd.uchicago.edu * generic disclaimer: * "It's more fun to =
= crsp_ra@gsbacd.uchicago.edu * all my opinions are * compute" =
= * mine * -Kraftwerk =
============================================================================siegel@endor.harvard.edu (Rich Siegel) (10/10/89)
In article <5728@tank.uchicago.edu> gft_robert@gsbacd.uchicago.edu writes: > >I want to write out an integer to a specific location in memory, something like >this: > If you want to write out two bytes, then var p : ^Integer; p := Pointer(addr); p^ := i; is the way to do it. They way you wrote it, the high byte of your value will get written out; there will be no range violation, because the high byte will never have a value bigger than $FF. At any rate, SignedByte is not 0..255, it's -127..128, or $ff..$80. R. ~~~~~~~~~~~~~~~ Rich Siegel Staff Software Developer Symantec Corporation, Language Products Group Internet: siegel@endor.harvard.edu UUCP: ..harvard!endor!siegel "There is no personal problem which cannot be solved by sufficient application of high explosives." ~~~~~~~~~~~~~~~