structure alignment question

Thomas H{meenaho thomas at kuling.UUCP
Wed Oct 8 20:13:10 AEST 1986


In article <7479 at sun.uucp> guy at sun.uucp (Guy Harris) writes:
>> The last 68000 compiler I used aligned strings on WORD boundaries.
>> This would cost one byte per string, half the time. But there was a
>> big speed payoff: I could do word operations in my strnlen, strncmp,
>> strncpy, and whatever other string processing functions I happened to
>> write.
>
>	char	string3[128+1];
>
>	strcpy(string3, string1);
>
>would, if it copied a word at a time, have to deal both with words of the
>form
>
>	00xx
>
>(when it recognizes a word of that form, it should stop *before* copying it
>and stuff a zero byte at the end of the target) and of the form
>
>	xx00
>
>(when it recognizes a word of that form, it should stop *after* copying it).
>

In sysV for the 68K this technique is used for bcopy inside the kernel.
bcopy is easier as one knows how many bytes are to be moved.
bzero is even smarter, it clears a set of registers and uses movem to copy
them to memory.


-- 
Thomas Hameenaho, Dept. of Computer Science, Uppsala University, Sweden
Phone: +46 18 138650
UUCP: thomas at kuling.UUCP (...!{seismo,mcvax}!enea!kuling!thomas)



More information about the Comp.lang.c mailing list