avr: added routine to count used buffers. fixed a bug.

This commit is contained in:
Martin Preuss
2025-02-14 22:42:46 +01:00
parent 6e25647c0a
commit b60de3994c
2 changed files with 43 additions and 1 deletions

View File

@@ -108,5 +108,32 @@ l_end:
; ---------------------------------------------------------------------------
; @macro m_fixedbuf_count_used
;
; @return r16 number of buffers in use
; @param X pointer to start of buffers
; @param %0 constant maxBytes per buffer (including statusbyte in front)
; @param %1 constant maxBuffers
; @clobbers r16, r17, r18, X
.macro m_fixedbuf_count_used
clr r16
ldi r17, @1
l_loop:
ld r18, X
tst r18
breq l_notused
inc r16
l_notused:
adiw xh:xl, @0
dec r17
brne l_loop
l_end:
.endmacro
; @end