| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | structure alignment |
ac> Does anyone know of any other DOS or OS/2 compilers that align structures
ac> by default?
Most do. Borland is the exception rather than the norm in its default
setting. Either way, it is an implementation option.
ac> Also, does aligning structures at 2- or 4-byte boundaries
ac> really provide a distinct speed increase in an 'average' program?
The issue isn't quite that simple, but certainly accessing words on word
boundaries in 16-bit mode is faster than odd-byte word fetches.
On some platforms (not intel), the option of accessing data at other than
alignment boundaries of a size determined by the machine is not available.
While you can fetch bytes at a time from a block of memory, the code
produced will usually load the data at the required alignment, then mask
and shift it into the CPU register for convenience to deal with it. A
statement such as:
char b = char_block[3];
might produce something like:
load reg_a,char_block
and reg_a,0x00ff0000
shr reg_a,16
... which is a whole *lot* less efficient than your typical byte fetch.
Such compilers will often require alignment of longs and (almost always)
floats no matter what, since generating code that attempts to fetch with
adjustment for alignment is pretty hairy. On those machines, the usual
result of generating bad code which doesn't do it correctly is a trap or
crash.
---
* Origin: Unique Computing, Melbourne, Australia (3:632/348)SEEN-BY: 50/99 620/243 623/630 632/103 348 998 633/371 634/384 388 635/301 SEEN-BY: 635/502 503 544 727 636/100 639/100 711/401 409 410 430 510 807 808 SEEN-BY: 711/809 932 934 712/515 713/888 714/906 800/1 7877/2809 @PATH: 632/103 348 635/503 50/99 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.