> > Sorry, it is in assembler...
> 
> I'm afraid you're on your own then. I don't understand pic
> assembler.

No problem, I'm quite familiar :-)

> Also, I'd say it is not a good idea to use assembler in
> jalllib's. But
> that's probably because I don't understand ;)

Well, I can understand that. And in many cases, it does not help to use 
assembler, as the compiler is really good and most things run fast with low 
ressources. But if you can improve the innermost loop of a frequently called 
procedure you're saving real lots of cycles and some code words. I can compare 
this procedure to a JAL variant, but I presume the JAL will take at least twice 
the code and cycles.

I think, assembler can be used in some places. Of course, those are libs for 
JAL. But you do not demand that the compiler had to be programmed in JAL, too. 
And you don't have to understand how a diesel engine works to ride on the bus. 
If the assembler part is tested, and it is clearly explained what it does so 
that everyone can use it, I think it can go in a lib.

If e.g. the hardware multiplier was used that is only there on 18F devices and 
upward, things would be different. Then there had to be two routines, one for 
18F up, and one for 16F down devices, conditionally compiled. But in this case 
there are only simple commands every PIC understands.


> Btw, did you extended the 'not_printed_yet' stuff for this
> routine? It
> could be passed on as false, and (in an other case)
> returned as true.

Sorry, I just started writing without looking at the lib first.

My bit "_print_display_first_zero" was exactly not "no_digits_printed_yet"

Here's the version that fits the lib, haven't compiled it, though. Might 
contain typos.

--
-- set this bit when starting to output a number. It will be cleared
-- by the procedure as soon as the first non-zero digit has been
-- printed.
var bit no_digits_printed_yet=true
--
-- 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_last_pair=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
    btfss       no_digits_printed_yet
    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_last_pair
    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
    bcf         no_digits_printed_yet
    btfsc       _print_last_digit
    bcf         no_digits_printed_yet

  end assembler

  if _print_first_digit then
    device=digit
  end if

  if _print_last_digit then
    device=data
  end if

end procedure



-- 
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