Construct the example of the subroutine instruction (SBR) and the return instruction (RET) program shown in Figure 9-19. The purpose of the program is to find the average value of N7:5 and N7:20 and...

Construct the example of the subroutine instruction (SBR) and the return instruction (RET) program shown in Figure 9-19. The purpose of the program is to find the average value of N7:5 and N7:20 and store the result in N7:30. This is accomplished by passing parameters to the subroutine and doing the math in the subroutine, and then returning the answer to the main program through the RET instruction. The operation of the program can be summarized as follows: When S1 is closed, the data from the input parameter, N7:5, are copied into the first input parameter in the SBR instruction, N7:50. The data from the second input parameter, N7:20, are copied into the second input parameter in the SBR, N7:51. In the subroutine, N7:50 and N7:51 are then added together, with the result stored in N7:52. The value in N7:52 is then divided by 2, which gives the average of N7:50 and N7:51, with the result stored in N7:53. The RET instruction then returns the average value through the return parameter, N7:53, to N7:30 in the JSR instruction in the first rung in the main program. Prove the operation by using the data monitor to insert values for N7:5 and N7:20 and verifying that the average value is contained in N7:30.

May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here