[SLOF] [PATCH 3/5] base: Move cnt-bits and bcd-to-bin to board-js2x folder

Nikunj A Dadhania nikunj at linux.vnet.ibm.com
Fri Apr 29 17:35:35 AEST 2016


Thomas Huth <thuth at redhat.com> writes:

> These functions are only used by some ancient js2x code,
> so move them to that folder accordingly.
>
> Signed-off-by: Thomas Huth <thuth at redhat.com>

Reviewed-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>

> ---
>  board-js2x/slof/helper.fs |  9 +++++++++
>  board-js2x/slof/rtc.fs    |  4 ++++
>  slof/fs/base.fs           | 13 -------------
>  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
> -- 
> 1.8.3.1
>
> _______________________________________________
> SLOF mailing list
> SLOF at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/slof



More information about the SLOF mailing list