[Oberon] FPGA - Little Endian & Bit numbering

Jörg joerg.straube at iaeth.ch
Fri Sep 22 19:03:20 CEST 2017

[1] and [2] are identical. But [1] seems to be portable as it does not import SYSTEM.
With [2] you are hinted to verify your code if you port it to another machine, as code using SYSTEM might need some tweaking during porting.


-----Original Message-----
From: Tomas Kral [mailto:thomas.kral at email.cz] 
Sent: Friday, September 22, 2017 6:36 PM
To: oberon at lists.inf.ethz.ch
Cc: joerg.straube at iaeth.ch
Subject: Re: [Oberon] FPGA - Little Endian & Bit numbering

On Fri, 22 Sep 2017 15:46:27 +0200
Jörg <joerg.straube at iaeth.ch> wrote:

> With the following code you can find out, whether the Oberon compiler
> and the CPU uses "LSB 0" or "MSB 0".
>   IF ORD({0}) = 1 THEN Out.String("LSB 0") ELSE Out.String("MSB 0")
>   END;

On my machine gives `LSB 0' 

> The bad thing is, this code MIGHT generate different results on
> different machines, as ORD is not well defined. Principally "ORD"
> should be in MODULE SYSTEM as it's implementation specific, e.g.
> ORD("A") is not defined at all. Almost everybody assumes it's the
> ASCII value 65 but it could also return EBCDIC value 193, but this is
> off-topic. It might be to your surprise, but it will turn out that
> most Oberon implementations use "LSB 0"

This brings another question what is the real difference between
[1] SYSTEM.VAL(INTEGER, {0}), and
[2] ORD({0}),
as both works on my system.

In the code I use the former [1], I thought ORD primarily as opposite of
CHR, but above extends its meaning, also platform dependent.

> Most probably you played with bitmaps and found out that the bit 0 is
> the left most bit on the screen. If you want to move a pixel to the
> RIGHT on the screen, you have to use LSL() (logical shift LEFT).

That's precise, I did. Also I was slightly confused because WriteBin
procedure prints in reverse order. 

Tomas Kral <thomas.kral at email.cz>

More information about the Oberon mailing list