Bitfields

General discussions about working with the Astrobe IDE and programming ARM Cortex-M3, M4 and M7 microcontrollers.

Bitfields

Postby steve64 » Fri Jul 20, 2018 4:09 pm

It seems that the SYSTEM.BFI and SYSTEM.UBFX procedures only work with constants for msb and lsb.
Is this confirmed? If so, what's the reason?
steve64
 
Posts: 36
Joined: Mon Jul 09, 2018 8:56 am
Location: Italy

Re: Bitfields

Postby cfbsoftware » Fri Jul 20, 2018 11:23 pm

SYSTEM.BFI is designed to efficiently generate a single ARMv7-M architecture instruction:

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

<lsb> and <width> are constant values encoded in the instruction so these need to be known at compile-time. The same applies to SYSTEM.UBFX.

if you want to do bit manipulation using variables you can use Oberon's SET variables, operators and functions (INCL and EXCL). If you are new to Oberon the following article by Niklaus Wirth should be useful to you:

SET: A neglected data type, and its compilation for the ARM
cfbsoftware
Site Admin
 
Posts: 355
Joined: Fri Dec 31, 2010 12:30 pm

Re: Bitfields

Postby cfbsoftware » Sat Nov 03, 2018 12:01 am

Alternative approaches are discussed in BIT WISE AND/OR operation on the Oberon Language forum.
cfbsoftware
Site Admin
 
Posts: 355
Joined: Fri Dec 31, 2010 12:30 pm


Return to Astrobe for ARM Cortex-M3, M4 and M7

cron