avr: added List_GetItemAt
This commit is contained in:
@@ -241,6 +241,42 @@ List_ForEveryObject_callZ:
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine List_GetItemAt
|
||||
|
||||
; @param Y pointer to first object in a list
|
||||
; @param r16 idx (starting with 0)
|
||||
; @return CFLAG set if found, cleared otherwise
|
||||
; @return X list element at given idx (if CFLAG set)
|
||||
; @clobbers r16, r17
|
||||
|
||||
List_GetItemAt:
|
||||
push yl
|
||||
push yh
|
||||
mov r17, yl
|
||||
or r17, yh
|
||||
clc
|
||||
breq List_GetItemAt_done
|
||||
List_GetItemAtLoop:
|
||||
tst r16
|
||||
breq List_GetItemAt_found
|
||||
ldd r17, Y+LIST_OFFS_NEXT_LO
|
||||
ldd yh, Y+LIST_OFFS_NEXT_HI
|
||||
mov yl, r17
|
||||
or r17, yh
|
||||
clc
|
||||
breq List_GetItemAt_done
|
||||
dec r16
|
||||
rjmp List_GetItemAtLoop
|
||||
List_GetItemAt_found:
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
sec
|
||||
List_GetItemAt_done:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user