Smallest vCPU program

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice.
Post Reply
User avatar
Posts: 283
Joined: 13 May 2018, 08:26

Smallest vCPU program

Post by marcelk » 18 Jun 2019, 23:36

The smallest vCPU application

1. Gives identifiable visual feedback:
- Draws two colored lines (one vertical, one horizontal)
- Continuously blinks a pixel

2. Is interactive:
- Shifts the screen when a button is pressed, restores when released
- Changes line color when this button is an arrow button

3. Behaves consistent and doesn't crash:
- Is compatible with all ROM versions, past, present and future
- Doesn't rely on undocumented features
- Doesn't accidently clobber system variables

4. Is as small as possible
- Occupies 6 bytes of RAM (3 vCPU instructions)
- Loads at a non-intrusive memory location

Annotated screen capture
Smallest.png (190.11 KiB) Viewed 137 times

Code: Select all

 * file: Docs/Smallest.gt1
 0207  21 0e                    LDW   frameCount         |!.|
 0209  f3 17                    DOKE  vPC+1              |..|
 020d  90 07                    BRA   $0209              |..|
 * 6 bytes

 * start at $0207

Believe it or not, there's actually an application for this: to provide some kind of defined behaviour in case a GT1 file is loaded on a Gigatron with an older ROM than required. You don't want it to crash when using functions that aren't present. But you still want it to behave in a manner that's identifiable. The GT1 file itself is responsible, because the Loader wouldn't know any better. So it must be as small as possible(*). A bit silly? Oh sure!

Details on the workings in the comments of Docs/Smallest.gcl.

(*) I guess it's a bit akin to the message "This program cannot be run in DOS mode" present in Windows executables. Same idea, but smaller.
GT1 file
(12 Bytes) Downloaded 4 times

Post Reply