aboutsummaryrefslogtreecommitdiff
path: root/board-js2x
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2016-04-29 09:01:18 +0200
committerAlexey Kardashevskiy <aik@ozlabs.ru>2016-05-02 14:06:10 +1000
commit18b95561227f69e6441ee090d517f95f6e8acfbe (patch)
treed077f265eb37f13cc7e16f01b8ce8bdb1fa5ac03 /board-js2x
parenta78bbb304903dfbfe4320d2f8f3c6526839dfb68 (diff)
downloadSLOF-18b95561227f69e6441ee090d517f95f6e8acfbe.zip
SLOF-18b95561227f69e6441ee090d517f95f6e8acfbe.tar.gz
SLOF-18b95561227f69e6441ee090d517f95f6e8acfbe.tar.bz2
base: Move cnt-bits and bcd-to-bin to board-js2x folder
These functions are only used by some ancient js2x code, so move them to that folder accordingly. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'board-js2x')
-rw-r--r--board-js2x/slof/helper.fs9
-rw-r--r--board-js2x/slof/rtc.fs4
2 files changed, 13 insertions, 0 deletions
diff --git a/board-js2x/slof/helper.fs b/board-js2x/slof/helper.fs
index 1e2b030..c522c90 100644
--- a/board-js2x/slof/helper.fs
+++ b/board-js2x/slof/helper.fs
@@ -37,3 +37,12 @@
ENDCASE
drop
;
+
+\ count the number of bits equal 1
+\ the idea is to clear in each step the least significant bit
+\ v&(v-1) does exactly this, so count the steps until v == 0
+: cnt-bits ( 64-bit-value -- #bits=1 )
+ dup IF
+ 41 1 DO dup 1- and dup 0= IF drop i LEAVE THEN LOOP
+ THEN
+;
diff --git a/board-js2x/slof/rtc.fs b/board-js2x/slof/rtc.fs
index 861b3f9..5d5dbc3 100644
--- a/board-js2x/slof/rtc.fs
+++ b/board-js2x/slof/rtc.fs
@@ -40,6 +40,10 @@
\ PC87417.pdf page 156 (chapter 8.3.15) - RTC Control Register C
00 0c rtc!
+: bcd-to-bin ( bcd -- bin )
+ dup f and swap 4 rshift a * +
+;
+
\ read from the rtc and do the bcd-to-bin conversion
: rtc-bin@ ( offset -- value )
rtc@ bcd-to-bin