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

📄 lib1funcs.asm

📁 gcc-you can use this code to learn something about gcc, and inquire further into linux,
💻 ASM
📖 第 1 页 / 共 2 页
字号:
	add	dividend, workLover6:	mov	curbit, ip	mov	work, #2	ror	curbit, work	tst	overdone, curbit	beq	Lover7	lsr	work, divisor, #2	add	dividend, workLover7:	mov	curbit, ip	mov	work, #1	ror	curbit, work	tst	overdone, curbit	beq	Lgot_result	lsr	work, divisor, #1	add	dividend, work  .endifLgot_result:.endm	/* ------------------------------------------------------------------------ *//*		Start of the Real Functions				    *//* ------------------------------------------------------------------------ */#ifdef L_udivsi3	FUNC_START udivsi3#ifdef __thumb__	cmp	divisor, #0	beq	Ldiv0	mov	curbit, #1	mov	result, #0		push	{ work }	cmp	dividend, divisor	blo	Lgot_result	THUMB_DIV_MOD_BODY 0		mov	r0, result	pop	{ work }	RET#else /* ARM version.  */		cmp	divisor, #0	beq	Ldiv0	mov	curbit, #1	mov	result, #0	cmp	dividend, divisor	blo	Lgot_result		ARM_DIV_MOD_BODY 0		mov	r0, result	RET	#endif /* ARM version */	FUNC_END udivsi3#endif /* L_udivsi3 *//* ------------------------------------------------------------------------ */#ifdef L_umodsi3	FUNC_START umodsi3#ifdef __thumb__	cmp	divisor, #0	beq	Ldiv0	mov	curbit, #1	cmp	dividend, divisor	bhs	Lover10	RET	Lover10:	push	{ work }	THUMB_DIV_MOD_BODY 1		pop	{ work }	RET	#else  /* ARM version.  */		cmp	divisor, #0	beq	Ldiv0	cmp     divisor, #1	cmpne	dividend, divisor	moveq   dividend, #0	RETc(lo)	mov	curbit, #1	ARM_DIV_MOD_BODY 1		RET	#endif /* ARM version.  */		FUNC_END umodsi3#endif /* L_umodsi3 *//* ------------------------------------------------------------------------ */#ifdef L_divsi3	FUNC_START divsi3	#ifdef __thumb__	cmp	divisor, #0	beq	Ldiv0		push	{ work }	mov	work, dividend	eor	work, divisor		@ Save the sign of the result.	mov	ip, work	mov	curbit, #1	mov	result, #0	cmp	divisor, #0	bpl	Lover10	neg	divisor, divisor	@ Loops below use unsigned.Lover10:	cmp	dividend, #0	bpl	Lover11	neg	dividend, dividendLover11:	cmp	dividend, divisor	blo	Lgot_result	THUMB_DIV_MOD_BODY 0		mov	r0, result	mov	work, ip	cmp	work, #0	bpl	Lover12	neg	r0, r0Lover12:	pop	{ work }	RET#else /* ARM version.  */		eor	ip, dividend, divisor		@ Save the sign of the result.	mov	curbit, #1	mov	result, #0	cmp	divisor, #0	rsbmi	divisor, divisor, #0		@ Loops below use unsigned.	beq	Ldiv0	cmp	dividend, #0	rsbmi	dividend, dividend, #0	cmp	dividend, divisor	blo	Lgot_result	ARM_DIV_MOD_BODY 0		mov	r0, result	cmp	ip, #0	rsbmi	r0, r0, #0	RET	#endif /* ARM version */		FUNC_END divsi3#endif /* L_divsi3 *//* ------------------------------------------------------------------------ */#ifdef L_modsi3	FUNC_START modsi3#ifdef __thumb__	mov	curbit, #1	cmp	divisor, #0	beq	Ldiv0	bpl	Lover10	neg	divisor, divisor		@ Loops below use unsigned.Lover10:	push	{ work }	@ Need to save the sign of the dividend, unfortunately, we need	@ work later on.  Must do this after saving the original value of	@ the work register, because we will pop this value off first.	push	{ dividend }	cmp	dividend, #0	bpl	Lover11	neg	dividend, dividendLover11:	cmp	dividend, divisor	blo	Lgot_result	THUMB_DIV_MOD_BODY 1			pop	{ work }	cmp	work, #0	bpl	Lover12	neg	dividend, dividendLover12:	pop	{ work }	RET	#else /* ARM version.  */		cmp	divisor, #0	rsbmi	divisor, divisor, #0		@ Loops below use unsigned.	beq	Ldiv0	@ Need to save the sign of the dividend, unfortunately, we need	@ ip later on; this is faster than pushing lr and using that.	str	dividend, [sp, #-4]!	cmp	dividend, #0			@ Test dividend against zero	rsbmi	dividend, dividend, #0		@ If negative make positive	cmp	dividend, divisor		@ else if zero return zero	blo	Lgot_result			@ if smaller return dividend	mov	curbit, #1	ARM_DIV_MOD_BODY 1	ldr	ip, [sp], #4	cmp	ip, #0	rsbmi	dividend, dividend, #0	RET	#endif /* ARM version */		FUNC_END modsi3#endif /* L_modsi3 *//* ------------------------------------------------------------------------ */#ifdef L_dvmd_tls	FUNC_START div0	RET	SIZE	(__div0)	#endif /* L_divmodsi_tools *//* ------------------------------------------------------------------------ */#ifdef L_dvmd_lnx@ GNU/Linux division-by zero handler.  Used in place of L_dvmd_tls/* Constants taken from <asm/unistd.h> and <asm/signal.h> */#define SIGFPE	8#define __NR_SYSCALL_BASE	0x900000#define __NR_getpid			(__NR_SYSCALL_BASE+ 20)#define __NR_kill			(__NR_SYSCALL_BASE+ 37)	FUNC_START div0	stmfd	sp!, {r1, lr}	swi	__NR_getpid	cmn	r0, #1000	ldmhsfd	sp!, {r1, pc}RETCOND	@ not much we can do	mov	r1, #SIGFPE	swi	__NR_kill#ifdef __THUMB_INTERWORK__	ldmfd	sp!, {r1, lr}	bx	lr#else	ldmfd	sp!, {r1, pc}RETCOND#endif	SIZE 	(__div0)	#endif /* L_dvmd_lnx *//* ------------------------------------------------------------------------ *//* These next two sections are here despite the fact that they contain Thumb    assembler because their presence allows interworked code to be linked even   when the GCC library is this one.  */		/* Do not build the interworking functions when the target architecture does    not support Thumb instructions.  (This can be a multilib option).  */#if defined L_call_via_rX && (defined __ARM_ARCH_4T__ || defined __ARM_ARCH_5T__ || defined __ARM_ARCH_5TE__)/* These labels & instructions are used by the Arm/Thumb interworking code.    The address of function to be called is loaded into a register and then    one of these labels is called via a BL instruction.  This puts the    return address into the link register with the bottom bit set, and the    code here switches to the correct mode before executing the function.  */		.text	.align 0        .force_thumb.macro call_via register	THUMB_FUNC_START _call_via_\register	bx	\register	nop	SIZE	(_call_via_\register).endm	call_via r0	call_via r1	call_via r2	call_via r3	call_via r4	call_via r5	call_via r6	call_via r7	call_via r8	call_via r9	call_via sl	call_via fp	call_via ip	call_via sp	call_via lr#endif /* L_call_via_rX *//* ------------------------------------------------------------------------ *//* Do not build the interworking functions when the target architecture does    not support Thumb instructions.  (This can be a multilib option).  */#if defined L_interwork_call_via_rX && (defined __ARM_ARCH_4T__ || defined __ARM_ARCH_5T__ || defined __ARM_ARCH_5TE__)/* These labels & instructions are used by the Arm/Thumb interworking code,   when the target address is in an unknown instruction set.  The address    of function to be called is loaded into a register and then one of these   labels is called via a BL instruction.  This puts the return address    into the link register with the bottom bit set, and the code here    switches to the correct mode before executing the function.  Unfortunately   the target code cannot be relied upon to return via a BX instruction, so   instead we have to store the resturn address on the stack and allow the   called function to return here instead.  Upon return we recover the real   return address and use a BX to get back to Thumb mode.  */		.text	.align 0	.code   32	.globl _arm_return_arm_return:			ldmia 	r13!, {r12}	bx 	r12	.code   16.macro interwork register						.code   16	THUMB_FUNC_START _interwork_call_via_\register	bx 	pc	nop		.code   32	.globl .Lchange_\register.Lchange_\register:	tst	\register, #1	stmeqdb	r13!, {lr}	adreq	lr, _arm_return	bx	\register	SIZE	(_interwork_call_via_\register).endm		interwork r0	interwork r1	interwork r2	interwork r3	interwork r4	interwork r5	interwork r6	interwork r7	interwork r8	interwork r9	interwork sl	interwork fp	interwork ip	interwork sp		/* The LR case has to be handled a little differently...  */	.code 16	THUMB_FUNC_START _interwork_call_via_lr	bx 	pc	nop		.code 32	.globl .Lchange_lr.Lchange_lr:	tst	lr, #1	stmeqdb	r13!, {lr}	mov	ip, lr	adreq	lr, _arm_return	bx	ip		SIZE	(_interwork_call_via_lr)	#endif /* L_interwork_call_via_rX */

⌨️ 快捷键说明

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