📄 vaxdeciml.s
字号:
.byte 15 , 16 , 17 , 18 , 19 # to ^x19 .byte 10 , 10 , 10 , 10 , 10 , 10 # illegal decimal digits .byte 20 , 21 , 22 , 23 , 24 # index ^x20 .byte 25 , 26 , 27 , 28 , 29 # to ^x29 .byte 20 , 20 , 20 , 20 , 20 , 20 # illegal decimal digits .byte 30 , 31 , 32 , 33 , 34 # index ^x30 .byte 35 , 36 , 37 , 38 , 39 # to ^x39 .byte 30 , 30 , 30 , 30 , 30 , 30 # illegal decimal digits .byte 40 , 41 , 42 , 43 , 44 # index ^x40 .byte 45 , 46 , 47 , 48 , 49 # to ^x49 .byte 40 , 40 , 40 , 40 , 40 , 40 # illegal decimal digits .byte 50 , 51 , 52 , 53 , 54 # index ^x50 .byte 55 , 56 , 57 , 58 , 59 # to ^x59 .byte 50 , 50 , 50 , 50 , 50 , 50 # illegal decimal digits .byte 60 , 61 , 62 , 63 , 64 # index ^x60 .byte 65 , 66 , 67 , 68 , 69 # to ^x69 .byte 60 , 60 , 60 , 60 , 60 , 60 # illegal decimal digits .byte 70 , 71 , 72 , 73 , 74 # index ^x70 .byte 75 , 76 , 77 , 78 , 79 # to ^x79 .byte 70 , 70 , 70 , 70 , 70 , 70 # illegal decimal digits .byte 80 , 81 , 82 , 83 , 84 # index ^x80 .byte 85 , 86 , 87 , 88 , 89 # to ^x89 .byte 80 , 80 , 80 , 80 , 80 , 80 # illegal decimal digits .byte 90 , 91 , 92 , 93 , 94 # index ^x90 .byte 95 , 96 , 97 , 98 , 99 # to ^x99 .byte 90 , 90 , 90 , 90 , 90 , 90 # illegal decimal digits #+ # binary number to decimal equivalent # # the following table is used to do a fast conversion from a binary number # stored in a byte to its decimal representation. the table structure assumes # that the number lies in the range 0 to 99. numbers that lie outside this # range produce unpredictable resutls. #- # decimal equivalents binary # ------------------- ------ .globl decimal$binary_to_packed_tabledecimal$binary_to_packed_table: .byte 0x00 , 0x01 , 0x02 , 0x03 , 0x04 # 0 through 9 .byte 0x05 , 0x06 , 0x07 , 0x08 , 0x09 # .byte 0x10 , 0x11 , 0x12 , 0x13 , 0x14 # 10 through 19 .byte 0x15 , 0x16 , 0x17 , 0x18 , 0x19 # .byte 0x20 , 0x21 , 0x22 , 0x23 , 0x24 # 20 through 29 .byte 0x25 , 0x26 , 0x27 , 0x28 , 0x29 # .byte 0x30 , 0x31 , 0x32 , 0x33 , 0x34 # 30 through 39 .byte 0x35 , 0x36 , 0x37 , 0x38 , 0x39 # .byte 0x40 , 0x41 , 0x42 , 0x43 , 0x44 # 40 through 49 .byte 0x45 , 0x46 , 0x47 , 0x48 , 0x49 # .byte 0x50 , 0x51 , 0x52 , 0x53 , 0x54 # 50 through 59 .byte 0x55 , 0x56 , 0x57 , 0x58 , 0x59 # .byte 0x60 , 0x61 , 0x62 , 0x63 , 0x64 # 60 through 69 .byte 0x65 , 0x66 , 0x67 , 0x68 , 0x69 # .byte 0x70 , 0x71 , 0x72 , 0x73 , 0x74 # 70 through 79 .byte 0x75 , 0x76 , 0x77 , 0x78 , 0x79 # .byte 0x80 , 0x81 , 0x82 , 0x83 , 0x84 # 80 through 89 .byte 0x85 , 0x86 , 0x87 , 0x88 , 0x89 # .byte 0x90 , 0x91 , 0x92 , 0x93 , 0x94 # 90 through 99 .byte 0x95 , 0x96 , 0x97 , 0x98 , 0x99 # #+ # functional description: # # in 3 operand format, the source 1 string specified by the length and # source 1 address operands is compared to the source 2 string specified # by the length and source 2 address operands. the only action is to # affect the condition codes. # # in 4 operand format, the source 1 string specified by the source 1 # length and source 1 address operands is compared to the source 2 string # specified by the source 2 length and source 2 address operands. the # only action is to affect the condition codes. # # input parameters: # # entry at vax$cmpp3 # # r0 - len.rw length of either decimal string # r1 - src1addr.ab address of first packed decimal string # r3 - src2addr.ab address of second packed decimal string # # entry at vax$cmpp4 # # r0 - src1len.rw length of first packed decimal string # r1 - src1addr.ab address of first packed decimal string # r2 - src2len.rw length of second packed decimal string # r3 - src2addr.ab address of second packed decimal string # # output parameters: # # r0 = 0 # r1 = address of the byte containing the most significant digit of # the first source string # r2 = 0 # r3 = address of the byte containing the most significant digit of # the second source string # # condition codes: # # n <- first source string lss second source string # z <- first source string eql second source string # v <- 0 # c <- 0 # # register usage: # # this routine uses r0 through r5. the condition codes are recorded # in r2 as the routine executes. # # algorithm: # # tbs #- #+ # define some bit fields that allow recording the presence of minus signs # in either or both of the source strings. #-/* $defini cmppx_flags * * _vield cmppx,0,<- * <src1_minus,,m>,- * <src2_minus,,m>,- * > * * $defend cmppx_flags */ .globl vax$cmpp3vax$cmpp3: movzwl r0,r2 # make two source lengths equal brb L110 # only make one length check .globl vax$cmpp4vax$cmpp4: # roprand_check r2 # insure that r2 lequ 31 cmpw r2,$31 blequ 1f brw decimal_roprand1: movzwl r2,r2L110: # roprand_check r0 # insure that r0 lequ 31 cmpw r0,$31 blequ 1f brw decimal_roprand1: movzwl r0,r0 # pushr $^m<r0,r1,r2,r3,r4,r5,r10> # save some registers pushr $0x043f # 002 # establish_handler decimal_accvio # Store address of access # violation handler movab decimal_accvio,r10 # get sign of first input string clrl r4 # assume both strings contain "+" extzv $1,$4,r0,r5 # convert digit count to byte count # mark_point cmppx_accvio .text 2 .set table_size,table_size + 1 .word Lcmppx_accvio - module_base .text 3 .word cmppx_accvio - module_base .textLcmppx_accvio: bicb3 $0x0f0,(r1)[r5],r5 # r5 contains "sign" digit caseb r5,$10,$15-10 # dispatch on sign digitL1: .word 3f-L1 # 10 => sign is "+" .word 2f-L1 # 11 => sign is "-" .word 3f-L1 # 12 => sign is "+" .word 2f-L1 # 13 => sign is "-" .word 3f-L1 # 14 => sign is "+" .word 3f-L1 # 15 => sign is "+"2: bisl2 $cmppx_m_src1_minus,r4 # remember that src1 contains "-" # now get sign of second input string3: extzv $1,$4,r2,r5 # convert digit count to byte count # mark_point cmppx_accvio_a .text 2 .set table_size,table_size + 1 .word Lcmppx_accvio_a - module_base .text 3 .word cmppx_accvio - module_base .textLcmppx_accvio_a: bicb3 $0x0f0,(r3)[r5],r5 # r5 contains "sign" digit caseb r5,$10,$15-10 # dispatch on sign digitL2: .word 5f-L2 # 10 => sign is "+" .word 4f-L2 # 11 => sign is "-" .word 5f-L2 # 12 => sign is "+" .word 4f-L2 # 13 => sign is "-" .word 5f-L2 # 14 => sign is "+" .word 5f-L2 # 15 => sign is "+"4: bisl2 $cmppx_m_src2_minus,r4 # remember that src2 contains "-" # at this point, we have determined the signs of both input strings. if the # strings have different signs, then the comparison is done except for the # extraordinary case of comparing a minus zero to a plus zero. if both signs # are the same, then a digit-by-digit comparison is required.5: caseb r4,$0,$3-0 # dispatch on combination of signsL3: .word 6f-L3 # both signs are "+" .word minus_zero_check-L3 # signs are different .word minus_zero_check-L3 # signs are different .word 6f-L3 # both signs are "-" # both strings have the same sign. if the strings have different lengths, then # the excess digits in the longer string are checked for nonzero because that # eliminates the need for further comparison.6: subl3 r0,r2,r5 # get difference in lengths beql equal_length # strings have the same size blss src2_shorter # src2 is shorter than src1 # this code executes when src1 is shorter than src2. that is, r0 lssu r2. # the large comment at the beginning of this module explains the need for the # incl r5 instruction when r0, the length of the shorter string, is odd.src1_shorter: blbc r0,7f # skip adjustment if r0 is even incl r5 # adjust digit difference if r0 is odd7: extzv $1,$4,r5,r5 # convert digit count to byte count beql equal_length # skip loop if no entire bytes in excess # mark_point cmppx_accvio_b .text 2 .set table_size,table_size + 1 .word Lcmppx_accvio_b - module_base .text 3 .word cmppx_accvio - module_base .textLcmppx_accvio_b:8: tstb (r3)+ # test excess src2 digits for nonzero bneq src1_smaller # all done if nonzero. src1 lss src2 sobgtr r5,8b # test for end of loop brb equal_length # enter loop that performs comparison # this code executes when src2 is shorter than src1. that is, r2 lssu r0. # the large comment at the beginning of this module explains the need for the # incl r5 instruction when r2, the length of the shorter string, is odd.src2_shorter: movl r2,r0 # r0 contains number of remaining digits mnegl r5,r5 # make difference positive blbc r2,9f # skip adjustment if r2 is even incl r5 # adjust digit difference if r2 is odd9: extzv $1,$4,r5,r5 # convert digit count to byte count beql equal_length # skip loop if no entire bytes in excess # mark_point cmppx_accvio_c .text 2 .set table_size,table_size + 1 .word Lcmppx_accvio_c - module_base .text 3 .word cmppx_accvio - module_base .textLcmppx_accvio_c:0: tstb (r1)+ # test excess src1 digits for nonzero bneq src2_smaller # all done if nonzero. src2 lss src1 sobgtr r5,0b # test for end of loop # all excess digits are zero. we must now perform a digit-by-digit comparison # of the remaining digits in the two strings. r0 contains the remaining number # of digits in either string.equal_length: extzv $1,$4,r0,r0 # convert digit count to byte count beql 2f # all done if no digits remain # mark_point cmppx_accvio_d .text 2 .set table_size,table_size + 1 .word Lcmppx_accvio_d - module_base .text 3 .word cmppx_accvio - module_base .textLcmppx_accvio_d:1: cmpb (r1)+,(r3)+ # compare next two digits bneq not_equal # comparison complete if not equal sobgtr r0,1b # test for end of loop
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -