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

📄 vaxstring.s

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 S
📖 第 1 页 / 共 5 页
字号:
/*	@(#)vaxstring.s	4.1		%G		*/#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, 15-Nov-84 * 001- Fix bugs that were revieved from Larry Kenah. * *	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 string instructions. #	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 # #	16 august 1982 # # modified by: # #	v04-001 ljk004		lawrence j. kenah	06-sep-1984 #		The backup code for movtc when moving in the forward direction #		also needs to be changed (see ljk0039) based on the relative #		sizes of the source and destination strings. # #	v01-005	kdm0107		kathleen d. morse	21-aug-1984 #		Fix bug in cmpc3.  Return C clear if string length is 0. # #	v01-004 ljk0039		lawrence j. kenah	20-jul-1984 #		modify movtc backup code to reflect differences in register #		contents when traversing strings backwards.  There are two #		cases based on the relative sizes of source and destination. # #	v01-003	ljk0026		lawrence j. kenah	19-Mar-1984 #		Final cleanup pass. Access violation handler is now #		called string_accvio. Set pack_m_accvio bit in r1 #		before passing control to vax$reflect_fault # #	v01-002	ljk0011		lawrence j. kenah	8-nov-1983 #		fix three minor bugs in movtc and movtuc.  # #	v01-001	original	lawrence j. kenah	16-aug-1982 #-- #+ #	the following notes apply to most or all of the routines that appear in  #	this module. the comments appear here to avoid duplication in each routine. # #  1.	the vax architecture standard (dec std 032) is the ultimate authority on #	the functional behavior of these routines. a summary of each instruction #	that is emulated appears in the functional description section of each #	routine header.  # #  2.	one design goal that affects the algorithms used is that these instructions #	can incur exceptions such as access violations that will be reported to #	users in such a way that the exception appears to have originated at the #	site of the reserved instruction rather than within the emulator. this #	constraint affects the algorithms available and dictates specific #	implementation decisions.  # #  3.	each routine header contains a picture of the register usage when it is #	necessary to store the intermediate state of an instruction (routine) while #	servicing an exception.  # #	the delta-pc field is used by the condition handler jacket to these #	routines when it determines that an exception such as an access violation #	occurred in response to an explicit use of one of the reserved #	instructions. these routines can also be called directly with the input #	parameters correctly placed in registers. the delta-pc field is not used in #	this case.  # #	note that the input parameters to any routine are a subset of the #	intermediate state picture.  # #	fields that are not used either as input parameters or to store #	intermediate state are indicated thus, xxxxx.  # #  4.	in the input parameter list for each routine, certain register fields that #	are not used may be explicitly listed for one reason or another. these #	unused input parameters are described as irrelevant.  # #  5.	in general, the final condition code settings are determined as the side #	effect of one of the last instructions that executes before control is #	passed back to the caller with an rsb. it is seldom necessary to explicitly #	manipulate condition codes with a bixpsw instruction or similar means.  # #  6.	there is only a small set of exceptions that are reflected to the user in an #	altered fashion, with the exception pc changed from within the emulator to #	the site of the original entry into these routines. the instructions that #	generate these exceptions are all immediately preceded by a  # #		mark_point	yyyy_n # #	where yyyy is the instruction name and n is a small integer. these names #	map directly into instruction- and context-specific routines (located at #	the end of this module) that put each instruction (routine) into a #	consistent state before passing control to a more general exception handler #	in a different module.  #- # include files: #	$psldef				# define bit fields in psl #	pack_def			# stack usage for exception handling # macro definitions #	.macro	_include	opcode , boot_flag #	.if	not_defined	boot_switch #		opcode'_def #		include_'opcode = 0 #	.if_false #		.if	identical	<boot_flag> , boot  #			opcode'_def #			include_'opcode = 0 #		.endc #	.endc #	.endm	_include # global and external declarations #	.disable	global #	.if	not_defined	boot_switch #	.external	vax$reflect_fault,-	# reflect access violation #			vax$reflect_to_vms	# reflect unrecognized exception #	.endc # psect declarations: #		begin_mark_point	.text	.text	2	.set	table_size,0pc_table_base:	.text	3handler_table_base:	.textmodule_base: #+ # functional description: # #	the source string specified by the  source  length  and  source  address #	operands  is translated and replaces the destination string specified by #	the destination length and destination address operands.  translation is #	accomplished  by using each byte of the source string as an index into a #	256 byte table whose zeroth entry address  is  specified  by  the  table #	address operand.  the byte selected replaces the byte of the destination #	string.  if the destination string is longer than the source string, the #	highest  addressed  bytes  of the destination string are replaced by the #	fill operand.  if the destination string  is  shorter  than  the  source #	string,  the  highest  addressed  bytes  of  the  source  string are not #	translated and moved.  the operation of the  instruction  is  such  that #	overlap  of  the  source  and  destination  strings  does not affect the #	result.  if the destination string overlaps the translation  table,  the #	destination string is unpredictable. # # input parameters: # #	the following register fields contain the same information that #	exists in the operands to the movtc instruction. # #		r0<15:0> = srclen	length of source string #		r1       = srcaddr	address of source string #		r2<7:0>  = fill		fill character #		r3       = tbladdr	address of 256-byte table #		r4<15:0> = dstlen	length of destination string #		r5       = dstaddr	address of destination string # #	in addition to the input parameters that correspond directly to #	operands to the movtc instruction, there are other input parameters  #	to this routine. note that the two inixxxlen parameters are only #	used when the movtc_v_fpd bit is set in the flags byte. # #		r2<15:8>  = flags	instruction-specific status # #	the contents of the flags byte must be zero (mbz) on entry to this #	routine from the outside world (through the emulator jacket or by #	a jsb call). if the initial contents of flags are not zero, the #	actions of this routine are unpredictable.  # #	there are two other input parameters whose contents depend on #	the settings of the flags byte. # #	movtc_v_fpd bit in flags is clear # #		r0<31:16> = irrelevant #		r4<31:16> = irrelevant # #	movtc_v_fpd bit in flags is set # #		r0<31:16> = inisrclen	initial length of source string #		r4<31:16> = inidstlen	initial length of destination string # # intermediate state: # #     31               23               15               07            00 #    +----------------+----------------+----------------+----------------+ #    |         initial srclen          |             srclen              | : r0 #    +----------------+----------------+----------------+----------------+ #    |                              srcaddr                              | : r1 #    +----------------+----------------+----------------+----------------+ #    |    delta-pc    |     xxxx       |     flags      |      fill      | : r2 #    +----------------+----------------+----------------+----------------+ #    |                              tbladdr                              | : r3 #    +----------------+----------------+----------------+----------------+ #    |         initial dstlen          |             dstlen              | : r4 #    +----------------+----------------+----------------+----------------+ #    |                              dstaddr                              | : r5 #    +----------------+----------------+----------------+----------------+ # # output parameters: # #	source string longer than destination string # #		r0 = number of bytes remaining in the source string  #		r1 = address of one byte beyond last byte in source string #			that was translated (the first untranslated byte) #		r2 = 0 #		r3 = tbladdr	address of 256-byte table #		r4 = 0 (number of bytes remaining in the destination string) #		r5 = address of one byte beyond end of destination string # #	source string same size as or smaller than destination string # #		r0 = 0 (number of bytes remaining in the source string) #		r1 = address of one byte beyond end of source string #		r2 = 0 #		r3 = tbladdr	address of 256-byte table #		r4 = 0 (number of bytes remaining in the destination string) #		r5 = address of one byte beyond end of destination string # # condition codes: # #	n <- srclen lss dstlen #	z <- srclen eql dstlen #	v <- 0 #	c <- srclen lssu dstlen # # side effects: # #	this routine uses up to four longwords of stack space. #-		.globl	vax$movtcvax$movtc:	pushl	r4			# store dstlen on stack	pushl	r0			# store srclen on stack	bbs	$(movtc_v_fpd+8),r2,L5	# branch if instruction was interrupted	movw	(sp),2(sp)		# set the initial srclen on stack	movw	4(sp),6(sp)		# set the initial dstlen on stackL5:	pushl	r10			# save r10 so it can hold handler  #	establish_handler	string_accvio	 movab	string_accvio,r10	movzwl	r4,r4			# clear unused bits of dstlen	beql	L40			# all done if zero	movzwl	r0,r0			# clear unused bits of srclen	beql	L20			# add fill character to destination	cmpl	r1,r5			# check relative position of strings	blssu	move_backward		# perform move from end of strings # this code executes if the source string is at a larger virtual address # than the destination string. the movement takes place from the front # (small address end) of each string to the back (high address end).move_forward:	pushl	r2			# allow r2 (fill) to be used as scratch	subl2	r0,r4			# get difference between strings	bgequ	L10			# branch if fill work to do eventually	movzwl	12(sp),r0		# use dstlen (saved r4) as srclen (r0) #	MARK_POINT	MOVTC_1	.text	2	.set	table_size, table_size + 1	.word	Lmovtc_1 - module_base	.text	3	.word	movtc_1 - module_base	.textLmovtc_1:L10:	movzbl	(r1)+,r2		# get next character from source #	MARK_POINT	MOVTC_2	.text	2	.set	table_size, table_size + 1	.word	Lmovtc_2 - module_base	.text	3	.word	movtc_2 - module_base	.textLmovtc_2:	movb	(r3)[r2],(r5)+		# move translated character	sobgtr	r0,L10			# source all done?	movl	(sp)+,r2		# retrieve fill character from stack	tstl	r4			# do we need to fill anything?	bleq	L80			# skip to exit code if no fill work #	MARK_POINT	MOVTC_3	.text	2	.set	table_size, table_size + 1	.word	Lmovtc_3 - module_base	.text	3	.word	movtc_3 - module_base	.textLmovtc_3:L20:	movb	r2,(r5)+		# fill next character	sobgtr	r4,L20			# destination all done? # this is the common exit path. r2 is cleared to conform to its output # setting. the condition codes are determined by the original lengths # of the source and destination strings that were saved on the stack.L30:	clrl	r2			# r2 is zero on return	movl	(sp)+,r10		# restore saved r10	ashl	$-16,(sp),(sp)		# get initial srclen	ashl	$-16,4(sp),4(sp)	# get initial dstlen	cmpl	(sp)+,(sp)+		# set condition codes	rsb

⌨️ 快捷键说明

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