setjmp.s,v

来自「TCP-IP红宝书源代码」· S,V 代码 · 共 69 行

S,V
69
字号
head	1.1;
access;
symbols;
locks
	dls:1.1; strict;
comment	@# @;


1.1
date	97.09.21.19.27.40;	author dls;	state Dist;
branches;
next	;


desc
@@


1.1
log
@pre-3e code
@
text
@|setjmp, longjmp
|
|	longjmp(a, v)
|causes a "return(v)" from the
|last call to
|
|	setjmp(v)
|by restoring all the registers and
|adjusting the stack
|
|jmp_buf is set up as:
|
|	_________________
|	|	pc	|
|	-----------------
|	|	d2	|
|	-----------------
|	|	...	|
|	-----------------
|	|	d7	|
|	-----------------
|	|	a2	|
|	-----------------
|	|	...	|
|	-----------------
|	|	a7	|
|	-----------------

	.globl setjmp, longjmp
	.text

setjmp:
	movl	sp@@(4),a0	|pointer to jmp_buf
	movl	sp@@,a0@@		|pc
	moveml	#0xFCFC,a0@@(4)	|d2-d7, a2-a7
	clrl	d0		|return 0
	rts

longjmp:
	movl	sp@@(4),a0	|pointer to jmp_buf
	movl	sp@@(8),d0	|value returned
	moveml	a0@@(4),#0xFCFC	|restore d2-d7, a2-a7
	movl	a0@@,sp@@		|restore pc of call to setjmp to stack
	rts
@

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?