aboutsummaryrefslogtreecommitdiff
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
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>
-rw-r--r--board-js2x/slof/helper.fs9
-rw-r--r--board-js2x/slof/rtc.fs4
-rw-r--r--slof/fs/base.fs13
3 files changed, 13 insertions, 13 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
diff --git a/slof/fs/base.fs b/slof/fs/base.fs
index e30311c..62cfb00 100644
--- a/slof/fs/base.fs
+++ b/slof/fs/base.fs
@@ -42,19 +42,6 @@ VARIABLE mask -1 mask !
: 0.r 0 swap <# 0 ?DO # LOOP #> type ;
-\ 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
-;
-
-: bcd-to-bin ( bcd -- bin )
- dup f and swap 4 rshift a * +
-;
-
\ calcs the exponent of the highest power of 2 not greater than n
: 2log ( n -- lb{n} )
8 cells 0 DO 1 rshift dup 0= IF drop i LEAVE THEN LOOP