Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a subroutine that computes the CHECKSUM for a data table (by XORing all th

ID: 3806985 • Letter: W

Question

Write a subroutine that computes the CHECKSUM for a data table (by XORing all the data bytes). The inputs to the subroutine are a pointer to the table in FSR1 and the number of elements in NUM. The output is the CHECKSUM in the WREG, which is also stored at the end of the table. a) Draw a flowchart for the subroutine (and indicate any registers used). b) Write the assembly language for the subroutine (called by a main program) and simulate using the sample data table: 24, 65, F0. c) Your solution should include the assembler listing and an annotated screen capture of the simulator showing the final register values.

Explanation / Answer

Subroutine called by main program in assemble looks like below :

main: #assume value x is already in $t0, y in $t1
add $a0,$0,$t0 # it is the move function
add $a1,$0,$t1
jal addFunction # call function
add $t4,$0,$v0 # move the return value from $v0 to the register which we want
syscall

addFunction:
addi $sp,$sp,-4 # Stack pointer move
sw $t0, 0($sp) # Previous value store

add $t0,$a0,$a1 # Function Body aadding a0 and a1 and moving to t0
add $v0,$0,$t0 # Result

lw $t0, 0($sp) # Load previous value
addi $sp,$sp,4 # Stack pointer move
jr $ra # return value

Subroutine function adds up two value and gives us the final result.Above code explains about the register as well.

Please let us know if you need further more details. Thanks!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote