Elektronika MK-90 - machine code programming

The first 512 bytes of the memory module contain a boot loader program which can be loaded and executed by selecting the SMP0 or SMP1 entry from the start menu.
The code is loaded into the RAM locations 0x0000-0x01FF, then executed from the address 0x0000.
The stack pointer (SP) is initialised to 0x0200.
The first instruction (at the location 0x0000) must be a NOP (opcode 0x00A0).

The default loader written by the INIT command simply displays a message "SMP without loader" then locks the system, but the programmer makes possible to put there own machine code programs.
Currently it's the only known way to run machine code on BASIC 1.0 systems (BASIC 2.0 provides this feature with the command PATCH).

Sample programs

This program can automatically execute any predefined sequence of BASIC instructions at the boot from the memory module.
In particular, it allows to load and run a BASIC program with only two key strokes.
In the example code the command LOAD"SMx:AUTO",R is executed.
Any occurrence of the lower-case character x in the command string is replaced by the loader with 0 or 1, depending on the slot from which it was booted.Note: In the BASIC 2.0 the option R of the instruction LOAD doesn't seem to work, at least on the emulator.

This program permanently disables the start menu and immediately skips to the BASIC interpreter after power-on or reset.
It modifies the reset vector stored in the battery backed RAM in the Real Time Clock chip so that it points to the BASIC interpreter "cold start" instead of the usual "welcome screen" routine.
There don't seem to be any other possible entry points in the ROM.
To reverse the changes the batteries have to be removed from the calculator for a while.Note: Unlike a real MK-90, the emulated one intentionally doesn't preserve the battery backed RAM contents between sessions!

The program repeatedly draws a horizontal line in the middle of the screen.
Every 31.25ms the timer interrupt routine adds another pixel.
Therefore the time needed to draw an entire line should be 120*31.25ms=3.75s.
If the program is terminated with the Reset key, the calculator displays the "welcome screen", but still continues to draw the line.
It's because the system software doesn't set up the RTC chip properly.
Selecting BASIC from this state crashes the system.
To make the calculator operable again, the batteries have to be removed for a while.

This machine code program implements Conway's Game of Life.
Because its size exceeds 512 bytes, it has to be stored in the cartridge data area.
In order to prevent the system from overwriting it, the value at the location 0x0412 (in the cartridge directory area) is changed from 0x10 to 0x0D.
This step allocates three last sectors for machine code programs of size up to 1.5 kBytes, leaving the remaining space of 6.5 kBytes available for the system.
The original boot loader is replaced by another one reading the code from the three last sectors to the RAM, then starting it.

Since the program doesn't use any ROM calls, it should work with any BASIC version.
The program can be terminated only by the reset key or power switch.