📄 vaxeditpc.s
字号:
# # all of the following labels are associated with exceptions that occur # inside a loop that is reading digits from the input stream and # optionally storing these or other characters in the output string. # while it is a trivial matter to back up the output pointer and restart # the loop from the beginning, it is somewhat more difficult to handle # all of the cases that can occur with the input packed decimal string # (because a byte can contain two digits). to avoid this complication, # we add the ability to restart the various loops where they left off. # in order to accomplish this, we need to store the loop count and, # optionally, the latest input digit in the intermediate state array. # # the two entry points where the contents of r7 (the last digit read # from the input stream) are significant are move_2 and float_3. all # other entry points ignore the contents of r7. (note that these two # entry points exit through label 60$ to store r7 in the saved register # array.) # # input parameters: # # r0 - address of top of stack when access violation occurred # r7 - latest digit read from input stream (move_2 and float_3 only) # r8 - remaining loop count # # 00(r0) - return pc to main vax$editpc control loop # 04(r0) - saved r0 # 08(r0) - saved r1 # etc. # # output parameters: # # a restart code that is unique for each entry is stored in the saved # register array. the loop count (and the latest input digit, if # appropriate) is also stored before passing control to editpc_pack. # # editpc_b_state(sp) - code that uniquely determines the code that # was executing when the access violation was detected. # # editpc_b_eo_read_char(sp) - latest digit read from the input string # # editpc_b_loop_count(sp) - remaining loop count # # side effects: # # r0 is unchanged by this code path #- # assume editpc_v_state eq 0fill_2: movb $fill_2_restart,editpc_b_state(sp) brb 7fmove_2: movb $move_2_restart,editpc_b_state(sp) brb 6fmove_3: movb $move_3_restart,editpc_b_state(sp) brb 7ffloat_2: movb $float_2_restart,editpc_b_state(sp) brb 6ffloat_3: movb $float_3_restart,editpc_b_state(sp) brb 6ffloat_4: movb $float_4_restart,editpc_b_state(sp) brb 7fblank_zero_2: movb $blank_zero_2_restart,editpc_b_state(sp) brb 7f6: movb r7,editpc_b_eo_read_char(sp) # save result of latest read7: movb r8,editpc_b_loop_count(sp) # save loop counter brb 8f #+ # functional description: # # an access violation at editpc_1 indicates that the byte containing the # sign of the input packed decimal string could not be read. there is # little state to preserve. the key step here is to store a restart code # that differentiates this exception from the large number that can be # restarted at the top of the command loop. # # input parameters: # # 00(r0) - saved r0 # 04(r0) - saved r1 # etc. # # output parameter: # # editpc_b_state(sp) - code that indicates that instruction should # be restarted at point where sign "digit" is fetched. #-editpc_1: movb $editpc_1_restart,editpc_b_state(sp) brb editpc_pack #+ # functional description: # # this routine handles all of the simple access violations, those that # can be backed up to the same intermediate state. in general, an access # violation occurred in one of the simpler routines or at some other # point where it is not difficult to back up the editpc operation to the # top of the main dispatch loop. # # input parameters: # # r3 - points one byte beyond current pattern operator (except for # replace_sign_2 where it is one byte further along) # # 00(r0) - top_of_loop (return pc to main vax$editpc control loop) # 04(r0) - saved r0 # 08(r0) - saved r1 # etc. # # output parameters: # # r3 must be decremented to point to the pattern operator that was being # processed when the exception occurred. the return pc must be # "discarded" to allow the registers to be restored and the return pc # from vax$editpc to be located. # # r3 - points to current pattern operator # # 00(r0) - saved r0 # 04(r0) - saved r1 # etc. # # output parameter: # # editpc_b_state(sp) - the restart point called editpc_2 is the place # from which all "simple" access violations are restarted. # this is essentially the location top_of_loop. #-end_float_1: bbsc $psl$v_c,r11,9f brb 9freplace_sign_2: decl editpc_a_pattern(sp) # back up to "length" byteeditpc_3:editpc_4:editpc_5:insert_1:insert_2:store_sign_1:fill_1:move_1:float_1:blank_zero_1:replace_sign_1:load_xxxx_1:load_xxxx_2:adjust_input_1:9: decl editpc_a_pattern(sp) # back up to current pattern operatoreditpc_2: movb $editpc_2_restart,editpc_b_state(sp) # store special restart code8: addl2 $4,r0 # discard return pc # ... and drop through to editpc_pack #+ # functional description: # # this routine stores the intermediate state of an editpc instruction # that has been prematurely terminated by an access violation. these # exceptions and illegal pattern operators are the only exceptions from # which execution can continue after the exceptional condition has been # cleared up. after the state is stored in the registers r0 through r5, # control is transferred to vax$reflect_fault, where the appropriate # backup method is determined, based on the return pc from the # vax$editpc routine. # # input parameters: # # r0 - current digit count in input string # r1 - address of next digit in input string # r2 - fill character # r3 - address of current pattern operator # r4 - sign character (stored in r2<15:8>) # r5 - address of next character to be stored in output character string # r9 - zero count (stored in r0<31:16>) # r11 - condition codes # # 00(r0) - saved r0 # 04(r0) - saved r1 # 08(r0) - saved r6 # 12(r0) - saved r7 # 16(r0) - saved r8 # 20(r0) - saved r9 # 24(r0) - saved r10 # 28(r0) - saved r11 # 32(r0) - return pc from vax$editpc routine # # output parameters: # # r0 - address of return pc from vax$editpc routine # # 00(r0) - return pc from vax$editpc routine # # some of the register contents are dictated by the vax architecture. # other register contents are architecturally described as "implementation # dependent" and are used to store the instruction state that enables it # to be restarted successfully and complete according to specifications. # # the following register contents are architecturally specified # # r0<15:00> - current digit count in input string # r0<31:16> - current zero count (from r9) # r1 - address of next digit in input string # r2<07:00> - fill character # r2<15:08> - sign character (from r4) # r3 - address of current pattern operator # r5 - address of next character in output character string # # the following register contents are peculiar to this implementation # # r2<23:16> - delta-pc (if initiated by exception) # r2<31:24> - delta srcaddr (current srcaddr minus initial srcaddr) # r4<07:00> - initial digit count (from saved r0) # r4<15:08> - saved condition codes (for easy retrieval) # r4<23:16> - state flags # state field determines the restart point # fpd bit is set # accvio bit is set # r4<31:24> - unused for this exception (see access violations) # # the condition codes are not architecturally specified by the vax # architecture for an access violation. the following list applies to # some but not all of the points where an access violation can occur. # # psl<n> - source string has a minus sign # psl<z> - all digits are zero so far # psl<v> - nonzero digits have been lost # psl<c> - significance #-editpc_pack: # now start stuffing the various registers movw r9,editpc_w_zero_count(sp) # save r9 in r0<31:16> movb r4,editpc_b_sign(sp) # save r4 in r2<15:8> movq (r0)+,r2 # get initial r0/r1 to r2/r3 movb r2,editpc_b_inisrclen(sp) # save initial value of r0 subl3 r3,editpc_a_srcaddr(sp),r3 # calculate srcaddr difference movb r3,editpc_b_delta_srcaddr(sp) # store it in r4<15:8> movb r11,editpc_b_saved_psw(sp) # save condition codes bisb2 $editpc_m_fpd,editpc_b_state(sp) # set the fpd bit # restore the remaining registers movq (r0)+,r6 # restore r6 and r7 movq (r0)+,r8 # ... and r8 and r9 movq (r0)+,r10 # ... and r10 and r11 # get rid of the extra copy of saved registers on the stack movq (sp)+,16(sp) # copy the saved r0/r1 pair movq (sp)+,16(sp) # ... and the saved r2/r3 pair movq (sp)+,r4 # r4 and r5 can be themselves # r1 contains delta-pc offset and indicates that fpd gets set # movl $<editpc_b_delta_pc!- # locate delta-pc offset # pack_m_fpd!- # set fpd bit in exception psl # pack_m_accvio>,r1 # indicate an access violation movl $(editpc_b_delta_pc|pack_m_fpd|pack_m_accvio),r1 jmp vax$reflect_fault # reflect fault to caller #+ # functional description: # # this routine receives control when an editpc instruction is restarted. # the instruction state (stack and general registers) is restored to the # point where it was when the instruction (routine) was interrupted and # control is passed back to the top of the control loop or to another # restart point. # # input parameters: # # 31 23 15 07 00 # +----------------+----------------+----------------+----------------+ # | zero count | srclen | # +----------------+----------------+----------------+----------------+ # | delta-srcaddr | delta-pc | sign | fill | # +----------------+----------------+----------------+----------------+ # | loop-count | state | saved-psw | inisrclen | # +----------------+----------------+----------------+----------------+ # | dstaddr | # +----------------+----------------+----------------+----------------+ # # depending on where the exception occurred, some of these parameters # may not be relevant. they are nevertheless stored as if they were # valid to make this restart code as simple as possible. # # these register fields are more or less architecturally defined. they # are strictly specified for a reserved operand fault (illegal pattern # operator) and it makes sense to use the same register fields for # access violations as well. # # r0<07:00> - current digit count in input string # (see eo_read_char below) # r0<31:16> - current zero count (loaded into r9) # r1 - address of next digit in input string # r2<07:00> - fill character # r2<15:08> - sign character (loaded into r4) # r3 - address of next pattern operator # r5 - address of next character in output character string # # these register fields are specific to this implementation. # # r0<15:08> - latest digit from input string (loaded into r7) # r2<23:16> - size of instruction (unused by this routine) # r2<31:24> - delta srcaddr (used to compute saved r1) # r4<07:00> - initial digit count (stored in saved r0) # r4<15:08> - saved condition codes (stored in r11) # psl<n> - source string has a minus sign # psl<z> - all digits are zero so far # psl<v> - nonzero digits have been lost # psl<c> - significance # r4<23:16> - state flags # state field determines the restart point # r4<31:24> - loop count (loaded into r8) # # 00(sp) - return pc from vax$editpc routine # # implicit input: # # note that the initial "srclen" is checked for legality before any # restartable exception can occur. this means that r0 lequ 31, which # leaves bits <15:5> free for storing intermediate state. in the case of # an access violation, r0<15:8> is used to store the latest digit read # from the input stream. in the case of an illegal pattern operator, # r0<15:5> are not used so that the architectural requirement that # r0<15:0> contain the current byte count is adhered to. # # output parameters: # # all of the registers are loaded, even if some of their contents are # not relevant to the particular point at which the instruction will be # restarted. this makes the output of this routine conditional on a # single thing, namely on whether the restart point is in one of the # pattern-specific routines or in the outer vax$editpc routine. this # comment applies especially to r7 and r8. # # r0 - current digit count in input string # r1 - address of next digit in input string # r2 - fill character # r3 - address of next pattern operator # r4 - sign character (stored in r2<15:8>) # r5 - address of next character to be stored in output character string # r6 - scratch # r7 - latest digit read from input packed decimal string # r8 - loop count # r9 - zero count (stored in r0<31:16>) # r10 - address of editpc_accvio, this module's "condition handler" # r11 - condition codes # # 00(sp) - saved r0 # 04(sp) - saved r1 # 08(sp) - saved r6 # 12(sp) - saved r7 # 16(sp) - saved r8 # 20(sp) - saved r9 # 24(sp) - saved r10 # 28(sp) - saved r11 # 32(sp) - return pc from vax$editpc routine # # side effects: # # r6 is assumed unimportant and is used as a scratch register by this # routine as soon as it is saved. #- .globl vax$editpc_restartvax$editpc_restart: # pushr $^m<r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11> # save them all pushr $0x0fff # establish_handler editpc_accvio # reload r10 with handler address movab editpc_accvio,r10 movzbl r0,r0 # clear out
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -