Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Is enum a suitable way to implement a "local define?"
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="glen herrmannsfeldt" data-source="post: 5154550"><p>I haven't heard the term "address constant" used so much outside</p><p>of S/360 (and successor) assembler programming.</p><p></p><p></p><p>For S/360 address constants, which may or may not generalize to</p><p>other systems, they can be either absolute or relocatable.</p><p>Absolute address constants don't change on relocation, and</p><p>relocatable ones do (maybe that is too obvious).</p><p></p><p>Pointer constant sounds more C-like to me.</p><p></p><p>The assembler stores the offset into the CSECT, the linker</p><p>updates that as it relocates it within the load module, and</p><p>program fetch updates again as it is being loaded into memory.</p><p></p><p>To get back to C, some things are required to be known at compile</p><p>time, and so compile time constants.</p><p></p><p>Among others, C doesn't require subtraction between pointers to</p><p>different objects to have a defined value. Subtracting two constant</p><p>pointers to different objects, then, should not be a compile time</p><p>constant, even though the compilers for some systems could</p><p>probably compute one. I presume C can compute a constant absolute</p><p>expression with pointers to the same object.</p><p></p><p>Another interesting feature of the OS/360 assembler that I haven't</p><p>known in others is that the relocation factor, in addition to the</p><p>usual 0 or 1, can also be -1 or 2. In C terms, you can compute</p><p>the value of -pointer, 2*pointer, or pointer1+pointer2 as an</p><p>address constant. C doesn't allow for that.</p><p></p><p>-- glen</p></blockquote><p></p>
[QUOTE="glen herrmannsfeldt, post: 5154550"] I haven't heard the term "address constant" used so much outside of S/360 (and successor) assembler programming. For S/360 address constants, which may or may not generalize to other systems, they can be either absolute or relocatable. Absolute address constants don't change on relocation, and relocatable ones do (maybe that is too obvious). Pointer constant sounds more C-like to me. The assembler stores the offset into the CSECT, the linker updates that as it relocates it within the load module, and program fetch updates again as it is being loaded into memory. To get back to C, some things are required to be known at compile time, and so compile time constants. Among others, C doesn't require subtraction between pointers to different objects to have a defined value. Subtracting two constant pointers to different objects, then, should not be a compile time constant, even though the compilers for some systems could probably compute one. I presume C can compute a constant absolute expression with pointers to the same object. Another interesting feature of the OS/360 assembler that I haven't known in others is that the relocation factor, in addition to the usual 0 or 1, can also be -1 or 2. In C terms, you can compute the value of -pointer, 2*pointer, or pointer1+pointer2 as an address constant. C doesn't allow for that. -- glen [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Is enum a suitable way to implement a "local define?"
Top