Previous Book Contents Book Index Next

Inside Macintosh: Operating System Utilities /
Chapter 3 - Mathematical and Logical Utilities / Mathematical and Logical Utilities Reference
Routines / Getting and Setting Memory Values


StuffHex

You can use the StuffHex procedure to hardcode byte values into memory.

PROCEDURE StuffHex (thingPtr: Ptr; s: Str255);
thingPtr
A pointer to any data structure in memory. If thingPtr is an odd address, then thingPtr is interpreted as pointing to the next word boundary.
s
A string of characters representing hexadecimal digits. Be sure that all characters in this string are hexadecimal digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). Otherwise, StuffHex may set bytes in the data structure pointed to by thingPtr to arbitrary values. If there are an odd number of characters in the string, the last character is ignored.
DESCRIPTION
The StuffHex procedure sets bytes in memory beginning with that byte specified by the parameter thingPtr. The total number of bytes set is equivalent to s[0] DIV 2 (that is, half the length of the string, ignoring the last character if the number of characters is odd).

Each byte to be set corresponds to two characters in the string. These characters should represent hexadecimal digits. For example, the string 'D41A' results in 2 bytes being set to the values $D4 and $1A, respectively.

Although the StuffHex procedure sets the value of individual bytes, it does not move relocatable blocks. Thus, you can call it at interrupt time.

SPECIAL CONSIDERATIONS
The StuffHex procedure does no range checking to ensure that bytes being set are within the bounds of a certain data structure. If you do not use StuffHex carefully, you may change memory in the partition of your application or another application in unpredictable ways.

SEE ALSO
For examples of the use of the StuffHex procedure, see page 3-19.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996