aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Dimitrov <ivand@hobbylab.org>2017-09-11 18:49:07 +0300
committerIvan Dimitrov <ivand@hobbylab.org>2017-09-11 18:49:07 +0300
commitacbe7ebe4ca4eb475607ce096adfc16d4686dc6e (patch)
tree598aa4bd4a53084b5eac3112addb332a303c7349
parent17ae207176c6ae52d263e55c82ff1e9b0cb0a20e (diff)
downloadcforth-acbe7ebe4ca4eb475607ce096adfc16d4686dc6e.tar.gz
The code is changed as it was suggested.
-rw-r--r--src/cpu/arm/cortex-m3/bitband.fth29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/cpu/arm/cortex-m3/bitband.fth b/src/cpu/arm/cortex-m3/bitband.fth
index e919cf4..2966409 100644
--- a/src/cpu/arm/cortex-m3/bitband.fth
+++ b/src/cpu/arm/cortex-m3/bitband.fth
@@ -10,27 +10,12 @@
\ 0 x !
\ x 0 BITBAND 1 swap c! x @ .
-1 #28 shift 1- constant BITBAND.BASEMASK_ \ covers the offset
-BITBAND.BASEMASK_ invert constant BITBAND.BASEMASK \ covers only the page
-\ 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
- \ get the bit_band_base - the starting address of the alias region.
- BITBAND.BASEMASK and
- swap
- \ get the byte_offset - the number of the byte in the bit-band region that
- \ contains the targeted bit.
- BITBAND.BASEMASK_
- and $20 *
- + +
- \ add the bit_word_offset - the position of the target bit in the bit-band
- \ memory region.
- BITBAND.OFFSET +
+: bitband ( bit adr -- aliasadr )
+ dup 5 lshift ( bit adr byte-offset ) \ Spread low part of address; high bits will be shifted out
+ swap $f000.0000 and or ( bit adr' ) \ Keep high nibble of address
+ $0200.0000 or ( bit adr' ) \ Offset to bitband alias space
+ swap la+ ( aliasadr ) \ Merge bit number as 32-bit word offset
;
-." 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
+." Test for SFR " 5 $4001140C BITBAND $42228194 = if ." Passed" else ." Failed" then CR
+." Test for RAM " #24 $200FFFFC BITBAND $23ffffe0 = if ." Passed" else ." Failed" then CR