| 72 |
.type _U(strstr), @function |
.type _U(strstr), @function |
| 73 |
_U(strstr): |
_U(strstr): |
| 74 |
|
|
| 75 |
LOAD_X(s1_lo, s1_hi) |
X_movw XL, s1_lo |
| 76 |
LOAD_Z(s2_lo, s2_hi) |
X_movw ZL, s2_lo |
| 77 |
ld chr2, Z+ |
ld chr2, Z+ |
| 78 |
tst chr2 ; is str2 empty? |
tst chr2 ; is str2 empty? |
| 79 |
brne .L_findstart |
brne .L_findstart |
| 80 |
ret ; return original string (req'd by standard) |
ret ; return original string (req'd by standard) |
| 81 |
|
|
| 82 |
.L_findstart: |
.L_findstart: |
| 83 |
LOAD_Z(s2_lo, s2_hi) ; reset Z pointer |
X_movw ZL, s2_lo ; reset Z pointer |
| 84 |
ld chr2, Z+ ; fetch first char |
ld chr2, Z+ ; fetch first char |
| 85 |
|
|
| 86 |
.L_findstart_loop: ; Find first char |
.L_findstart_loop: ; Find first char |
| 88 |
tst chr1 ; Is str1 @ end? |
tst chr1 ; Is str1 @ end? |
| 89 |
breq .L_no_match ; then return |
breq .L_no_match ; then return |
| 90 |
cp chr1, chr2 ; Is chr1 == chr2? |
cp chr1, chr2 ; Is chr1 == chr2? |
| 91 |
|
X_movw ret_lo, XL ; store return value |
|
mov ret_lo, XL ; store return value |
|
|
mov ret_hi, XH |
|
|
|
|
| 92 |
brne .L_findstart_loop ; If, then start checking string |
brne .L_findstart_loop ; If, then start checking string |
| 93 |
|
|
| 94 |
.L_stringloop: |
.L_stringloop: |