⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 o32.s

📁 this gcc-g++-3.3.1.tar.gz is a source file of gcc, you can learn more about gcc through this codes f
💻 S
字号:
/* -----------------------------------------------------------------------   o32.S - Copyright (c) 1996, 1998  Cygnus Solutions      MIPS Foreign Function Interface    Permission is hereby granted, free of charge, to any person obtaining   a copy of this software and associated documentation files (the   ``Software''), to deal in the Software without restriction, including   without limitation the rights to use, copy, modify, merge, publish,   distribute, sublicense, and/or sell copies of the Software, and to   permit persons to whom the Software is furnished to do so, subject to   the following conditions:   The above copyright notice and this permission notice shall be included   in all copies or substantial portions of the Software.   THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR   OTHER DEALINGS IN THE SOFTWARE.   ----------------------------------------------------------------------- */#define LIBFFI_ASM	#include <ffi.h>/* Only build this code if we are compiling for o32 */	#if defined(FFI_MIPS_O32)	#define callback a0#define bytes	 a2#define flags	 a3		#define SIZEOF_FRAME	( 4 * SIZEOF_ARG + 2 * SIZEOF_ARG )	.text	.align	2	.globl	ffi_call_O32	.ent	ffi_call_O32ffi_call_O32:		# Prologue	SUBU	$sp, SIZEOF_FRAME			# Frame size	REG_S	$fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp)	# Save frame pointer	REG_S	ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp)	# Save return address	move	$fp, $sp	move	t9, callback	# callback function pointer	REG_S	flags, SIZEOF_FRAME + 3*SIZEOF_ARG($fp) # flags	# Allocate at least 4 words in the argstack	move	v0, bytes	bge	bytes, 4 * SIZEOF_ARG, bigger		LI	v0, 4 * SIZEOF_ARG	b	sixteenbigger:		ADDU	t0, v0, 2 * SIZEOF_ARG -1	# make sure it is aligned 	and	v0, t0, -2 * SIZEOF_ARG		# to an 8 byte boundrysixteen:	SUBU	$sp, $sp, v0	# move the stack pointer to reflect the				# arg space	ADDU	a0, $sp, 4 * SIZEOF_ARG	ADDU	a3, $fp, SIZEOF_FRAME + 3*SIZEOF_ARG	jal	t9		REG_L	t0, SIZEOF_FRAME + 3*SIZEOF_ARG($fp)  # load the flags word	add	t2, t0, 0			   # and copy it into t2	and     t0, ((1<<4)-1)          # mask out the return type	SRL	t2, 4			# shift our arg info			ADDU	$sp, $sp, 4 * SIZEOF_ARG	# adjust $sp to new args	bnez	t0, pass_d			# make it quick for int	REG_L	a0, 0*SIZEOF_ARG($sp)		# just go ahead and load the	REG_L	a1, 1*SIZEOF_ARG($sp)		# four regs.	REG_L	a2, 2*SIZEOF_ARG($sp)	REG_L	a3, 3*SIZEOF_ARG($sp)	b	call_itpass_d:	bne	t0, FFI_ARGS_D, pass_f	l.d	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args	REG_L	a2,   2*SIZEOF_ARG($sp)	# passing a double	REG_L	a3,   3*SIZEOF_ARG($sp)	b	call_itpass_f:		bne	t0, FFI_ARGS_F, pass_d_d	l.s	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args	REG_L	a1,   1*SIZEOF_ARG($sp)	# passing a float	REG_L	a2,   2*SIZEOF_ARG($sp)	REG_L	a3,   3*SIZEOF_ARG($sp)	b	call_it		pass_d_d:			bne	t0, FFI_ARGS_DD, pass_f_f	l.d	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args	l.d	$f14, 2*SIZEOF_ARG($sp)	# passing two doubles	b	call_itpass_f_f:		bne	t0, FFI_ARGS_FF, pass_d_f	l.s	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args	l.s	$f14, 1*SIZEOF_ARG($sp)	# passing two floats	REG_L	a2,   2*SIZEOF_ARG($sp)	REG_L	a3,   3*SIZEOF_ARG($sp)	b	call_itpass_d_f:			bne	t0, FFI_ARGS_DF, pass_f_d	l.d	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args	l.s	$f14, 2*SIZEOF_ARG($sp)	# passing double and float	REG_L	a3,   3*SIZEOF_ARG($sp)	b	call_itpass_f_d:		 # assume that the only other combination must be float then double #	bne	t0, FFI_ARGS_F_D, call_it	l.s	$f12, 0*SIZEOF_ARG($sp)	# load $fp regs from args	l.d	$f14, 2*SIZEOF_ARG($sp)	# passing double and floatcall_it:		# Load the function pointer	REG_L	t9, SIZEOF_FRAME + 5*SIZEOF_ARG($fp)	# If the return value pointer is NULL, assume no return value.	REG_L	t1, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)	beqz	t1, noretval	bne     t2, FFI_TYPE_INT, retfloat	jal	t9	REG_L	t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)	REG_S	v0, 0(t0)	b	epilogueretfloat:	bne     t2, FFI_TYPE_FLOAT, retdouble	jal	t9	REG_L	t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)	s.s	$f0, 0(t0)	b	epilogueretdouble:		bne	t2, FFI_TYPE_DOUBLE, noretval	jal	t9	REG_L	t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)	s.d	$f0, 0(t0)	b	epilogue	noretval:		jal	t9		# Epilogueepilogue:		move	$sp, $fp		REG_L	$fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp) # Restore frame pointer	REG_L	ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp)  # Restore return address	ADDU	$sp, SIZEOF_FRAME		      # Fix stack pointer	j	ra	.end	ffi_call_O32	#endif

⌨️ 快捷键说明

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