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

📄 vaxeditpc.s

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 S
📖 第 1 页 / 共 5 页
字号:
/*	@(#)vaxeditpc.s	4.1		7/2/90		*/#include "../machine/emul/vaxemul.h"#include "../machine/psl.h"#include "../machine/emul/vaxregdef.h"/************************************************************************ *									* *			Copyright (c) 1984 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, 20-Mar-84 * 000- This code is the modification of the VMS emulation codethat  *	was written by Larry Kenah.  It has been modified to run *	on Ultrix. * ***********************************************************************/ #++ # facility:  # #	vax-11 instruction emulator # # abstract: # #	the routines in this module emulate the vax-11 editpc instruction. #	these routines 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 # #	20 september 1982 # # modified by: # #	v01-008 ljk0035		lawrence j. kenah	16-jul-1984 #		Fix bugs in restart logic. # #		R6 cannot be used as both the exception dispatch register and #		a scratch register in the main editpc routine.  Use r7 as the #		scratch register. #		Add code to the editpc_1 restart routine to restore r7 as the #		address of the sign byte. #		clear c-bit in saved psw in end_float_1 routine. #		restore r9 (count of zeros) with cvtwl instruction. #		fix calculation of initial srcaddr parameter. #		preserve r8 in read_1 and read_2 routines. #		preserve r7 in float_2 routine. # #	v01-007 ljk0032		lawrence j. kenah	 5-jul-1984 #		fix restart routine to take into account the fact that #		restart codes are based at one when computing restart pc. #		Load state cell with nonzero restart code in roprand_fault #		routine. # #	v01-006	ljk0026		lawrence j. kenah	19-mar-1984 #		final cleanup, especially in access violation handling. make #		all of the comments in exception handling accurately describe #		what the code is really doing. # #	v01-005	ljk0018		lawrence j. kenah	23-jan-1984 #		add restart logic for illegal pattern operator. add access #		violation handling. # #	v01-004	ljk0014		lawrence j. kenah	21-nov-1983 #		clean up rest of exception handling. remove reference #		to lib$signal. # #	v01-003	ljk0012		lawrence j. kenah	8-nov-1983 #		start out with r9 containing zero so that pattern streams #		that do not contain eo$adjust_input will work correctly. # #	v01-002	ljk0009		lawrence j. kenah	20-oct-1983 #		add exception handling. fix bug in size of count field. # #	v01-001	original	lawrence j. kenah	20-sep-1982 #-- # include files:/*	editpc_def			# define intermediaie instruction state * *	$psldef				# define bit fields in psl */ # equated symbols# define blank 0x20# define minus 0x2d# define zero  0x30 # psect declarations:	.text #	begin_mark_point	restart	.text	.text	2	.set	table_size,0pc_table_base:	.text	3handler_table_base:	.text	1	.set	restart_table_size,0restart_pc_table_base:	.textmodule_base: #+ # functional description: # #	the destination  string  specified  by  the  pattern  and  destination #	address  operands  is  replaced  by  the editted version of the source #	string specified by the source length  and  source  address  operands. #	the  editing  is performed according to the pattern string starting at #	the address pattern and extending until a pattern end (eo$end) pattern #	operator  is  encountered.   the  pattern  string consists of one byte #	pattern operators.  some pattern operators  take  no  operands.   some #	take  a repeat count which is contained in the rightmost nibble of the #	pattern operator itself.  the rest  take  a  one  byte  operand  which #	follows  the  pattern operator immediately.  this operand is either an #	unsigned integer length or a byte character.  the  individual  pattern #	operators are described on the following pages. # # input parameters: # #	r0 - srclen.rw		length of input packed decimal string #	r1 - srcaddr.ab		address of input packed decimal string #	r3 - pattern.ab		address of table of editing pattern operators #	r5 - dstaddr.ab		address of output character string # # intermediate state: # #     31               23               15               07            00 #    +----------------+----------------+----------------+----------------+ #     |            zero count             |              srclen               |  : r0 #    +----------------+----------------+----------------+----------------+ #     |                               srcaddr                               |  : r1 #    +----------------+----------------+----------------+----------------+ #     |     delta-srcaddr     |       xxxx       |       sign       |       fill       |  : r0 #    +----------------+----------------+----------------+----------------+ #     |                               pattern                               |  : r3 #    +----------------+----------------+----------------+----------------+ #     |    loop-count      state            saved-PSW       inisrclen                                |  : r4 #    +----------------+----------------+----------------+----------------+ #     |                               dstaddr                               |  : r5 #    +----------------+----------------+----------------+----------------+ # # output parameters: # #	r0 - length of input decimal string #	r1 - address of most significant byte of input decimal string #	r2 - 0 #	r3 - address of byte containing eo$end pattern operator #	r4 - 0 #	r5 - address of one byte beyond destination character string # # condition codes: # #	n <- source string lss 0	(src = -0 => n = 0) #	z <- source string eql 0 #	v <- decimal overflow		(nonzero digits lost) #	c <- significance #-	.globl	vax$editpcL502:	jmp	vax$editpc_restart	# Make sure we test the right FPD bitL5:	brw	editpc_roprand_abort	# time to quit if illegal lengthvax$editpc:	bbs	$(editpc_v_fpd+16),r4,L502 #	pushr	$^m<r0,r1,r6,r7,r8,r9,r10,r11>	# save lots of registers	 pushr	$0x0fc3	cmpw	r0,$31			# check for r0 gtru 31	bgtru	L5			# signal roprand if r0 gtru 31	movzwl	r0,r0			# clear any junk from high-order word	movzbl	$blank,r2		# set fill to blank, stored in r2	clrl	r9			# start with "zero count" of zero #	establish_handler	editpc_accvio	 movab	editpc_accvio,r10	movpsl	r11			# get current psl	bicb2	$( psl$m_n | psl$m_v | psl$m_c ),r11	# clear n-, v-, and c-bits	bisb2	$psl$m_z,r11		# set z-bit.  # we need to determine the sign in the input decimal string to choose # the initial setting of the n-bit in the saved psw.	extzv	$1,$4,r0,r7		# get byte offset to end of string	addl2	r1,r7			# get address of byte containing sign #	mark_point	editpc_1, restart	 .text	2	 .set	table_size,table_size + 1	 .word	Leditpc_1 - module_base	 .text	3	 .word	editpc_1 - module_base	 .text	1	 .set	restart_table_size,restart_table_size+1	 .set	editpc_1_restart,restart_table_size	 .word	Leditpc_1 - module_base	 .textLeditpc_1:	extzv	$0,$4,(r7),r7		# get sign "digit" into r6	caseb	r7,$10,$15-10		# dispatch on sign L1:	.word	2f-L1			# 10 => +	.word	1f-L1			# 11 => -	.word	2f-L1			# 12 => +	.word	1f-L1			# 13 => -	.word	2f-L1			# 14 => +	.word	2f-L1			# 15 => + # sign is minus1:	bisb2	$psl$m_n,r11		# set n-bit in saved psw	movzbl	$minus,r4		# set sign to minus, stored in r4	brb	top_of_loop		# join common code # sign is plus (but initial content of sign register is blank)2:	movzbl	$blank,r4		# set sign to blank, stored in r4 # the architectural description of the editpc instruction uses an exit flag # to determine whether to continue reading edit operators from the input # stream. this implementation does not use an explicit exit flag. rather, all # of the end processing is contained in the routine that handles the eo$end # operator. # the next several instructions are the main routine in this module. each # pattern is used to dispatch to a pattern-specific routine that performs # its designated action. these routines (except for eo$end) return control # to top_of_loop to allow the next pattern operator to be processed.top_of_loop:	pushab	top_of_loop			# store "return pc" # the following instructions pick up the next byte in the pattern stream and # dispatch to a pattern specific subroutine that performs the designated # action. control is passed back to the main editpc loop by the rsb # instructions located in each pattern-specific subroutine.  # note that the seemingly infinite loop actually terminates when the eo$end # pattern operator is detected. that routine insures that we do not return # to this loop but rather to the caller of vax$editpc. # 	mark_point	editpc_2, restart	 .text	2	 .set	table_size,table_size + 1	 .word	Leditpc_2 - module_base	 .text	3	 .word	editpc_2 - module_base	 .text	1	 .set	restart_table_size,restart_table_size+1	 .set	editpc_2_restart,restart_table_size	 .word	Leditpc_2 - module_base	 .textLeditpc_2:	caseb	(r3)+,$0,$4-0L2:	.word	eo$end_routine-L2		# 00 - eo$end	.word	eo$end_float_routine-L2		# 01 - eo$end_float	.word	eo$clear_signif_routine-L2	# 02 - eo$clear_signif	.word	eo$set_signif_routine-L2	# 03 - eo$set_signif	.word	eo$store_sign_routine-L2	# 04 - eo$store_sign #	mark_point	editpc_3	.text	.text	2	.set	table_size, table_size + 1	.word	Leditpc_3 - module_base	.text	3	.word	editpc_3 - module_base	.textLeditpc_3:	caseb	-1(r3 ),$0x40,$0x47-0x40L3:	.word	eo$load_fill_routine-L3		# 40 - eo$load_fill	.word	eo$load_sign_routine-L3		# 41 - eo$load_sign	.word	eo$load_plus_routine-L3		# 42 - eo$load_plus	.word	eo$load_minus_routine-L3	# 43 - eo$load_minus	.word	eo$insert_routine-L3		# 44 - eo$insert	.word	eo$blank_zero_routine-L3	# 45 - eo$blank_zero	.word	eo$replace_sign_routine-L3	# 46 - eo$replace_sign	.word	eo$adjust_input_routine-L3	# 47 - eo$adjust_input #	mark_point	editpc_4	.text	.text	2	.set	table_size, table_size + 1	.word	Leditpc_4 - module_base	.text	3	.word	editpc_4 - module_base	.textLeditpc_4: #	bitb	$^b1111,-1(r3)		# check for 80, 90, or a0	 bitb	$0x0f,-1(r3)	beql	3f			# reserved operand on repeat of zero #	mark_point	editpc_5	.text	.text	2	.set	table_size, table_size + 1	.word	Leditpc_5 - module_base	.text	3	.word	editpc_5 - module_base	.textLeditpc_5:	extzv	$4,$4,-1(r3 ),r7		# ignore repeat count in dispatch	caseb	r7,$8,$10-8L4:	.word	eo$fill_routine-L4		# 81 to 8f - eo$fill	.word	eo$move_routine-L4		# 91 to 9f - eo$move	.word	eo$float_routine-L4		# a1 to af - eo$float # if we drop through all three case instructions, the pattern operator is # unimplemented or reserved. r3 is backed up to point to the illegal # pattern operator and a reserved operand fault is signalled.3:	decl	r3			# point r3 to illegal operator	addl2	$4,sp			# discard return pc	brw	editpc_roprand_fault	# initiate exception processing #+ # functional description: # #	there is a separate action routine for each pattern operator. these  #	routines are entered with specific register contents and several  #	scratch registers at their disposal. they perform their designated  #	action and return to the main vax$editpc routine. # #	there are several words used in the architectural description of this #	instruction that are carried over into comments in this module. these #	words are briefly mentioned here. # #	char	character in byte following pattern operator (used by #		eo$load_fill, eo$load_sign, eo$load_plus, eo$load_minus, #		and eo$insert) # #	length	length in byte following pattern operator (used by #		eo$blank_zero, eo$replace_sign, and eo$adjust_input) # #	repeat	repeat count in bits <3:0> of pattern operator (used by #		eo$fill, eo$move, and eo$float) # #	the architecture makes use of two character registers, described #	as appearing in different bytes of r2. for simplicity, we use an #	additional register. # #	fill	stored in r2<7:0> # #	sign	stored in r4<7:0>  # #	finally, the architecture describes two subroutines, one that obtains #	the next digit from the input string and the other that stores a  #	character in the output string.  # #	read	subroutine eo_read provides this functionality # #	store	a single instruction of the form # #			movb	xxx,(r5)+ # #		or # #			addb3	$zero,r7,(r5)+ # #		stores a single character and advances the pointer. # # input parameters: # #	r0 - updated length of input decimal string #	r1 - address of next byte of input decimal string #	r2 - fill character #	r3 - address of one byte beyond current pattern operator #	r4 - sign character 

⌨️ 快捷键说明

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