First of all, BASIC programs (and also the stub here) do not begin at $xxx0, but at $xxx1 [*] and the first 0 byte in your example is not supposed to be part of the program. Just cross-check against any BASIC program stored to disk with the SAVE command.
Second, the lines of a BASIC program all end with a 0 byte. The last line is then followed by another two 0 bytes of an empty link-pointer. The three 0 bytes signify the end of the program. If they are missing, the relink routine called after LOAD continues after the BASIC stub and corrupts the assembly program behind it (or possibly even hangs!), as you have noted.
So, here we go with the corrected version:
Code: Select all
*=$1001
!byte 0b,10,00,00,9e,34,31,30,39,00,00,00 ; 0 sys4109
lda #15
sta vol
sta bass
loop inc bass
eor bass
rol bass
ldy #0 ;delay
- iny
bne -
jmp loop
It can be loaded normally ("relative") with
",8" to the BASIC start. The absolute load with
",8,1" is only necessary for pure machine code or data that is loaded to another address than the BASIC start, and where the KERNAL load routine then takes the load address from the first two bytes of the *.prg file. These are not shown here, rather automatically prepended by the assembler before save.
That also shows why $1000 as start address is a bad choice. It actually
forces you to load the program with ",8,1" as if it was a machine program to be executed with SYS later. But it is the reason of those BASIC stubs to make a machine program easily executable with LOAD"...",8 and RUN only!
[*]: to be more precise, that 0 byte is actually stored in the address
before the BASIC start, and it is prepared so by the BASIC interpreter itself. Normally the pointer at 43/44 points to an address ending in $xxx1, like $0401, $1001 or $1201 on the VIC-20, or $0801 on the C64. You could have point it elsewhere at an address with another value than 1 as low byte. Still the requirement remains, that a 0 byte must be placed before the BASIC start - and this is in the responsibility of the party moving the BASIC start, not of the program being loaded!