diff options
author | ivand58 <ivand58@hotmail.com> | 2017-09-05 18:42:44 +0300 |
---|---|---|
committer | ivand58 <ivand58@hotmail.com> | 2017-09-05 18:42:44 +0300 |
commit | 9b01360e3d4099f97150e6da7628b7e43f08b203 (patch) | |
tree | 4fe4574436d3c0a6c80fbbeb840e20bfb937a995 | |
parent | 65db4c280da717438bc375e4c15b9e46fd7c67e1 (diff) | |
download | cforth-9b01360e3d4099f97150e6da7628b7e43f08b203.tar.gz |
code for bit-band
-rw-r--r-- | src/app/arm-stm32f103/app.fth | 2 | ||||
-rw-r--r-- | src/lib/bitband.fth | 20 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/app/arm-stm32f103/app.fth b/src/app/arm-stm32f103/app.fth index 0052090..43af890 100644 --- a/src/app/arm-stm32f103/app.fth +++ b/src/app/arm-stm32f103/app.fth @@ -1,5 +1,5 @@ \ Load file for application-specific Forth extensions - +fl ../../lib/bitband.fth fl ../../lib/misc.fth fl ../../lib/dl.fth $3000 $5000 npatch load-base diff --git a/src/lib/bitband.fth b/src/lib/bitband.fth index bfbd64e..ec4cf6b 100644 --- a/src/lib/bitband.fth +++ b/src/lib/bitband.fth @@ -7,19 +7,25 @@ 1 #28 shift 1- constant BITBAND.BASEMASK_ \ covers the offset BITBAND.BASEMASK_ invert constant BITBAND.BASEMASK \ covers only the page -$2000000 constant BITBAND.OFFSET \ bit_word_offset is the position of the target bit in the bit-band memory region. +\ bit_word_offset is the position of the target bit in the bit-band memory region. +$2000000 constant BITBAND.OFFSET : BITBAND ( addr bit -- aliasaddress ) $4 * \ offest caused by the bit swap - dup \ we need to split the addr is two parts - BITBAND.BASEMASK and \ get the bit_band_base - the starting address of the alias region. + dup \ we need to split the addr is two parts + \ get the bit_band_base - the starting address of the alias region. + BITBAND.BASEMASK and swap - BITBAND.BASEMASK_ \ get the byte_offset - the number of the byte in the bit-band region that contains the targeted bit. + \ get the byte_offset - the number of the byte in the bit-band region that + \ contains the targeted bit. + BITBAND.BASEMASK_ and $20 * + + - BITBAND.OFFSET + \ add the bit_word_offset - the position of the target bit in the bit-band memory region. + \ add the bit_word_offset - the position of the target bit in the bit-band + \ memory region. + BITBAND.OFFSET + ; -$4001140C 5 BITBAND $42228194 = if ." Passed" else ." Failed" then CR -$200FFFFC #24 BITBAND $23ffffe0 = if ." Passed" else ." Failed" then CR +." Test for SFR " $4001140C 5 BITBAND $42228194 = if ." Passed" else ." Failed" then CR +." Test for RAM " $200FFFFC #24 BITBAND $23ffffe0 = if ." Passed" else ." Failed" then CR |