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

📄 vaxstring.s

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 S
📖 第 1 页 / 共 5 页
字号:
 # 16 bits have to be cleared in r2 and then the condition codes are set # to indicate that a match occurred.L340:	movzwl	r2,r2			# clear unused bits	brb	L330			# join common code # this code executes if the strings do not match. the actual code state # that brings us here is that the object string is now larger than the # remaining piece of the source string, making a match impossible.L350:	clrl	r2			# r2 contains zero in no match case	addl3	r6,r7,r3		# point r3 to end of source string	brb	L320			# join common exit code #+ # functional description: # #	the crc of the  data  stream  described  by  the  string  descriptor  is #	calculated.   the initial crc is given by inicrc and is normally 0 or -1 #	unless the crc is calculated in several steps.  the result  is  left  in #	r0.   if  the  polynomial  is  less  than  order-32,  the result must be #	extracted from the result.  the  crc  polynomial  is  expressed  by  the #	contents of the 16-longword table.   # # input parameters: # #	r0       = inicrc	initial crc #	r1       = tbl		address of 16-longword table #	r2<15:0> = strlen	length of data stream #	r3       = stream	address of data stream # # intermediate state: # #     31               23               15               07            00 #    +----------------+----------------+----------------+----------------+ #    |                              inicrc                               | : r0 #    +----------------+----------------+----------------+----------------+ #    |                                tbl                                | : r1 #    +----------------+----------------+----------------+----------------+ #    |    delta-pc    |      xxxx      |             strlen              | : r2 #    +----------------+----------------+----------------+----------------+ #    |                              stream                               | : r3 #    +----------------+----------------+----------------+----------------+ # # output parameters: # #	r0 = final crc value #	r1 = 0 #	r2 = 0 #	r3 = address of one byte beyond end of data stream # # condition codes: # #	n <- r0 lss 0 #	z <- r0 eql 0 #	v <- 0 #	c <- 0 # #	the condition codes simply reflect the final crc value. # # side effects: # #	this routine uses three longwords of stack. # # notes: # #	note that the main loop of this routine is slightly complicated #	by the need to allow the routine to be interrupted and restarted #	from its entry point. this requirement prevents r0 from being #	partially updates several times during each trip through the loop. #	instead, r5 is used to record the partial modifications and r5 is #	copied into r0 at the last step (with the extra movl r5,r0). #-	.globl	vax$crcvax$crc:	movzwl	r2,r2			# clear unused bits & check for 0 length	beql	2f			# all done if zero	pushl	r10			# save r10 so it can hold handler  #	establish_handler	string_accvio	 movab	string_accvio,r10	pushl	r5			# save contents of scratch register	movl	r0,r5			# copy inicrc to r5	pushl	r4			# save contents of scratch register	clrl	r4			# clear it out (we only use r4<7:0>) # this is the main loop that operates on each byte in the input stream #	MARK_POINT	CRC_1	.text	2	.set	table_size, table_size + 1	.word	Lcrc_1 - module_base	.text	3	.word	crc_1 - module_base	.textLcrc_1:1:	xorb2	(r3)+,r5		# include next byte # the next three instructions are really the body of a loop that executes # twice on each pass through the outer loop. rather than incur additional # overhead, this inner loop is expanded in line.	bicb3	$0x0f0,r5,r4		# get right 4 bits	extzv	$4,$28,r5,r5		# shift result right 4 #	MARK_POINT	CRC_2	.text	2	.set	table_size, table_size + 1	.word	Lcrc_2 - module_base	.text	3	.word	crc_2 - module_base	.textLcrc_2:	xorl2	(r1)[r4],r5		# include table entry	bicb3	$0x0f0,r5,r4		# get right 4 bits	extzv	$4,$28,r5,r5		# shift result right 4 #	MARK_POINT	CRC_3	.text	2	.set	table_size, table_size + 1	.word	Lcrc_3 - module_base	.text	3	.word	crc_3 - module_base	.textLcrc_3:	xorl2	(r1)[r4],r5		# include table entry	movl	r5,r0			# preserve latest complete result	sobgtr	r2,1b			# count down loop #	popr	$^m<r4,r5,r10>		# restore saved r4, r5, and r10	 popr	$0x430	2:	clrl	r1			# r1 must be zero on exit	tstl	r0			# determine n- and z-bits 					# (note that tstl clears v- and c-bits)	rsb				# return to caller #+ # functional description: # #	this routine receives control when an access violation occurs while #	executing within the emulator. this routine determines whether the #	exception occurred while accessing a source or destination string. #	(this check is made based on the pc of the exception.)  # #	if the pc is one that is recognized by this routine, then the state of #	the instruction (character counts, string addresses, and the like) are #	restored to a state where the instruction/routine can be restarted #	after the cause for the exception is eliminated. control is then #	passed to a common routine that sets up the stack and the exception #	parameters in such a way that the instruction or routine can restart #	transparently.  # #	if the exception occurs at some unrecognized pc, then the exception is #	reflected to the user as an exception that occurred within the #	emulator.  # #	there are two exceptions that can occur that are not backed up to a  #	consistent state.  # #	    1.	if stack overflow occurs due to use of the stack by one of  #		the vax$xxxxxx routines, it is unlikely that this routine  #		will even execute because the code that transfers control  #		here must first copy the parameters to the exception stack  #		and that operation would fail. (the failure causes control  #		to be transferred to vms, where the stack expansion logic is  #		invoked and the routine resumed transparently.) # #	    2.	if assumptions about the address space change out from under  #		these routines (because an ast deleted a portion of the  #		address space or a similar silly thing), the handling of the  #		exception is unpredictable. # # input parameters: # #	r0  - value of sp when the exception occurred #	r1  - pc of exception #	r2  - scratch #	r3  - scratch #	r10 - address of this routine (but that was already used so r10 #	      can be used for a scratch register if needed) # #	00(sp) - saved r0 (contents of r0 when exception occurred) #	04(sp) - saved r1 (contents of r1 when exception occurred) #	08(sp) - saved r2 (contents of r2 when exception occurred) #	12(sp) - saved r3 (contents of r3 when exception occurred) # #	16(sp) - return pc in exception dispatcher in operating system # #	20(sp) - first longword of system-specific exception data #	xx(sp) - first longword of system-specific exception data # #	the address of the next longword is the position of the stack when #	the exception occurred. this address is contained in r0 on entry #	to this routine. # # r0 ->	<4*<n+1> + 16>(sp) - instruction-specific data #	  .                - optional instruction-specific data #	  .                - saved r10 #	<4*<n+m> + 16>(sp) - return pc from vax$xxxxxx routine (m is the number #		             of instruction-specific longwords, including the    #		             saved r10. m is guaranteed greater than zero.) # # implicit input: # #	it is assumed that the contents of all registers (except r0 to r3) #	coming into this routine are unchanged from their contents when the #	exception occurred. (for r0 through r3, this assumption applies to the #	saved register contents on the top of the stack. any modification to #	these registers must be made to their saved copies and not to the #	registers themselves.)  # #	it is further assumed that the exception pc is within the bounds of  #	this module. (violation of this assumption is simply an inefficiency.) # #	finally, the macro begin_mark_point should have been invoked at the #	beginning of this module to define the symbols  # #		module_base #		pc_table_base #		handler_table_base #		table_size # # output parameters: # #	if the exception is recognized (that is, if the exception pc is  #	associated with one of the mark points), control is passed to the  #	context-specific routine that restores the instruction state to a  #	uniform point from which it can be restarted. # #		r0  - value of sp when exception occurred #		r1  - scratch #		r2  - scratch #		r3  - scratch #		r10 - scratch # #	 r0 ->	zz(sp) - instruction-specific data begins here # #	the instruction-specific routines eventually pass control back to the #	host system with the following register contents. # #		r0  - address of return pc from vax$xxxxxx routine #		r1  - byte offset from top of stack (into saved r0 through r3)  #		      to indicate where to store the delta-pc (if so required) #		r10 - restored to its value on entry to vax$xxxxxx # #	if the exception pc occurred somewhere else (such as a stack access),  #	the saved registers are restored and control is passed back to the  #	host system with an rsb instruction. # # implicit output: # #	the register contents are modified to put the intermediate state of #	the instruction into a consistent state from which it can be #	continued. any changes to r0 through r3 are made in their saved state #	on the top of the stack. any scratch registers saved by each #	vax$xxxxxx routine are restored.  #-string_accvio:	clrl	r2			# initialize the counter	pushab	module_base		# store base address of this module	subl2	(sp)+,r1		# get pc relative to this base1:	cmpw	r1,pc_table_base[r2]	# is this the right pc?	beql	2f			# exit loop if true	aoblss	$table_size,r2,1b	# do the entire table # if we drop through the dispatching based on pc, then the exception is not  # one that we want to back up. we simply reflect the exception to the user. #	popr	#^m<r0,r1,r2,r3>	# restore saved registers	 popr	$0x0f	rsb				# let vms reflect the exception	 # the exception pc matched one of the entries in our pc table. r2 contains # the index into both the pc table and the handler table. r1 has served # its purpose and can be used as a scratch register.2:	movzwl	handler_table_base[r2],r1	# get the offset to the handler	jmp	module_base[r1]		# pass control to the handler #+ # functional description: # #	these routines are used to store the intermediate state of the state #	of the string instructions (except movtc and movtuc) into the registers #	that are altered by a given instruction. # # input parameters: # #	r0 - points to top of stack when exception occurred # #	see each routine- and context-specific entry point for more details. # #	in general, register contents for counters and string pointers that #	are naturally tracking through a string are not listed. register #	contents that are out of the ordinary (different from those listed #	in the intermediate state pictures in each routine header) are listed. # # output parameters: # #	r0 - points to return pc from vax$xxxxxx #	r1 - locates specific byte in r0..r3 that will contain the delta-pc # #	all scratch registers (including r10) that are not supposed to be #	altered by the routine are restored to their contents when the  #	routine was originally entered. # # notes: # #	in all of the instruction-specific routines, the state of the stack #	will be shown as it was when the exception occurred. all offsets will #	be pictured relative to r0. in addition, relevant contents of r0 #	through r3 will be listed as located in the registers themselves, even #	though the actual code will manipulate the saved values of these #	registers located on the top of the stack.  # #	the apparent arbitrary order of the instruction-specific routines is #	dictated by the amount of code that they can share. the most sharing #	occurs at the middle of the code, for instructions like cmpc5 and #	scanc. the crc routines, because they are the only routines that store #	the delta-pc in r2 appear first. the cmpc3 instruction has no #	instruction-specific code that cannot be shared with all of the other #	routines so it appears at the end.  #- #+ # crc packing routine # #	r4 - scratch #	r5 - scratch # #	00(r0) - saved r4 #	04(r0) - saved r5 #	08(r0) - saved r10 #	12(r0) - return pc # # if entry is at crc_2 or crc_3, the exception occurred after the string # pointer, r3, was advanced. that pointer must be backed up to achieve a # consistent state.  #-crc_2:crc_3:	decl	pack_l_saved_r3(sp)	# back up string pointercrc_1:	movq	(r0)+,r4		# restore r4 and r5	movzbl	$crc_b_delta_pc,r1	# indicate offset used to store delta-pc	brb	L430			# not much common code left but use it #+ # matchc packing routine # #	r4<15:0> - number of characters in object string #	r5       - address of object string #	r6<15:0> - number of characters remaining in source string #	r7       - updated pointer into source string # #	00(r0) - saved r4 #	04(r0) - saved r5 #	08(r0) - saved r6 #	12(r0) - saved r7 #	16(r0) - saved r10 #	20(r0) - return pc # # note that the matchc instr

⌨️ 快捷键说明

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