shithub: riscv

ref: 14ac74fce1017b5c23ff4aed6f0289ab82bf71a2
dir: /sys/src/ape/lib/ap/386/main9p.s/

View raw version
#define NPRIVATES	16

GLOBL	_tos(SB), $4
GLOBL	_errnoloc(SB), $4
GLOBL	_plan9err(SB), $4
GLOBL	_privates(SB), $4
GLOBL	_nprivates(SB), $4

TEXT	_mainp(SB), 1, $(12+4+128+NPRIVATES*4)

	/* _tos = arg */
	MOVL	AX, _tos(SB)
	LEAL	12(SP), AX
	MOVL	AX, _errnoloc(SB)
	ADDL	$4, AX
	MOVL	AX, _plan9err(SB)
	ADDL	$128, AX
	MOVL	AX, _privates(SB)
	MOVL	$NPRIVATES, _nprivates(SB)

	/* _profmain(); */
	CALL	_profmain(SB)

	/* _tos->prof.pp = _tos->prof.next; */
	MOVL	_tos+0(SB),DX
	MOVL	4(DX),CX
	MOVL	CX,(DX)

	CALL	_envsetup(SB)

	/* main(argc, argv, environ); */
	MOVL	inargc-4(FP), AX
	MOVL	AX, 0(SP)
	LEAL	inargv+0(FP), AX
	MOVL	AX, 4(SP)
	MOVL	environ(SB), AX
	MOVL	AX, 8(SP)
	CALL	main(SB)
loop:
	MOVL	AX, 0(SP)
	CALL	exit(SB)
	MOVL	$_profin(SB), AX	/* force loading of profile */
	MOVL	$0, AX
	JMP	loop

TEXT	_saveret(SB), 1, $0
TEXT	_savearg(SB), 1, $0
	RET

TEXT	_callpc(SB), 1, $0
	MOVL	argp+0(FP), AX
	MOVL	4(AX), AX
	RET