Looks good, but I would stay away from assembler since JALv2 may
eventually support other processors.

Matt.

On Jan 9, 2:28 am, Oliver Seitz <[email protected]> wrote:
> > All kind of shortcuts are possible (like an effective
> > byte
> > routine and split words/dwords in chunck of 100 rather than
> > 10). But
> > they all take more flash and that is most precious...
>
> We could try that ;-)
>
> Here's the two-digit-procedure. Sorry, it is in assembler...
>
> --
> -- clear this bit when starting to output a number. It will be set
> -- by the procedure as soon as the first non-zero digit has been
> -- printed.
> var bit _print_display_first_zero=false
> --
> -- set this bit only when printing the last two digits of a number.
> -- It will make sure that if the number is zero, exactly one "0" is
> -- printed.
> var bit _print_display_last_zero=false
>
> procedure _print_two_digits_fast(volatile byte out device, byte in data) is
>
> -- Prints two digits to device.
> -- Do not call with data>99, it will print garbage.
>
> var bit _print_first_digit, _print_last_digit
>
>   assembler
>
>     LOCAL       _divide_10_loop, l_print_first_digit, l_print_last_digit
>
>     movlw       "0"-1
>     movwf       digit
>     movlw       10
> _divide_10_loop:
>     incf        digit,f
>     subwf       data,f
>     btfsc       STATUS_C
>     goto        _divide_10_loop
>     movlw       "0"+10
>     addwf       data,f
>
>     bsf         _print_last_digit
>
>     bsf         _print_first_digit
>     btfsc       _print_display_first_zero
>     goto        l_print_last_digit
>     movlw       "0"
>     xorwf       digit,w
>     btfss       STATUS_Z
>     goto        l_print_last_digit
>     bcf         _print_first_digit
>
> l_print_first_digit:
>
>     btfsc       _print_display_last_zero
>     goto        l_print_last_digit
>     movlw       "0"
>     xorwf       data,w
>     btfsc       STATUS_Z
>     bcf         _print_last_digit
> l_print_last_digit:
>
>     btfsc       _print_first_digit
>     bsf         _print_display_first_zero
>     btfsc       _print_last_digit
>     bsf         _print_display_first_zero
>
>   end assembler
>
>   if _print_first_digit then
>     device=digit
>   end if
>
>   if _print_last_digit then
>     device=data
>   end if
>
> end procedure
>
> Does anyone know if I have to take measures to ensure correct banking, or 
> does the compiler care about that automatically?
>
> The procedure should use about 50 words of code, and it executes in an 
> average of 84 instruction cycles.
>
> Greets,
> Kiste

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to