Question: !!!! PLEASE READ - DO NOT SKIP !!!! If you plan on copy and pasting some random answer, please, DO NOT DO IT HERE. MOVE
!!!! PLEASE READ - DO NOT SKIP !!!! If you plan on copy and pasting some random answer, please, DO NOT DO IT HERE. MOVE TO THE NEXT QUESTION. I seriously need help with this topic and have already received SIX answers that were completely unrelated to the question. PLEASE, SKIP THIS QUESTION IF YOU DONT WANT TO HELP!!
If you do want to help, thank you so much in advance. It is so hard finding a someone here on Chegg that doesn't just copy random code.
Using MIPS Assembly Language (with comments), write a function print_line that mimics system call 4. The only input parameter to this function should be the memory address of the start of a null terminated character array (appropriately stored on the stack). The function should utilize MMIO to print out the characters in the array one by one. Once the null terminator is reached, print out a newline character. Below I have attached the code to a program that would mimic system call 8, you may use this as a reference.

li $v0, 4 la $a0, prompt syscall # invoke readstr la $a0, my_str li $a1, 50 addi $sp, $sp, -12 sw ae, 0($.sp) sw a1, 4($sp) sw ra, 8($sp) jal read_str lw $ra, 8($sp) lw $a0, 0 ($sp) addi $sp, $sp, 12 - # print out user's string using system call 4 1i $vo, 4 syscall # terminate program li $ve, 10 syscall # system call 8 function read str: # read input params from stack lw $a0, 0 ($sp) lw $al, 4($sp) # $a@ holds char array address # $al holds array size 11 $a2, 0xffff0000 subi $a1, $a1, 1 # load base address of keyboard controller into a2 # use Sal as loop counter # subtract 1 because we need room for null character # start of main loop read_loop: #read a single character not_ready: lw $t1, ($a2) # read keyboard status andi $t1, $t1, 1 # extract ready bit beqz $t1, not-ready # if not ready, iterate again # once ready, extract character beq $t0, 18, done-read # exit loop on "enter" key # add character to array # increment array index addi $a0, $a0, 1 addi $a1, $a1, -1 # decrement loop counter beqz $al, done_read b read loop done read: sb $zero, ($a0) jr $ra # encode null character at end of string
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
