Files
arti 41b0979aef c-hello: first C program on the VT1200, running on real hardware
The 1987 TI K&R toolchain already compiled and linked a fib test, but nothing
had ever been executed on a VT1200. This is that program: hello.c draws HELLO
into video RAM (1 bpp, bit 0x04000000, no X11) and is loaded through the COFF
loader with hostload.py, on the real unit and in MAME.

Two runtime traps shaped the design, both recorded in the README:

  * boot.obj's exit() is `for(;;)` and _c_int00 ends in `reti`.  That is a
    standalone-ROM runtime, not a process: the child spun forever, and because
    the VT1200 OS is cooperative it took the whole terminal down (illegal
    opcode on hardware).  entry.asm replaces boot.obj -- set STK/FP, call
    _main, `rets` back to the create_process trampoline, the same return
    xhello uses -- and the image carries no .cinit (tables are built in code).
  * Pointers are bit addresses and pointer arithmetic scales by object size,
    so p + n on a char * is n bytes.  The pre-fix frame in evidence/ is that
    bug: 32 one-byte bars spread across a row.

Framebuffer geometry is not portable: the real unit is 1280 px wide at a
256-byte row pitch, MAME's canvas is 1024 px at 128.  build.sh builds both
(ROW_BYTES), and the README records how the real pitch was measured from a
real-unit frame rather than taken from MAME.

Evidence: real-unit frames in harness/c-hello/evidence/ (the pre-fix stripes
and the working HELLO), and dwt/loader/evidence/real-unit-xhello/ for the X
window that ran on the unit earlier.
2026-10-29 18:25:38 +02:00

36 lines
1.6 KiB
Plaintext

GSP COFF Assembler, Version 2.00, 87.300 Thu Oct 29 18:24:36 2026
(c) Copyright 1985, 1987, Texas Instruments Inc.
PAGE 1
0001 ; entry.asm -- process entry for the C hello world.
0002 ;
0003 ; The C runtime's boot.obj is designed for a ROM system
0004 ; *system* stack), calls main, calls exit (which is `fo
0005 ; `reti`. None of that fits a process made by the VT12
0006 ; the spin never yields, and `reti` returns from an int
0007 ; happened (it pops a garbage PC -> illegal opcode).
0008 ;
0009 ; So we enter here instead: set the C program stack (ST
0010 ; main, and `rets` back to the create_process trampolin
0011 ; xhello payload uses. SP (the OS's interrupt stack) i
0012 ;
0013 ; _cstack is 4096 bytes; the compiler grows the program
0014
0015 00000000 .text
0016 .globl _start
0017 .globl _main
0018 00000000 _start:
0019 00000000 0740 setf 32, 0, 1
0020 00000010 09EE movi _cstack, a14
00000020 00000000+
0021 00000040 4DCD move a14, a13
0022 00000050 0D5F calla _main
00000060 00000000!
0023 00000080 0960 rets
0024
0025 00000000 .bss _cstack, 32768, 16 ; 32768 bits = 4096 bytes
0026 .end
No Errors, No Warnings