【正文】
n, TapeDLT}。 static BackupUnit: TapeDrives := TapeDAT。 . . mov( BackupUnit, al )。 if( al = Tape8mm ) then ... endif。 // etc 23 Pointer Data Types ? a memory location whose value is the address of some other memory location. ? mov( p, ebx )。 mov( [ebx], eax )。 mov( amp。i, p )。 // Assume all variables are STATIC variables. . . . if( some_expression ) then mov( amp。j, p )。 . . . endif。 mov( p, ebx )。 mov( [ebx], eax )。 24 Declaring Pointers in HLA static b: byte。 d: dword。 pByteVar: pointer to byte := amp。b。 pDWordVar: pointer to dword := amp。d。 type ptrChar: pointer to char。 static cString: ptrChar。 25 Pointer Constants and Pointer Constant Expressions ? amp。StaticVarName + PureConstantExpression ? amp。StaticVarName – PureConstantExpression ? Ex: – 26 Pointer Variables and Dynamic Memory Allocation ? type ? bytePtr: pointer to byte。 ? var ? bPtr: bytePtr。 ? . ? . ? . ? malloc( 1024 )。 ? mov( eax, bPtr )。 ? . ? . ? free( bPtr )。 . 27 realloc procedure ? realloc( ExistingPointer, NewSize )。 ? Realloc returns a pointer to the newly allocated block in the EAX register. 28 Common Pointer Problems ? Using an uninitialized pointer ? Using a pointer that contains an illegal value (., NULL) ? Continuing to use malloc39。d storage after that storage has been free39。d ? Failing to free storage once the program is done using it ? Accessing indirect data using the wrong data type. 29 The last problem ? Ex: BadTypePtrDemo .hla 30 Thank you for your attention!