MOVEADDR Examples


Example 1:

. This sample for the MOVEVARADDR shows how the physical

. UDA address of can be used to build a PLB representation

. for a 'C' structure. The PLB RECORD variables in this case

. are being used time identify the 'C' structure members in

. PLB variable terms.

.

 

%IFDEF

NOTUSED

.

. Sample 'C' structure with embedded 'C' integer and character

. pointers. In this sample, the 'MQCDStruct' member is the

. address of a second 'C' structure.

 

struct {

  long Strucid;

  long Version;

  long Options;

  long Offset;

  char* MQCDStruct;

}

 

 

%ENDIF

 

$0

INTEGER

5

BinZero

INIT

0x0

. This RECORD provides a layout that populates a

. DIM variable to represent the 'C' structure members.

S1

RECORD

 

Strucid

INTEGER

4

Version

INTEGER

4

Options

INTEGER

4

Offset

INTEGER

4

pMQCDSTRUC

INTEGER

4

 

RECORDEND

 

.

. This is a second sample structure pointed to by the 'pMQCDSTRUCT' member found in the 'S1' RECORD layout.

.

S2

RECORD

 

A

INTEGER

4

B

INTEGER

4

C

INTEGER

4

 

RECORDEND

 

.

 

 

D1

DIM

32 //Working PLB DIM for 'C' S1 data.

D2

DIM

32 //Working PLB DIM for 'C' S2 data.

.

. Set the D1 and D2 data to be all binary zeros.

. This is NOT needed. But, I prefer that all data in the DIM

. initialized to binary zeros.

.

 

FILL

BinZero,D1,D2

 

CLEAR

D1,D1

.

. Initialize S2 structure members

.

 

MOVE

"1",S2.A

 

MOVE

"2",S2.B

 

MOVE

"3",S2.C

 

PACK

D2,S2 //Structure 2 data is in the D2 dim!

 

. Initialize S1 structure members!!

.

 

MOVE

"10",S1.Strucid

 

MOVE

"20",S1.Version

 

MOVE

"30",S1.Options

 

MOVE

"40,S1,Offset

.

 This MOVEVARADDR instruction moves the physical UDA address

. of the data for the 'D2' DIM variable into the INTEGER

. variable named 'S1.pMQCDSTRUCT'.

.

 

MOVEVARADDR

D2,S1.pMQCDSTRUCT

.

. This PACK creates a 'C' structure representation that is created in the 'D1' DIM variable.

.

. Note:

. The 'S1.pMQCDSTRUCT' INTEGER contains the UDA physical

. address of a SECOND 'C' structure that was packed\created

. in the 'D2' DIM variable.

.

 

PACK

D1,S1 //Structure 1 data with pointer to Structure 2 data in pMQCDSTRUCT!

 

KEYIN

"Hit enter to exit:",s$cmdlin

 



PL/B Language Reference