BASIC SYS implementation
Jon Abbott (1421) 2651 posts |
I was just looking at BASIC’s code for the SYS command, to figure out why OS_CallASWI / OS_CallASWIR12 wasn’t seeing them and noticed it doesn’t use either SWI. It instead builds up an SWI instruction in memory and moves the PC to it. It doesn’t appear to issue an OS_SynchroniseCodeAreas, so I’m guessing SYS is still working because there’s always an SWI at that address. I’m suprised Acorn didn’t update this at the same time CLib was changed to use OS_CallASWI. |
Jeffrey Lee (213) 6048 posts |
Correct – that’s one of the few types of self-modifying code that ARM actually say is OK to do (since the CPU ignores the SWI number). On startup when BASIC first copies the SWI + return instruction to that location it does an OS_SynchroniseCodeAreas, so everything is fine and above board. |
Steve Drain (222) 1620 posts |
As a bit of history, BASIC originally built the SWI call on the stack. It was moved to the workspace because of the synchonise problem, I think, for version 1.16 with RO 3.7 and StrongArm. Documented in my StrongHelp BASIC manual. ;-) |