Mis-aligned Variables

| SimCon Home | fpt Reference Manual Home |

Problems with Mis-aligned Variables

Modern machines usually fetch data from, and write data to memory starting at 4 or 8 byte memory address boundaries. If an object begins at an address which is not a multiple of this algnment granularity, more bytes are fetched when the object is read, and the object is then extracted in processor registers. When the object is written, the surounding bytes must be fetched, the space occupied by the object is changed, and the data are written back. This leads to a small inefficiency.

Compilers normally align objects by default. Mis-alignment may be caused deliberately by EQUIVALENCE statements, or may be caused by the memory mapping in sequence derived types, COMMON blocks and (Non-standard) structures.

Mis-aligned objects may cause problems in two ways:

The fpt Report

The fpt command is:

CHECK ALIGNMENT

Part of the report from a tracking radar control code is shown below. This code was migrated to a 64-bit PC where is is believed to run correctly.

COMMON opar ----------- Mis-aligned objects: Name Scope Use/COMMON Address Type Size Value/Bounds ---- ----- ---------- ------- ---- ---- ------------ sigma_w urrn_tsb,urrn_qlt,urrn_stg,urrn_stb,urrn_cti,urrn_ads,urrn_zpr, urrn_wpr,urrn_tcs,urrn_ssr,urrn_ssb,urrn_srp... /opar/ 20 REAL *8 sigmar25 urrn_tsb,urrn_qlt,urrn_stg,urrn_stb,urrn_cti,urrn_ads,urrn_zpr, urrn_wpr,urrn_tcs,urrn_ssr,urrn_ssb,urrn_srp... /opar/ 28 REAL *8

Copyright ©1995 to 2024 Software Validation Ltd. All rights reserved.