Bitfields
Posted: Fri Jul 20, 2018 4:09 pm
It seems that the BFI and BFX procedures only work with constants for msb and lsb.
Is this confirmed? If so, what's the reason?
Is this confirmed? If so, what's the reason?
A technical support group for Astrobe Oberon users
https://astrobe.com./forum/
Code: Select all
BFI <Rd>, <Rn>, #<lsb>, #<width>
where:
<Rd> Specifies the destination register.
<Rn> Specifies the source register.
<lsb> Specifies the least significant destination bit, in the range 0 to 31.
<width> Specifies the number of bits
Code: Select all
setMsk := BITS(LSL(01FFH, 5));
wayMsk := BITS(LSL(3H, 30));
SYSTEM.GET(CCSIDR, ccsidr);
sets := LSR(ORD(ccsidr * BITS(LSL(07FFFH, 13))), 13);
REPEAT
ways := LSR(ORD(ccsidr * BITS(LSL(03FFH, 3))), 3);
REPEAT
SYSTEM.PUT(DCISW, (BITS(LSL(sets, 5)) * setMsk) +
(BITS(LSL(ways,30)) * wayMsk));
DEC(ways);
UNTIL ways < 0;
DEC(sets);
UNTIL sets < 0;
Code: Select all
SYSTEM.GET(CCSIDR, ccsidr);
sets := BFX(ccsidr, 27, 13); (* extract bits 27..13 to sets *)
REPEAT
ways := BFX(ccsidr, 12, 3);
dcisw := 0;
BFI(dcisw, 13, 5, sets); (* Insert sets into bits 13..5 *)
REPEAT
BFI(dcisw, 31, 30, ways);
SYSTEM.PUT(DCISW, dcisw);
DEC(ways);
UNTIL ways < 0;
DEC(sets);
UNTIL sets < 0;