avr: added routine to count used buffers. fixed a bug.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user