Files

70 lines
2.0 KiB
NASM

; native-entry.asm -- M5 native-object entry, linked at bit 018A0000.
;
; Calls the object produced by llc -filetype=obj and writes six markers:
; 018A8000 native_value() == 42
; 018A8020 native_combo() == 152 (42 + 'n')
; 018A8040 native_bump() == 1
; 018A8060 native_bump() == 2
; 018A8080 native_loop(5) == 10
; 018A80A0 native_call_external() == 77
;
; native_combo() calls native_value() and native_first(); both are .text
; symbols, so the CALLAs are same-section 0xFFFF relocations. The
; cross-section section-symbol relocation path is exercised by native_first()'s
; MOVI to the .data object msg and native_bump()'s MOVI to the .bss object
; native_counter. native_loop() carries the conditional/unconditional branch
; relocations. native_external() is defined here and is an undefined C_EXT
; reference in the llc object. The object is assembled separately with GSPA
; 2.00 and the two objects are linked by GSPLNK 2.00.
.ref _native_value
.ref _native_combo
.ref _native_bump
.ref _native_loop
.ref _native_call_external
.text
.globl _native_entry
_native_entry:
setf 16, 1, 0
setf 32, 0, 1
movi _cstack, a14
move a14, a13
calla _native_value
move a8, @018A8000h, 1
calla _native_combo
move a8, @018A8020h, 1
calla _native_bump
move a8, @018A8040h, 1
calla _native_bump
move a8, @018A8060h, 1
move a14, -*sp, 1
movi 5, a0
move a0, *a14+, 1
calla _native_loop
move a8, @018A8080h, 1
calla _native_call_external
move a8, @018A80A0h, 1
rets
.globl _native_external
_native_external:
; Same prologue/epilogue as an llc-compiled leaf so native_call_external
; gets the A14 frame it expects on return.
setf 16, 1, 0
setf 32, 0, 1
move a13, -*sp, 1
move a0, -*sp, 1
move a14, a13
addi 32, a14
move a13, a0
addi -32, a0
move *a0, a0, 1
movi 77, a0
move a0, a8
move *sp(96), a14, 1
move *sp+, a0, 1
move *sp+, a13, 1
rets 2
.bss _cstack, 32768, 16
.end