Slide 5.8: Defining strings
Slide 5.10: Defining other data
Home

Defining WORD and SWORD Data


   word1  WORD   100h + 0B00h


     ; integer expression


   word2  SWORD  -32768


     ; smallest signed value

Type Usage
WORD 16-bit unsigned integer
SWORD 16-bit signed integer
Using the DUP Operator
The DUP operator generates a repeated storage allocation, using a constant expression as a counter.


   val5  BYTE  10 DUP('a')        ; 10 bytes, all equal to 'a'


   val6  BYTE  10 DUP(?)          ; 10 bytes, uninitialized


   val7  BYTE   3 DUP("test")     ; 12 bytes, "testtesttest"
An array can be created by using the following statement:


    myArray  WORD  10, 10, 10, 10
which is equal to


    myArray  WORD  4 DUP(10)
 
Offset Value
0000 10
0002 10
0004 10
0006 10
Assume myArray starts at offset 0. All offsets are shown on the above.

 EAX == 12345678h, (Y/N)


 .data


 X   WORD  1234h


 Y   WORD  5678h


 .code


 mov   eax, X


 call  WriteHex


 .data


 X   WORD  1234h


 Y   WORD  5678h


 Z  DWORD  ?


 .code


 mov   bx, Y


 mov   Z, bx


 mov   bx, X


 mov   Z+2, bx


 mov   eax, Z


 call  WriteHex


 .data


 X  WORD  1234h


 Y  WORD  5678h


 


 .code


 mov   bx, Y


 mov   Z, bx


 mov   bx, X


 mov   Z+2, bx


 mov   ecx, OFFSET Z


 


 call  WriteHex
 

 Output  Output  Output
   



   



  12345678h