LMAPGC05

LMAPGC05 - 105 CHAPTER 1 With the complex data types...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
105 CHAPTER 1 With the complex data types available in MASM 6.1 — arrays, strings, records, structures, and unions — you can access data as a unit or as individual elements that make up a unit. The individual elements of complex data types are often the integer types discussed in Chapter 4, “Defining and Using Simple Data Types.” “Arrays and Strings” reviews how to declare, reference, and initialize arrays and strings. This section summarizes the general steps needed to process arrays and strings and describes the MASM instructions for moving, comparing, searching, loading, and storing. “Structures and Unions” covers similar information for structures and unions: how to declare structure and union types, how to define structure and union variables, and how to reference structures and unions and their fields. “Records” explains how to declare record types, define record variables, and use record operators. Arrays and Strings \z "COMPLW.DOC-1001" \z "COMPLW.DOC-1002" \z "COMPLW.DOC-1003" \z "COMPLW.DOC-1004" An array is a sequential collection of variables, all of the same size and type, called “elements.” A string is an array of characters. For example, in the string “ABC,” each letter is an element. You can access the elements in an array or string relative to the first element. This section explains how to handle arrays and strings in your programs. Declaring and Referencing Arrays \z "COMPLW.DOC-1005" \z "COMPLW.DOC-1006" \z "COMPLW.DOC-1007" \z "COMPLW.DOC-1008" \z "COMPLW.DOC-1009" Array elements occupy memory contiguously, so a program references each element relative to the start of the array. To declare an array, supply a label name, the element type, and a series of initializing values or ? placeholders. The following examples declare the arrays warray and xarray: warray WORD 1, 2, 3, 4 xarray DWORD 0FFFFFFFFh, 789ABCDEh Initializer lists of array declarations can span multiple lines. The first initializer must appear on the same line as the data type, all entries must be initialized, and, Filename: eb3b273c1e13d7d77a78beb587ca3af80e697a4a.DOC Project: Template: Author: Last Saved By: Revision #: 0 Page: 105 of 32 Printed:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Programmer’s Guide if you want the array to continue to the new line, the line must end with a comma. These examples show legal multiple-line array declarations: big BYTE 21, 22, 23, 24, 25, 26, 27, 28 somelist WORD 10, 20, 30 If you do not use the LENGTHOF and SIZEOF operators discussed later in this section, an array may span more than one logical line, although a separate type declaration is needed on each logical line: var1 BYTE 10, 20, 30 BYTE 40, 50, 60 BYTE 70, 80, 90 The DUP Operator \z "COMPLW.DOC-1010" \z "COMPLW.DOC-1011" You can also declare an array with the DUP operator. This operator works with any of the data allocation directives described in “Allocating Memory for Integer Variables” in Chapter 4. In the syntax count DUP ( initialvalue [[ , initialvalue ]]. .. ) \z "COMPLW.DOC-1012"
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 32

LMAPGC05 - 105 CHAPTER 1 With the complex data types...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online