📄 vaxstring.s
字号:
# r0 = number of bytes remaining in the string (including the byte # that produced the zero and result) # r1 = address of the byte that produced the zero and result # r2 = 0 # r3 = tbladdr address of 256-byte table # # and result always nonzero (string exhausted) # # r0 = 0 # r1 = address of one byte beyond end of string # r2 = 0 # r3 = tbladdr address of 256-byte table # # condition codes: # # n <- 0 # z <- r0 eql 0 # v <- 0 # c <- 0 # # the z bit is clear if there was a zero and result. # the z bit is set if the input string is exhausted. # # side effects: # # this routine uses two longwords of stack. #- .globl vax$spancvax$spanc: movzwl r0,r0 # clear unused bits & check for 0 length beql 3f # simply return if length is zero pushl r10 # save r10 so it can hold handler # establish_handler string_accvio movab string_accvio,r10 pushl r4 # we need a scratch register # MARK_POINT SCANC_1 .text 2 .set table_size, table_size + 1 .word Lscanc_1 - module_base .text 3 .word scanc_1 - module_base .textLscanc_1:1: movzbl (r1)+,r4 # get next character in string # MARK_POINT SCANC_2 .text 2 .set table_size, table_size + 1 .word Lscanc_2 - module_base .text 3 .word scanc_2 - module_base .textLscanc_2: bitb r2,(r3)[r4] # index into table and and with mask beql 4f # exit loop if nonzero sobgtr r0,1b # if we drop through the end of the loop into the following code, then # the input string was exhausted with no zero result.2: # popr $^m<r4,r10> # restore saved registers popr $0x4103: clrl r2 # set r2 for output value of 0 tstl r0 # set condition codes rsb # return # exit path from loop if and produced zero result4: decl r1 # point r1 to located character brb 2b # merge with common exit #+ # functional description: # # the character operand is compared with the bytes of the string specified # by the length and address operands. comparison continues until equality # is detected or all bytes of the string have been compared. if equality # is detected# the condition code z-bit is cleared# otherwise the z-bit # is set. # # input parameters: # # r0<15:0> = len length of character string # r0<23:16> = char character to be located # r1 = addr address of character string # # intermediate state: # # 31 23 15 07 00 # +----------------+----------------+----------------+----------------+ # | delta-pc | char | len | : r0 # +----------------+----------------+----------------+----------------+ # | addr | : r1 # +----------------+----------------+----------------+----------------+ # # output parameters: # # character found # # r0 = number of bytes remaining in the string (including located one) # r1 = address of the located byte # # character not found # # r0 = 0 # r1 = address of one byte beyond end of string # # condition codes: # # n <- 0 # z <- r0 eql 0 # v <- 0 # c <- 0 # # the z bit is clear if the character is located. # the z bit is set if the character is not located. # # side effects: # # this routine uses two longwords of stack. #- .globl vax$loccvax$locc: pushl r10 # save r10 so it can hold handler # establish_handler string_accvio movab string_accvio,r10 pushl r2 # save register ashl $-16,r0,r2 # get character to be located movzwl r0,r0 # clear unused bits & check for 0 length beql 2f # simply return if length is 0 # MARK_POINT LOCC_1 .text 2 .set table_size, table_size + 1 .word Llocc_1 - module_base .text 3 .word locc_1 - module_base .textLlocc_1:1: cmpb r2,(r1)+ # character match? beql 3f # exit loop if yes sobgtr r0,1b # if we drop through the end of the loop into the following code, then # the input string was exhausted with the character not found.2: # popr $^m<r2,r10> # restore saved r2 and r10 popr $0x404 tstl r0 # insure that c-bit is clear rsb # return with z-bit set # exit path when character located3: decl r1 # point r1 to located character brb 2b # join common code #+ # functional description: # # the character operand is compared with the bytes of the string specified # by the length and address operands. comparison continues until # inequality is detected or all bytes of the string have been compared. # if inequality is detected# the condition code z-bit is cleared# # otherwise the z-bit is set. # # input parameters: # # r0<15:0> = len length of character string # r0<23:16> = char character to be skipped # r1 = addr address of character string # # intermediate state: # # 31 23 15 07 00 # +----------------+----------------+----------------+----------------+ # | delta-pc | char | len | : r0 # +----------------+----------------+----------------+----------------+ # | addr | : r1 # +----------------+----------------+----------------+----------------+ # # output parameters: # # different character found # # r0 = number of bytes remaining in the string (including # unequal one) # r1 = address of the unequal byte # # all characters in string match "char" # # r0 = 0 # r1 = address of one byte beyond end of string # # condition codes: # # n <- 0 # z <- r0 eql 0 # v <- 0 # c <- 0 # # the z bit is clear if a character different from "char" is located. # the z bit is set if the entire string is equal to "char". # # side effects: # # this routine uses two longwords of stack. #- .globl vax$skpcvax$skpc: pushl r10 # save r10 so it can hold handler # establish_handler string_accvio movab string_accvio,r10 pushl r2 # save register ashl $-16,r0,r2 # get character to be skipped movzwl r0,r0 # clear unused bits & check for 0 length beql 2f # simply return if yes # mark_point skpc_1 .text 2 .set table_size, table_size + 1 .word Lskpc_1 - module_base .text 3 .word skpc_1 - module_base .textLskpc_1:1: cmpb r2,(r1)+ # character match? bneq 3f # exit loop if no sobgtr r0,1b # if we drop through the end of the loop into the following code, then # the input string was exhausted with all of string equal to "char".2: # popr $^m<r2,r10> # restore saved r2 and r10 popr $0x404 tstl r0 # insure that c-bit is clear rsb # return with z-bit set # exit path when nonmatching character located3: decl r1 # point r1 to located character brb 2b # join common code #+ # functional description: # # the source string specified by the source length and source address # operands is searched for a substring which matches the object string # specified by the object length and object address operands. if the # substring is found, the condition code z-bit is set# otherwise, it is # cleared. # # input parameters: # # r0<15:0> = objlen length of object string # r1 = objaddr address of object string # r2<15:0> = srclen length of source string # r3 = srcaddr address of source string # # intermediate state: # # 31 23 15 07 00 # +----------------+----------------+----------------+----------------+ # | delta-pc | xxxx | objlen | : r0 # +----------------+----------------+----------------+----------------+ # | objaddr | : r1 # +----------------+----------------+----------------+----------------+ # | xxxxx | srclen | : r2 # +----------------+----------------+----------------+----------------+ # | srcaddr | : r3 # +----------------+----------------+----------------+----------------+ # # output parameters: # # match occurred # # r0 = 0 # r1 = address of one byte beyond end of object string # r2 = number of bytes remaining in the source string # r3 = address of one byte beyond last byte matched # # strings do not match # # r0 = objlen length of object string # r1 = objaddr address of object string # r2 = 0 # r3 = address of one byte beyond end of source string # # condition codes: # # n <- 0 # z <- r0 eql 0 # v <- 0 # c <- 0 # # the z bit is clear if the object does not match the source # the z bit is set if a match occurred # # side effects: # # this routine uses five longwords of stack for saved registers. #- .globl vax$matchcvax$matchc: movzwl r0,r0 # clear unused bits & check for 0 length beql L340 # simply return if length is 0 movzwl r2,r2 # clear unused bits & check for 0 length beql L330 # return with condition codes set # based on r0 gtru 0 pushl r10 # save r10 so it can hold handler # establish_handler string_accvio movab string_accvio,r10 # the next set of instructions saves r4..r7 and copy r0..r3 to r4..r7 pushl r7 # pushl r6 # pushl r5 # pushl r4 # movq r0,r4 # movq r2,r6 # brb top_of_loop # skip reset code on first pass # the following code resets the object string parameters (r0,r1) and # points the source string parameters (r2,r3) to the next byte. (note # that there is no explicit test for r6 going to zero. that test is # implicit in the cmpl r0,r2 at top_of_loop.) # in fact, this piece of code is really two nested loops. the object string # is traversed for each substring in the source string. if no match occurs, # then the source string is advanced by one character and the inner loop is # traversed again.reset_strings: decl r6 # one less byte in source string incl r7 # ... at address one byte larger movq r4,r0 # reset object string descriptor movq r6,r2 # load new source string descriptortop_of_loop: cmpl r0,r2 # compare sizes of source and object bgtru L350 # object larger than source => no match # MARK_POINT MATCHC_1 .text 2 .set table_size, table_size + 1 .word Lmatchc_1 - module_base .text 3 .word matchc_1 - module_base .textLmatchc_1:L310: cmpb (r1)+,(r3)+ # does next character match? bneq reset_strings # exit inner loop if no match sobgtr r0,L310 # object exhausted? # if we drop through the loop, then a match occurred. set the correct # output parameters and exit. note that r0 is equal to zero, which # will cause the condition codes (namely the z-bit) to indicate a match. subl2 r4,r2 # subtract objlen from srclenL320: # popr $^m<r4,r5,r6,r7,r10> # restore scratch registers and r10 popr $0x04f0L330: tstl r0 # set condition codes rsb # return # this code executes if the object string is zero length. the upper
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -