[Oberon] Unsigned comparisons

muller at inf.ethz.ch muller at inf.ethz.ch
Thu Aug 29 22:09:20 CEST 2002


Frank van Riet <Fvanriet at spescom.com> wrote:
>  A stack pointer 
> (for instance) is an unsigned value the size of a machine word -period. 

Just a quick hint.  To compare two stack addresses a, b: LONGINT, you 
could use: SYSTEM.LSH(a, -2) < SYSTEM.LSH(b, -2), since the addresses
are always multiples of 4.  LSH is a logical (unsigned) shift.  -1 instead
of -2 will also work.  This is much more text than a, b: CARDINAL and
a < b, but the code is not significantly slower on a modern processor.
Defining an inline UnsignedLess(a, b) CODE procedure is also an option,
but is not portable to non-Intel ETH Oberon systems.

BTW Someone mentioned that the bit order of SET is implemented 
differently in different compilers.  This was the case with the 
PowerPC compiler, but in the meantime Günter Feldmann has fixed this.
If you use the latest releases, in low level code you can now assume 
that SYSTEM.VAL(LONGINT, {0}) = 1 on all current ETH Oberon systems. 

-- Pieter

--
Pieter Muller, Computer Systems Institute, ETH Zurich / MCT Lab, Zurich
Native Oberon OS: http://www.oberon.ethz.ch/native/



More information about the Oberon mailing list