Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; scopes with up to 3 effective registers could easily be optimized.
- ; ex.
- ; int countByteMatches(uint8_t *ptr, uint8_t c){
- ; int matches=0;
- ; while (*ptr){
- ; if (*ptr++==c) matches++;
- ; }
- ; return matches;
- ; }
- ;optimized code
- ;returns int
- ;inputs u8_ptr,u8
- countByteMatches:
- call ti._frameset0
- or a,a
- sbc hl,hl
- ld de,(ix+3)
- ld c,(ix+6)
- .loop:
- ld a,(de)
- inc de
- cp a,c
- jr nz,.notequal
- inc hl
- .notequal:
- or a,a
- jr nz,.loop
- ret
Advertisement
Add Comment
Please, Sign In to add comment