24.11.2014 Views

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

Open Watcom FORTRAN 77 Language Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Language</strong> <strong>Reference</strong><br />

2.80 UNION Statement<br />

UNION<br />

The UNION statement is used in conjunction with the END UNION declarative statement. The UNION<br />

statement marks the start of a series of MAP structures. A UNION block must contain at least two MAP<br />

structures. A UNION block permits the mapping of the same storage in several different ways.<br />

The following example maps out a 4-byte integer on an Intel 80x86-based processor.<br />

Example:<br />

STRUCTURE /MAPINT/<br />

UNION<br />

MAP<br />

INTEGER*4 LONG<br />

END MAP<br />

MAP<br />

INTEGER*2 LO_WORD<br />

INTEGER*2 HI_WORD<br />

END MAP<br />

MAP<br />

INTEGER*1 BYTE_0<br />

INTEGER*1 BYTE_1<br />

INTEGER*1 BYTE_2<br />

INTEGER*1 BYTE_3<br />

END MAP<br />

END UNION<br />

END STRUCTURE<br />

RECORD /MAPINT/ I<br />

I%LONG = ’01020304’x<br />

PRINT ’(2Z4)’, I%LO_WORD, I%HI_WORD<br />

END<br />

For more information, see the chapter entitled "Structures, Unions and Records" on page 167.<br />

142 UNION Statement

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!