For the Dragon 32 and the TRS-80 Color Computer I've found two documents describing how loading from cassette tape works:Dragon 32 doc, CoCo doc.
They both say that a standard program consists of a leader, a "name block", a second leader, many data blocks, and an end block.
The three kinds of blocks all have a length. So you keep loading the next block until you get to the end block.
The "name block" contains both the load address and the execution address for machine code files.
But some .cas tape image files, which are just byte-for-byte the data that the audio modulations represent, actually put blocks in other places, presumably for copy protection. For false end blocks near the beginning or missing end blocks it's easy to guess what to do.
But when there are multiple "name blocks" it is not clear. Of course I can reset the load address that's in each name block and load all subsequent data there until the next name block changes it. But each name block also has a "default EXEC address" or "machine code starting address".
When that happens, do the latter entry addresses just overwrite the previous ways, which presumably have some decoy code to throw a red herring to crackers back in the day? Or does each code block get executed? Or maybe even the first one is the real one and the latter ones are decoys?
I can't find this behaviour documented but perhaps some of the emulators load .cas files directly without fully emulating the audio system, or some file conversion tools dealt with it? The two emulators that I have both do seem to use the audio system though, even when you select a .cas file from the menu rather than from the native BASIC OS.
I did find this commented ROM disassembly and I'm trying to figure out what it does, but I haven't been able to understand it well enough. The machine code tape loading code is at
A4FE and labelled
CLOADM, the name of the BASIC command for loading a machine code program.