TYPEDEF Operator
The TYPEDEF operator lets you create a user-defined type that has all the status of a built-in type when defining variables.
It is ideal for creating pointer variables.
PWORD TYPEDEF PTR WORD |
PWORD TYPEDEF PTR DWORD |
PWORD TYPEDEF PTR WORD
.data
array WORD 10h, 20h, 30h, 40h
pointer PWORD array
.code
mov ecx, LENGTHOF array
mov eax, 0
mov esi, pointer
L1: add ax, [esi]
add esi, 2
loop L1
call WriteHex
|
PDWORD TYPEDEF PTR DWORD
.data
array WORD 10h, 20h, 30h, 40h
pointer PDWORD array
.code
mov ecx, 2
mov eax, 0
mov esi, pointer
L1: add eax, [esi]
add esi, 4
loop L1
call WriteHex
|
|
Output |
Output |
The following list gives the differences between
register and
[register]:
-
esi gives the contents of the register ESI.
-
[esi] dereferences the offset and obtains the contents of memory if the register ESI contains an offset.
“I’m not arguing, I’m just explaining why I’m right.”
― Unknown
|