I compared the AROS "clearmem" code with the corresponding code in Kickstart 1.3 ($FF4EF4).
This routine is called with a BPTR in D1, and a length/count (number of longwords) in D2.
There are differences between the AROS and Kickstart versions of this routine:
- If count is negative (bit 31 set), the Kickstart routine just returns (with the original BPTR in D1 unchanged).
- If count is not negative, the Kickstart routine returns a pointer to the memory in D1. (That is, D1 on entry shifted right by 2.)
- The AROS version clears one fewer longword than the Kickstart version. Kickstart clears count+1 longwords, e.g. if D2 contain 10, the routine clears 11 longwords. Like the current AROS code, the Kickstart routine uses a DBF loop to do the clearing, so only the lower word of the length in D2 is used.
A modified version of clearmem that should behave more like the Kickstart one is below (completely untested). The Kickstart routine uses A3 as a scratch register so is slightly shorter than this.
BCPL clearmem /* -50, void, @buff, lw_length */
move.l %d1,%d0 ;Value which is returned if length negative
tst.l %d2 ;Check length
bmi.b .Done ;Do nothing if negative
lsl.l #2,%d1 ;BPTR to APTR
move.l %d1,%d0 ;Routine returns pointer to memory (maybe an undocumented feature?)
Log in to post a comment.