The complete program is below.
The base register is "moved" through the string by increasing the address by one for each byte. This is also called "moving a pointer". This program has an important concept on every line. Using these concepts is how you program!
The program is very close to the C standard library function
int strlen(char*)
.
As it is written, the program contains its
own data,
and it is not written as a function that can be called.
In a few chapters,
we will write functions that
can be called and that use parameters.
Does the program work correctly if the string is the null string (the string of length zero that consists of just a null byte)?