<<< NEAR Pointers | Index | >>> |
The TYPEDEF operator creates a user-defined type.
A user-defined type has the status of a built-in type when defining variables.
TYPEDEF is ideal for creating pointer variables.
For example, PBYTE and PWORD are pointers to bytes and words, respectively:
PBYTE TYPEDEF PTR BYTE PWORD TYPEDEF PTR WORD .DATA ; Begin data segment b_array BYTE 0, 1, 2, 4, 8 w_array WORD 1000h, 2000h, 3000h ptr_b_arr PBYTE OFFSET b_array ptr_w_arr PWORD OFFSET w_array .CODE ; Begin code segment mov esi, ptr_b_arr inc esi inc esi mov al, [esi] ; AL <- 2 mov esi, ptr_w_arr add esi, TYPE w_array mov ax, [esi] ; AX <- 2000h
<<< NEAR Pointers | Index | >>> |