48 lines
1.7 KiB
NASM
48 lines
1.7 KiB
NASM
; runtime-entry.asm -- M6 runtime gate entry, linked at bit 018A0000.
|
|
;
|
|
; Sets the TI C field sizes, points STK/FP at the gate stack, calls the C
|
|
; driver runtime_run() and writes a post-return marker. runtime.sh
|
|
; concatenates the compiled driver and the shared conformance shim after this
|
|
; file, so _runtime_run, printf/sprintf and the string/memory functions share
|
|
; one assembly.
|
|
;
|
|
; The marker array is in .bss (linked at the ram origin); runtime-check.lua
|
|
; reads its address from the linker map and checks 13 words (0..12 written by
|
|
; the driver), 15 after runtime_run returns, and leaves 13..14 zero/unchecked.
|
|
; Marker n is 0x20 bits above marker n-1.
|
|
;
|
|
; The shim's printf output goes to its own CONF_* block above the linked RAM
|
|
; region (length at 01B00020h, bytes at 01B10000h); the checker compares those
|
|
; bytes with the expected text.
|
|
;
|
|
; GSPA requires `.ref` for an external symbol used by CALLA. The AsmPrinter
|
|
; emits it for the flib `$` ExternalSymbols but not for an ordinary C
|
|
; declaration (a GlobalAddress), so declare the rts.lib entry here.
|
|
.ref _isascii
|
|
.text
|
|
.globl _start
|
|
_start:
|
|
setf 16, 1, 0
|
|
setf 32, 0, 1
|
|
|
|
; Clear the shim's stream lengths. This entry does not otherwise touch
|
|
; the result block, and the shim's shadows cannot repair a cell it never
|
|
; writes (an empty stream), so clear both cells here.
|
|
movi 01B00020h, a1
|
|
sub a0, a0
|
|
move a0, *a1, 1
|
|
movi 01B00060h, a1
|
|
move a0, *a1, 1
|
|
|
|
movi _cstack, a14
|
|
move a14, a13
|
|
calla _runtime_run
|
|
movi 5A5A5A5Ah, a0
|
|
movi _runtime_markers+480, a2 ; marker 15, the post-return word
|
|
move a0, *a2, 1
|
|
rets
|
|
|
|
.globl _runtime_markers
|
|
.bss _runtime_markers, 512, 16 ; 16 marker words (0x20 bits each)
|
|
.bss _cstack, 32768, 16 ; 32768 bits = 4096 bytes
|