"Numerical Recipes in C" is nonportable code

Vidhyanath K. Rao vkr at osupyr.mast.ohio-state.edu
Sat Sep 3 04:48:12 AEST 1988


In article <8395 at smoke.ARPA>, gwyn at smoke.ARPA (Doug Gwyn ) writes:
> [From way past]
    Such an implementation will ABORT ON THE COMPUTATION `b - 1',
> That is not an X3J11 invention, just an acknowledgement of the
> way the world is.  (For example, segmented architectures.)

But why should it abort? If the address is sr:0, (sr = segment register)
subtract 1 to get (sr-1):ffff [or whatever number of 'f's]. Memory
protection, it seems to me, should not notice attempts to compute addresses
but only attempts to access forbidden addresses. 

Of course, this approach levies heavy penalities on segmented architecutres.
If you are using the 'small' model (in the 8088 meaning of the word), 
sr:0 - 1 = sr:ffff. Now you got to worry about the model. But doesn't the
philosophy of C say 'programmer knows best'. If you want to diddle with
segmented architectures, you got to put up with headaches.

So what am I missing?
-Nath
vkr at osupyr.mast.ohio-state.edu



More information about the Comp.lang.c mailing list