Question: Using MIPS assembly code: write a program that computes and prints out the first eleven rows of Pascal's Triangle. Your code must follow the outline
Using MIPS assembly code: write a program that computes and prints out the first eleven rows of Pascal's Triangle. Your code must follow the outline and requirements given below. In your .data segment, store the following 'array' of eleven integers in memory: {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}. Use a single appropriate label to mark the beginning of these integers in memory. In your .text segment, use a "main:" label to mark the start of your program, and use the syscall to properly terminate execution when main ends. Somewhere after the end of your main code, write a function that loops and prints out only the non-zero integers in the array on one console line of output. Somewhere after the end of your main code, write another function that loops through the first 10 integers in the array in forward order. Replace each integer with the sum of itself and the integer that follows it in memory. In code, Data[i] = Data[i] + Data[i+1]. Do this for i = [0..9]. This will properly compute the next row of Pascal's Triangle. In the main part of your code, use these two functions and a loop to compute and print out Pascal's Triangle.
I'm mostly confused about the part where it says "write a function that loops through the first 10 integers in the array in forward order. Replace each integer with the sum of itself". The other layout and printing are pretty basic. Thanks for the help! Below is some of the stuff I've already worked on.
.data title: .asciiz " Pascal's Triangle " prompt2: .asciiz " Thank you. " myArray: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 arraySize: .word 11
.text
main:
# Initialize variables la $s0, myArray la $s1, 0($s0) la $s2, 4($s0) lw $s7, arraySize lw $s6, arraySizeMinusOne addi $t2, $zero, 0 # begin main functions jal printTitle jal computePascal jal printArray
la $a0, prompt2 syscall j exit
printTitle: la $a0, title li $v0, 4 syscall j done
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
