Files
2026-11-13 20:09:55 +00:00

29 lines
1.1 KiB
NASM

; varargs-entry.asm -- M6 varargs gate entry, linked at bit 018A0000.
;
; Sets the TI C field sizes, points STK/FP at the gate stack, calls the C
; driver varargs_run() and writes a post-return marker. varargs.sh
; concatenates the llc output for m6-varargs.ll and the compiled driver after
; this file, so _varargs_run and the variadic functions share one assembly.
;
; The marker array is in .bss (linked at the ram origin); varargs-check.lua
; reads its address from the linker map and checks 15 words (markers 0..14, the
; last one written after varargs_run returns). Marker n is 0x20 bits above
; marker n-1. varargs_out is the formatted-output buffer defined by the C
; driver (zero-initialized .bss); the checker also reads its bytes.
.text
.globl _start
_start:
setf 16, 1, 0
setf 32, 0, 1
movi _cstack, a14
move a14, a13
calla _varargs_run
movi 5A5A5A5Ah, a0
movi _varargs_markers+448, a2 ; marker 14, the post-return word
move a0, *a2, 1
rets
.globl _varargs_markers
.bss _varargs_markers, 512, 16 ; 15 marker words (0x20 bits each)
.bss _cstack, 32768, 16 ; 32768 bits = 4096 bytes