1

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!

1
  • You seem to have some confusion about RAM. By design, the program does not know where physically the data is (RAM, cache, hard disk, tape drive...). As far as your program is concerned, in both C and assembly, the data is "in memory". When the data is requested, the hardware will take care of moving it to where it needs to be. Commented Jan 22, 2014 at 16:18

2 Answers 2

1
  • 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.

Sign up to request clarification or add additional context in comments.

Comments

1

"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.

2 Comments

Okay, so nothing else in the array can be that null termination. ...*headdesk* Of course not, otherwise the array would be considered over. Feeling kinda dumb.
And that holds only C strings. Not any arrays - even chatacter arrays. Some other languages use length-field in string implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.