Adding txt file of routine since Github does not like my formatting??? See below for attachment.
Assuming register A2 as the source register as per string.s, returning length in register D0
Fastest byte string lenght routine using post-increment and initial string address to compute length returned in register D0
_strlen
MOVE.L A2,D0 ;lsave the startaddress of our string into register D0 ;
StringsizeLoop: ; our test .loop label, take notice of the ":" at the end
TST.B (A2)+ ; test character A2 points to + post-increment the address pointer to next character
BNE.S StringsizeLoop ; is character not equal to 0, check next (remember, it is c-style Null terminated)
SUB. L D0,A2 ; we found end of c-style string terminator, so substact the start from the end
MOVE.l A2,D0 ;move the result to data register d0 for returning the value
SUBQ.L #1,d0 ; substract 1 from the result since it points to the C-style Null-terminator!
RTS
_strlen.txt
Adding txt file of routine since Github does not like my formatting??? See below for attachment.
Assuming register A2 as the source register as per string.s, returning length in register D0
Fastest byte string lenght routine using post-increment and initial string address to compute length returned in register D0
_strlen
MOVE.L A2,D0 ;lsave the startaddress of our string into register D0 ;
StringsizeLoop: ; our test .loop label, take notice of the ":" at the end
TST.B (A2)+ ; test character A2 points to + post-increment the address pointer to next character
BNE.S StringsizeLoop ; is character not equal to 0, check next (remember, it is c-style Null terminated)
SUB. L D0,A2 ; we found end of c-style string terminator, so substact the start from the end
MOVE.l A2,D0 ;move the result to data register d0 for returning the value
SUBQ.L #1,d0 ; substract 1 from the result since it points to the C-style Null-terminator!
RTS
_strlen.txt