It's possible to position your machine language routines between DOS and its first file buffer so that they won't be overwritten by BASIC programs.
Since $9D00 and $9D01 (48K system) point into the first, highest buffer:
1. Add the number of pages (256 byte blocks) your routine needs to the contents of $9D01.
2. Put a $00 in the address now pointed at by the contents of $9D00, $9D01.
3. Store a $00 at the address pointed at by the contents of $9D00, $9D01 plus $25.
4. Perform a JSR $A7D4 to rebuild the DOS file buffers and move the current BASIC's HIMEM down.
The first available address for your routine is the address pointed at by the contents of $9D00, $9D01 plus $2D.