<div dir="ltr">If they are manipulating a hardware register that is based on bits, why is the data ever in the form of an integer?</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Oct 24, 2018 at 12:16 PM Tomas Kral <<a href="mailto:thomas.kral@email.cz">thomas.kral@email.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 24 Oct 2018 14:47:30 +0200<br>
Tomas Kral <<a href="mailto:thomas.kral@email.cz" target="_blank">thomas.kral@email.cz</a>> wrote:<br>
<br>
> but how to access the<br>
> individual bits?<br>
<br>
How about this, if not correct or too silly?<br>
<br>
MODULE Bits; (*TK 24.10.2018 Word Byte Bit SET masks example*)<br>
IMPORT S := SYSTEM, O := Out;<br>
<br>
CONST<br>
m0 = {0}; m1 = {1}; m2 = {2}; m3 = {3}; m4 = {4}; m5 = {5}; m6 = {6}; m7 = {7}; (*bit masks*)<br>
m0123 = {3,2,1,0}; (*lower nibble*) m4567 = {4,5,6,7}; (*upper nibble*)<br>
m16 = {0..15}; (*lower short*) m24 = {16..31}; (*upper short*)<br>
m31 = {0..31}; (*word*)<br>
<br>
VAR<br>
wd: INTEGER;<br>
b0,b1,b2,b3: BYTE; (*b0: LSB, b3: MSB*)<br>
bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7: BYTE; (*bits' values*)<br>
s: SET;<br>
<br>
PROCEDURE Show*;<br>
BEGIN<br>
wd := 0F3F2F1F0H;<br>
b0 := wd MOD 100H; O.Hex(b0); O.Ln; (*one cycle or more?*)<br>
b1 := wd DIV 100H MOD 100H; O.Hex(b1); O.Ln;<br>
b2 := wd DIV 10000H MOD 100H; O.Hex(b2); O.Ln;<br>
b3 := wd DIV 1000000H MOD 100H; O.Hex(b3); O.Ln; O.Ln;<br>
bit0 := ORD(ODD(b0)); O.Hex(bit0); O.Ln;<br>
bit1 := b1 MOD 2; O.Hex(bit1); O.Ln;<br>
bit2 := b2 DIV 2 MOD 2; O.Hex(bit2); O.Ln;<br>
bit3 := b3 DIV 4 MOD 2; O.Hex(bit3); O.Ln;<br>
(*s := S.VAL(SET, wd) * m4);*) (*using mask {4}*)<br>
bit4 := b3 DIV 8 MOD 2; O.Hex(bit4); O.Ln;<br>
bit5 := b3 DIV 16 MOD 2; O.Hex(bit5); O.Ln;<br>
bit6 := b3 DIV 32 MOD 2; O.Hex(bit6); O.Ln;<br>
bit7 := b0 DIV 64 MOD 2; O.Hex(bit7); O.Ln; O.Ln;<br>
IF bit0 > 0 THEN INCL(s, bit0) END ;<br>
IF bit1 > 0 THEN INCL(s, bit1*2) END ;<br>
IF bit2 > 0 THEN INCL(s, bit2*4) END ;<br>
IF bit3 > 0 THEN INCL(s, bit3*8) END ;<br>
IF bit4 > 0 THEN INCL(s, bit4*16) END ;<br>
IF bit5 > 0 THEN INCL(s, bit5*32) END ;<br>
IF bit6 > 0 THEN INCL(s, bit6*64) END ;<br>
IF bit7 > 0 THEN INCL(s, bit7*128) END ;<br>
(*s := S.VAL(SET, wd) * (m0+m1+m2+m3);*) (*using mask {0..3}*)<br>
O.Hex(ORD(s)); O.Ln<br>
END Show;<br>
<br>
BEGIN<br>
END Bits.Show<br>
<br>
<br>
-- <br>
Tomas Kral <<a href="mailto:thomas.kral@email.cz" target="_blank">thomas.kral@email.cz</a>><br>
--<br>
<a href="mailto:Oberon@lists.inf.ethz.ch" target="_blank">Oberon@lists.inf.ethz.ch</a> mailing list for ETH Oberon and related systems<br>
<a href="https://lists.inf.ethz.ch/mailman/listinfo/oberon" rel="noreferrer" target="_blank">https://lists.inf.ethz.ch/mailman/listinfo/oberon</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Aubrey McIntosh, Ph.D.<div>1502 Devon Circle</div><div>Austin TX 78723</div><div>(512) 791-3801</div><div><br></div></div></div></div></div>