Sound_ReadControlBlock can trigger an alignment Abort
Jon Abbott (1421) 2651 posts |
This isn’t really a bug, more a combination of poor documentation and a lack of validation… The documentation for Sound_ReadControlBlock doesn’t specifically state the offset in R1 needs to be word aligned, in fact it implies it doesn’t need to be, as it’s specified as “R1=0-255” both in the Wiki and the PRM. The SWI code in SoundChannels also doesn’t align the value, or check it’s aligned, so the LDR R2,[R11,R1] that loads the value will trigger a misalignment Abort on newer CPU’s if R1 is misaligned. Sound_WriteControlBlock is the same, documentation implying non-word aligned and an LDR/STR pair in the code. |
nemo (145) 2546 posts |
Shonky doc. Other documentation does describe it as reading “a word from the control block” which, being made up of aligned words, one would not try to read with an unaligned offset. And I’m not sure that “R1=0-252” is much clearer in isolation. Yes, it should check… oh hang on, it’s worse than we thought. Despite the “R1=0-255” claim, R1=255 is a failure, and not intentionally. Sound_WriteControlBlock is similarly borked. Other SoundChannels horrors: Ha! One of my bugbears: Module initialisation knows that somebody broke OS_Byte,166 – so it tries ReadSysInfo,6,71 first and then OS_Byte,166 if that fails (and similarly everyone else who needs it is forced to do exactly the same bit of extra code just to work around 166 getting broken. MOSVarFix solves that unnecessary make-work). This was always unnecessary but see other thread for the rage. InstallVoice does a signed comparison of the slot number, so negatives will have unpleasant effects (PPE required). The Voice Generator ptr is not checked for sanity. AttachNamedVoice is mostly well behaved – the name ptr doesn’t have to be aligned, but isn’t checked for silly values. Voice names are case sensitive (for no good reason)… is that mentioned anywhere? Oh, and they’re ctrl/space terminated, not null. SoundControl implements the old-style ‘infinite’ duration as a finite duration… of over 155 days. I’ll let that one slide. Bored now. |