[Oberon] Bit manipulation in Oberon-07

Aubrey McIntosh aubrey.mcintosh at utexas.edu
Wed Oct 24 21:43:16 CEST 2018


Some decades ago I was working on a project, and I made a table of inputs
and outcomes.  I looked at the table and said halfheartedly to my
associate, "we need a jump on parity"  Well, there was such an instruction,
and the code became almost trivial.

see http://www.eastjesus.net/tech/crc/FastCRC.html

So my apologies, but I wonder if you could tell me again which processor
the project uses, or even better to a detailed instruction set document for
it.


On Wed, Oct 24, 2018 at 1:39 PM Tomas Kral <thomas.kral at email.cz> wrote:

> On Wed, 24 Oct 2018 19:15:56 +0200
> Tomas Kral <thomas.kral at email.cz> wrote:
>
> > but how to access the
> > individual bits?
>
> There is also SYSTEM.BIT(a, n) checking a single bit in memory.
> Apologies, this is quite catchy and cannot let go yet. Rewritten in
> arrays and loops, still possibly of little or no use.
>
>   MODULE Bits; (*TK 24.10.2018 Word Byte Bit SET masks example*)
>   IMPORT S := SYSTEM, O := Out;
>
> CONST
>   m0 = {0}; m1 = {1}; m2 = {2}; m3 = {3}; m4 = {4}; m5 = {5}; m6 = {6}; m7
> = {7}; (*bit masks*)
>   m0123 = {3,2,1,0}; (*lower nibble*) m4567 = {4,5,6,7}; (*upper nibble*)
>   m16 = {0..15}; (*lower short*) m24 = {16..31}; (*upper short*)
>   m31 = {0..31}; (*word*)
>
> VAR
>   wd, i: INTEGER;
>   b: ARRAY 4 OF BYTE; (*b[0]: LSB, b[3]: MSB*)
>   (*bit0, bit1, bit2, bit3, bit4,  bit5, bit6, bit7: BYTE;*) (*8 bits 0|1
> values*)
>   bit: ARRAY 8 OF BYTE;
>   s: SET;
>
>   PROCEDURE Show*;
>   BEGIN
>     wd := 0F3F2F1F0H; (*test word*)
>
>     (*bytes)
>     b[0] := wd MOD 100H; O.Hex(b[0]); O.Ln; (*shift = one cycle*)
>     b[1] := wd DIV 100H MOD 100H; O.Hex(b[1]); O.Ln;
>     b[2] := wd DIV 10000H MOD 100H; O.Hex(b[2]); O.Ln;
>     b[3] := wd DIV 1000000H MOD 100H; O.Hex(b[3]); O.Ln; O.Ln;
>
>     (*bits*)
>     bit[0] := ORD(ODD(b[0])); O.Hex(bit[0]); O.Ln;
>     bit[1] := b[1] MOD 2; O.Hex(bit[1]); O.Ln;
>     bit[2] := b[2] DIV 2 MOD 2; O.Hex(bit[2]); O.Ln;
>     bit[3] := b[3] DIV 4 MOD 2; O.Hex(bit[3]); O.Ln;
>
>     (*s := S.VAL(SET, wd) * m4);*) (*using mask {4}*)
>
>     bit[4] := b[3] DIV 8 MOD 2; O.Hex(bit[4]); O.Ln;
>     bit[5] := b[3] DIV 16 MOD 2; O.Hex(bit[5]); O.Ln;
>     bit[6] := b[3] DIV 32 MOD 2; O.Hex(bit[6]); O.Ln;
>     bit[7] := b[0] DIV 64 MOD 2; O.Hex(bit[7]); O.Ln; O.Ln;
>
>     (*set unrolled*)
>     (*IF bit[0] > 0 THEN INCL(s, 0) END ;
>     IF bit[1] > 0 THEN INCL(s, 1) END ;
>     IF bit[2] > 0 THEN INCL(s, 2) END ;
>     IF bit[3] > 0 THEN INCL(s, 3) END ;
>     IF bit[4] > 0 THEN INCL(s, 4) END ;
>     IF bit[5] > 0 THEN INCL(s, 5) END ;
>     IF bit[6] > 0 THEN INCL(s, 6) END ;
>     IF bit[7] > 0 THEN INCL(s, 7) END ;*)
>
>     (*set in loop*)
>     s := {}; FOR i := 0 TO 7 DO IF bit[i] > 0 THEN INCL(s, i) END END ;
>     (*s := S.VAL(SET, wd) * (m0+m1+m2+m3);*) (*using mask {0..3}*)
>
>     (*output byte hex & bin*)
>     O.Hex(S.VAL(INTEGER, s)); O.Ln;
>     O.Bin(S.VAL(INTEGER, s), 8); O.Ln
>   END Show;
>
> BEGIN
> END Bits.Show
>
>
> --
> Tomas Kral <thomas.kral at email.cz>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon
>


-- 
Aubrey McIntosh, Ph.D.
1502 Devon Circle
Austin TX 78723
(512) 791-3801
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20181024/f198caed/attachment-0001.html>


More information about the Oberon mailing list