Question

I'm writing a CRC32 program in assembler on an ARM "beagleboard", and for it I need to find the end of a char array in memory. The program is given (from a C framework) a pointer to the start of the array, and we need to iterate over the array. It is not known beforehand how large the array will be, and I'm not sure I'm allowed to check that in C and give that to the function as a variable, or even how that would work. Normally if I was coding this in C I'd just look for'\0', but when accessing this from RAM in assembler, that's just going to look like a byte full of zeroes. Is that still useful? Is there another way to detect the end of the array?

Thanks in advance!

Was it helpful?

Solution

  • Normally if I was coding this in C I'd just look for'\0'

Why does asm have to be any different? In any language I choose I can simply iterate through the bytes looking for a zero byte. The language is irrelevant. ASM is a language as is C or pascal or java, etc. If it is a zero terminated C string then whatever language you simply look for a zero.

C, asm, etc ram is ram an address is an address, so here again it has nothing to do with it, you have a starting address you iterate through until you find the zero byte.

Am I misunderstanding the question? Is your "string" not a C string, not zero terminated? If it isnt then your string by definition has to have some well known (to both sides) termination and or length specification. And then once you have defined that well known termination you simply implement that in whatever language you choose.

OTHER TIPS

"A byte full of zeroes" is still useful! If the array is null terminated, then you just need to find those 8 bits set to zero.

The tricky part is that the word size (the number of bits used in basic instructions) is probably something like 32 or 64 bits, not 8. So you will need to be able to isolate (mask) each 8 bit chunk of the word to check if it is set to all zeroes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top