Slide 8.10: Pointers
Slide 8.12: JMP and LOOP instructions
Home

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]: