Ch 10 & 12 Slides - Chapters 10 & 12 Click to edit...

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

View Full Document Right Arrow Icon
Click to edit Master subtitle style 9/8/10 Frank Cirimele Frank Cirimele
Background image of page 1

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

View Full DocumentRight Arrow Icon
9/8/10 Frank Cirimele Chapter 10 Structures Unions Macros
Background image of page 2
9/8/10 Frank Cirimele Kip Irvine Structures - Overview Defining Structures Declaring Structure Variables Referencing Structure Variables Example: Displaying the System Time Nested Structures
Background image of page 3

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

View Full DocumentRight Arrow Icon
9/8/10 Frank Cirimele Structure A template or pattern given to a logically related group of variables. field - structure member containing data size of structure = sum of its components Program access to a structure: entire structure as a complete unit individual fields
Background image of page 4
9/8/10 Frank Cirimele Kip Irvine Using a Structure Using a structure involves three sequential steps: 1. Define the structure. 2. Declare one or more variables of the structure type, called structure variables . 3. Write runtime instructions that access the structure.
Background image of page 5

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

View Full DocumentRight Arrow Icon
9/8/10 Frank Cirimele Structure Definition Syntax name STRUCT field-declarations name ENDS Field-declarations are identical to variable declarations States variable sizes Optionally, provide initial values with or without the DUP operator Structure allocates no memory
Background image of page 6
9/8/10 Frank Cirimele Kip Irvine COORD Structure The COORD structure used by the MS- Windows programming library identifies X and Y screen coordinates COORD STRUCT X WORD ? ; offset 00 Y WORD ? ; offset 02 COORD ENDS
Background image of page 7

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

View Full DocumentRight Arrow Icon
9/8/10 Frank Cirimele Kip Irvine Employee Structure Employee STRUCT IdNum BYTE "000000000" LastName BYTE 30 DUP(0) Years WORD 0 SalaryHistory DWORD 0,0,0,0 Employee ENDS A structure is ideal for combining fields of different types: "000000000" (null) 0 0 0 0 0 SalaryHistory Lastname Years Idnum
Background image of page 8
9/8/10 Frank Cirimele Kip Irvine Declaring Structure Variables Structure name is a user-defined type Insert replacement initializers between brackets: < . . . > Empty brackets <> retain the structure's default field initializers .data point1 COORD <5,10> point2 COORD <> worker Employee <>
Background image of page 9

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

View Full DocumentRight Arrow Icon
9/8/10 Frank Cirimele Initializing Array Fields Use the DUP operator to initialize one or more elements of an array field: .data emp Employee <,,,2 DUP(20000)>
Background image of page 10
9/8/10 Frank Cirimele Kip Irvine Array of Structures An array of structure objects can be defined using the DUP operator. Initializers can be used NumPoints = 3 AllPoints COORD NumPoints DUP(<0,0>) RD_Dept Employee 20 DUP(<>) accounting Employee 10 DUP(<,,,4 DUP(20000) >)
Background image of page 11

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

View Full DocumentRight Arrow Icon
9/8/10 Frank Cirimele Kip Irvine Referencing Structure Variables .data worker Employee <> mov eax,TYPE Employee ; 57 mov eax,SIZEOF Employee ; 57 mov eax,SIZEOF worker ; 57 mov eax,TYPE Employee.SalaryHistory ; 4 mov eax,LENGTHOF Employee.SalaryHistory ; 4 mov eax,SIZEOF Employee.SalaryHistory ; 16 Employee STRUCT ; bytes IdNum BYTE "000000000" ; 9 LastName BYTE 30 DUP(0) ; 30 Years WORD 0 ; 2 SalaryHistory DWORD 0,0,0,0 ; 16 Employee ENDS ; 57
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/08/2010 for the course CMPE 46 at San Jose State University .

Page1 / 71

Ch 10 & 12 Slides - Chapters 10 & 12 Click to edit...

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

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