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

📄 vaxarith.s

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 S
📖 第 1 页 / 共 5 页
字号:
/*	@(#)vaxarith.s	4.1		7/2/90		*/#include "../machine/emul/vaxemul.h"#include "../machine/psl.h"#include "../machine/emul/vaxregdef.h"/************************************************************************ *									* *			Copyright (c) 1985 by				* *		Digital Equipment Corporation, Maynard, MA		* *			All rights reserved.				* *									* *   This software is furnished under a license and may be used and	* *   copied  only  in accordance with the terms of such license and	* *   with the  inclusion  of  the  above  copyright  notice.   This	* *   software  or  any  other copies thereof may not be provided or	* *   otherwise made available to any other person.  No title to and	* *   ownership of the software is hereby transferred.			* *									* *   The information in this software is subject to change  without	* *   notice  and should not be construed as a commitment by Digital	* *   Equipment Corporation.						* *									* *   Digital assumes no responsibility for the use  or  reliability	* *   of its software on equipment which is not supplied by Digital.	* *									* ************************************************************************//************************************************************************ * *			Modification History * *	Stephen Reilly, 23-Dec-85 * 001- Fixed a constant translation bug that caused the divp instruction *	not to work. * ***********************************************************************/ #++ # facility:  # #	vax-11 instruction emulator # # abstract: # #	the routines in this module emulate the vax-11 packed decimal #	instructions that perform arithmetic operations. these procedures can #	be a part of an emulator package or can be called directly after the #	input parameters have been loaded into the architectural registers.  # #	the input parameters to these routines are the registers that #	contain the intermediate instruction state.  # # environment:  # #	these routines run at any access mode, at any ipl, and are ast  #	reentrant. # # author:  # #	lawrence j. kenah	 # # creation date # #	19 october 1983 # # modified by: # #	v01-003 ljk0037		Lawrence j. kenah	17-jul-1984 #		Fix two minor bugs in exceptions handling code that caused #		MULP and DIVP tests to generate spurious access violation # #	v01-002	ljk0024		lawrence j. kenah	21-feb-1984 #		add code to handle access violations. perform minor cleanup. #		eliminate double use of r10 in mulp and divp. # #	v01-001	ljk0008		lawrence j. kenah	19-oct-1983 #		the emulation code for addp4, addp6, subp4, subp6, mulp and #		divp was moved into a separate module. #-- # include files:/*	.nocross			# no cross reference for these *	.enable		suppression	# no symbol table entries either * *	addp4_def			# bit fields in addp4 registers *	addp6_def			# bit fields in addp6 registers *	divp_def			# bit fields in divp registers *	mulp_def			# bit fields in mulp registers *	subp4_def			# bit fields in subp4 registers *	subp6_def			# bit fields in subp6 registers  * *	$psldef				# define bit fields in psl *	$srmdef				# define arithmetic trap codes * *	.disable	suppression	# turn on symbol table again *	.cross				# cross reference is ok now */ # symbol definitions #	the architecture requires that r4 be zero on completion of an addp6 or  #	subp6 instruction. if we did not have to worry about restarting  #	instructions after an access violation, we could simply zero the saved  #	r4 value on the code path that these two instructions have in common  #	before they merge with the addp4 and subp4 routines. the ability to  #	restart requires that we keep the original r4 around at least until no  #	more access violations are possible. to accomplish this, we store the  #	fact that r4 must be cleared on exit in r11, which also contains the  #	evolving condition codes. we use bit 31, the compatibility mode bit  #	because it is nearly impossible to enter the emulator with cm set.# define add_sub_v_zero_r4  psl$v_cm # external declarations/*	.disable	global * *	.external - *			decimal$bounds_check,- *			decimal$binary_to_packed_table,- *			decimal$packed_to_binary_table,- *			decimal$strip_zeros_r0_r1,- *			decimal$strip_zeros_r2_r3 * *	.external - *			vax$decimal_exit,- *			vax$decimal_accvio,- *			vax$reflect_trap,- * 			vax$roprand */ # psect declarations: #	begin_mark_point	.text	.text	2	.set	table_size,0pc_table_base:	.text	3handler_table_base:	.textmodule_base: # #+ # functional description: # #	in 6 operand format, the subtrahend string specified by  the  subtrahend #	length  and  subtrahend  address operands is subtracted from the minuend #	string specified by the minuend length  and  minuend  address  operands. #	the  difference string specified by the difference length and difference #	address operands is replaced by the result. # # input parameters: # #	r0 - sublen.rw		number of digits in subtrahend string #	r1 - subaddr.ab		address of subtrahend string #	r2 - minlen.rw		number of digits in minuend string #	r3 - minaddr.ab		address of minuend string #	r4 - diflen.rw		number of digits in difference string #	r5 - difaddr.ab		address of difference string # # output parameters: # #	r0 = 0 #	r1 = address of the byte containing the most significant digit of #	     the subtrahend string #	r2 = 0 #	r3 = address of the byte containing the most significant digit of #	     the minuend string #	r4 = 0 #	r5 = address of the byte containing the most significant digit of #	     the string containing the difference # # condition codes: # #	n <- difference string lss 0 #	z <- difference string eql 0 #	v <- decimal overflow #	c <- 0 # # register usage: # #	this routine uses all of the general registers. the condition codes  #	are recorded in r11 as the routine executes. #-		.globl	vax$subp6vax$subp6: #	pushr	$^m<r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>	# save the lot	 pushr	$0x0fff	movzbl	$1,r9			# indicate that this is subtraction	brb	L10			# merge with addp6 code # #+ # functional description: # #	in 6 operand format, the addend 1  string  specified  by  the  addend  1 #	length  and  addend  1  address operands is added to the addend 2 string #	specified by the addend 2 length and addend 2 address operands.  the sum #	string  specified by the sum length and sum address operands is replaced #	by the result. # # input parameters: # #	r0 - add1len.rw		number of digits in first addend string #	r1 - add1addr.ab	address of first addend string #	r2 - add2len.rw		number of digits in second addend string #	r3 - add2addr.ab	address of second addend string #	r4 - sumlen.rw		number of digits in sum string #	r5 - sumaddr.ab		address of sum string # # output parameters: # #	r0 = 0 #	r1 = address of the byte containing the most significant digit of #	     the first addend string #	r2 = 0 #	r3 = address of the byte containing the most significant digit of #	     the second addend string #	r4 = 0 #	r5 = address of the byte containing the most significant digit of #	     the string containing the sum # # condition codes: # #	n <- sum string lss 0 #	z <- sum string eql 0 #	v <- decimal overflow #	c <- 0 # # register usage: # #	this routine uses all of the general registers. the condition codes  #	are recorded in r11 as the routine executes. #-		.globl	vax$addp6vax$addp6: #	pushr	$^m<r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>	# save the lot	 pushr	$0x0fff	clrl	r9			# this is additionL10: #	roprand_check	r4		# insure that r4 is lequ 31	 cmpw	r4,$31	 blequ	1f	 brw	decimal_roprand1:	 movzwl	r4,r4	movpsl	r11			# get initial psl # indicate that the saved r4 must be cleared on the exit path	bbcs	$add_sub_v_zero_r4,r11,L30	# set bit and join common code	brb	L30				# in case we drop through bbcs # #+ # functional description: # #	in 4 operand format,  the  subtrahend  string  specified  by  subtrahend #	length and subtrahend address operands is subtracted from the difference #	string  specified  by  the  difference  length  and  difference  address #	operands and the difference string is replaced by the result. # # input parameters: # #	r0 - sublen.rw		number of digits in subtrahend string #	r1 - subaddr.ab		address of subtrahend decimal string #	r2 - diflen.rw		number of digits in difference string #	r3 - difaddr.ab		address of difference decimal string # # output parameters: # #	r0 = 0 #	r1 = address of the byte containing the most significant digit of #	     the subtrahend string #	r2 = 0 #	r3 = address of the byte containing the most significant digit of #	     the string containing the difference # # condition codes: # #	n <- difference string lss 0 #	z <- difference string eql 0 #	v <- decimal overflow #	c <- 0 # # register usage: # #	this routine uses all of the general registers. the condition codes  #	are recorded in r11 as the routine executes. #-		.globl	vax$subp4vax$subp4: #	pushr	$^m<r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>	# save the lot	 pushr	$0x0fff	movzbl	$1,r9			# indicate that this is subtraction	brb	L20			# merge with addp4 code # #+ # functional description: # #	in 4 operand format, the addend string specified by  the  addend  length #	and  addend address operands is added to the sum string specified by the #	sum length and sum address operands and the sum string  is  replaced  by #	the result. # # input parameters: # #	r0 - addlen.rw		number of digits in addend string #	r1 - addaddr.ab		address of addend decimal string #	r2 - sumlen.rw		number of digits in sum string #	r3 - sumaddr.ab		address of sum decimal string # # output parameters: # #	r0 = 0 #	r1 = address of the byte containing the most significant digit of #	     the addend string #	r2 = 0 #	r3 = address of the byte containing the most significant digit of #	     the string containing the sum # # condition codes: # #	n <- sum string lss 0 #	z <- sum string eql 0 #	v <- decimal overflow #	c <- 0 # # register usage: # #	this routine uses all of the general registers. the condition codes  #	are recorded in r11 as the routine executes. #-		.globl	vax$addp4vax$addp4: #	pushr	$^m<r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>	# save the lot	 pushr	$0x0fff	clrl	r9			# this is addition # the output string, described by r4 and r5, will be the same as the input # string for addp4 and subp4. it is necessary to explicitly clear r4<31:16> # along this code path so movq r2,r4 will not always work.L20:	movzwl	r2,r4			# set output size equal to input size	movl	r3,r5			# ... and ditto for string addresses	movpsl	r11			# get initial psl # indicate that the saved r4 will be restored on the common exit path	bbcc	$add_sub_v_zero_r4,r11,L30	# clear bit and join common code # #+ # all four routines converge at this point and execute common initialization # code until a later decision is made to do addition or subtraction. # #	r4 - number of digits in destination string #	r5 - address of destination string # #	r9 - indicates whether operation is addition or subtraction #		0 => addition #		1 => subtraction # #	r11<31> - indicates whether this is a 4-operand or 6-operand instruction #		0 => 4-operand (restore saved r4 on exit) #		1 => 6-operand (set r4 to zero on exit) #-L30:	insv	$psl$m_z,$0,$4,r11	# set z-bit, clear the rest in saved psw #	establish_handler	-	# store address of access #		arith_accvio		#  violation handler	 movab	arith_accvio,r10 #	roprand_check	r2			# insure that r2 is lequ 31	 cmpw	r2,$31	 blequ	1f	 brw	decimal_roprand1:	 movzwl	r2,r2 #	mark_point	add_sub_bsbw_0	 .text	2

⌨️ 快捷键说明

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