Menu

(Solved) : Modify Following Codes Factorial Function Question Shown Q37156752 . . .

You now revise the program of the sample file (Q0.asm) so the output will display the correction equation and the factorial r

How to modify the following codes into a factorial function asthe question shown:

Initialization ORIG x3000 LDR6, EMPTY LD R5, PTR AND R0, R0, #0 ADD R0, R0, #10 OUT R6 is the stack pointer ; R5 is pointer t

You now revise the program of the sample file (Q0.asm) so the output will display the correction equation and the factorial result of every input value from the “datal.asm”. Save the program as the file Q4.asm For example (data from ‘datal.asm): 006!-720 005!-120 004!-024 003!-006 002!-002 0011-001 Initialization ORIG x3000 LDR6, EMPTY LD R5, PTR AND R0, R0, #0 ADD R0, R0, #10 OUT R6 is the stack pointer ; R5 is pointer to characters Print a new line LDR R3, R5, #0 REDO ; R3 gets character Test character for end of file ADD R4, R3, #-10 BRz EXIT LD R4, ZERO ADD R3. R3, R4 JSR CONV ADD R5, R5, #1 AND R4, R5, #1 BRz EVEN ADD R2, R3, #0 LDR0, PLUS OUT BRnzp REDO LD RO, EQUAL OUT ; Test for end of line (ASCⅡ xA) If done, quit Get the decimal value from ASCⅡ ; check odd/even Save the first operand to R2 EVEN Start calculation ; The second operand is at R3 AND R3. R2. R3 JSRCONV AND R0, R0, #0 ADD R0, R0. #10 OUT BRnzp REDO Print a new line ; A subroutine to output a 3-digit decimal result. CONV EXIT ; Halt machine HALT Show transcribed image text You now revise the program of the sample file (Q0.asm) so the output will display the correction equation and the factorial result of every input value from the “datal.asm”. Save the program as the file Q4.asm For example (data from ‘datal.asm): 006!-720 005!-120 004!-024 003!-006 002!-002 0011-001
Initialization ORIG x3000 LDR6, EMPTY LD R5, PTR AND R0, R0, #0 ADD R0, R0, #10 OUT R6 is the stack pointer ; R5 is pointer to characters Print a new line LDR R3, R5, #0 REDO ; R3 gets character Test character for end of file ADD R4, R3, #-10 BRz EXIT LD R4, ZERO ADD R3. R3, R4 JSR CONV ADD R5, R5, #1 AND R4, R5, #1 BRz EVEN ADD R2, R3, #0 LDR0, PLUS OUT BRnzp REDO LD RO, EQUAL OUT ; Test for end of line (ASCⅡ xA) If done, quit Get the decimal value from ASCⅡ ; check odd/even Save the first operand to R2 EVEN Start calculation ; The second operand is at R3 AND R3. R2. R3 JSRCONV AND R0, R0, #0 ADD R0, R0. #10 OUT BRnzp REDO Print a new line ; A subroutine to output a 3-digit decimal result. CONV EXIT ; Halt machine HALT

Expert Answer


Answer to How to modify the following codes into a factorial function as the question shown:…

OR