Presentation is loading. Please wait.

Presentation is loading. Please wait.

New/Old Assembler Directives Data Definition Statement syntax –[name] directive initializer [,initializer]… At least one initializer is required in a.

Similar presentations


Presentation on theme: "New/Old Assembler Directives Data Definition Statement syntax –[name] directive initializer [,initializer]… At least one initializer is required in a."— Presentation transcript:

1

2 New/Old Assembler Directives

3 Data Definition Statement syntax –[name] directive initializer [,initializer]… At least one initializer is required in a data definition even if it is ? (does not assign a specific value) –The name is a label that marks the offset of a variable from the beginning of its enclosing segment.

4 Examples Var1BYTE35h;use h for hex Var2byte255;case not checked Var3db‘A’;old syntax Var4sbyte-128;signed byte Var5byte?;uninitialized

5 Defining Lists.data List byte 10, 20, 30, 40 List2 byte 10, 32, 41h, 00100010b List3byte 10, 20, 30, 40 byte50, 60, 70, 80 byte90, 100, 120

6 Defining Strings String1byte“This is a string”, 0 String2byte‘T’,’h’,’i’,’s’,‘i’,…. String3byte “This is a long string that” byte“that extends across many” byte“lines”, 0Dh, 0Ah,0 String4\ byte “Continuation character \ may be” byte“ used to concatenate two lines” byte“ into one.”,0

7 Using the DUP Operator Generates a repeated storage allocation, using a constant expression as a counter BYTE20 DUP(0) –Results in 20 bytes, all equal to 0 BYTE20 DUP(?) –Results in 20 bytes, uninitialized BYTE4DUP(“STACK”) –Results in 20 bytes “STACKSTACKSTACKSTACK”

8 Symbolic Constants Created by associating an identifier with either an integer value or some text. Does not reserve any storage. They are only used during assembly of a program, so they cannot change value during runtime.

9 Equal-Sign Directive Associates a symbol name with an integer value.code –COUNT = 500 –Mov al, COUNT.code –ESC_KEY = 27 –Moval, ESC_KEY.data –COUNT = 50 –Array COUNT DUP(0) Useful for constants. Easy to later change one line of code.

10 Calculating the Sizes of Strings and Arrays Use the current location counter ($). –List byte 10, 20,30, 40 –ListSize = ($ - list) The calculation must be done immediately following the list definiton –mystring byte “This is my string”,0 –String_len = ($ - mystring –1)

11 Calculating the Sizes of Strings and Arrays of Words and Doublewords ListWORD1000h, 2000h, 3000h Listsize = ($ - list) / 2 List DWORD10000000h,20000000h, DWORD30000000h,40000000h Listsize = ($ - list) / 4 This is important when using loops through arrays

12 Lists and Strings List1 db 10, ‘A’, 41h, 0Ah, 00100010b, 101q Listptr db List1 Cstring db “This is a string”,0 Clength = ($ - Cstring); sets Clength to length of Cstring Array1 db 20 dup(0); 20 bytes, all equal to zero Array2 db 4 dup(“ABC”); 12 bytes, “ABCABCABCABC”


Download ppt "New/Old Assembler Directives Data Definition Statement syntax –[name] directive initializer [,initializer]… At least one initializer is required in a."

Similar presentations


Ads by Google