Plan 9 from Bell Labs’s /usr/web/sources/contrib/cinap_lenrek/old/linuxemu.old/stack.s

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


/*
 * jump somewhere, with
 * the stack pointer set to something
 */
TEXT jumpstack(SB), 1, $0
	MOVL addr+0(FP), BX
	MOVL stack+4(FP), AX
	MOVL AX, SP
	JMP* BX

/*
 * restore registers from ureg structure and 
 * continue execution.
 * FIXME: this code sucks
 */
TEXT jumpureg(SB), 1, $0
	MOVL ureg+0(FP), AX	/* ureg in AX */
	MOVL 68(AX), SP		/* restore SP */
	SUBL $12, SP
	MOVL 28(AX), BX		/* put AX on 4(SP) */
	MOVL BX, 4(SP)
	MOVL 56(AX), BX		/* put PC on 8(SP) */
	MOVL BX, 8(SP)
	MOVL 0(AX), DI		/* restore registers */
	MOVL 4(AX), SI
	MOVL 8(AX), BP
	MOVL 16(AX), BX
	MOVL 20(AX), DX
	MOVL 24(AX), CX
	MOVL 4(SP), AX		/* restore AX */
	ADDL $8, SP
	RET

TEXT callsignal(SB), 1, $0
	MOVL sig+0(FP), CX
	MOVL handler+4(FP), BX

	PUSHL AX
	PUSHL DX
	PUSHL DI
	PUSHL SI
	PUSHL BP
	
/*	SUBL $1024, SP */
	PUSHL CX
	CALL* BX
	POPL CX
/*	ADDL $1024, SP */

	POPL BP
	POPL SI
	POPL DI
	POPL DX
	POPL AX

	RET


TEXT	_xinc(SB),$0	/* void _xinc(long *); */

	MOVL	l+0(FP),AX
	LOCK
	INCL	0(AX)
	RET

TEXT	_xdec(SB),$0	/* long _xdec(long *); */

	MOVL	l+0(FP),AX
	LOCK
	DECL	0(AX)
	JZ	iszero
	MOVL	$1, AX
	RET
iszero:
	MOVL	$0, AX
	RET

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.