Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

!!!! PLEASE READ !!!! If you plan on copy and pasting some random answer, please, DO NOT DO IT HERE . I seriously need help

!!!! PLEASE READ !!!! If you plan on copy and pasting some random answer, please, DO NOT DO IT HERE. I seriously need help with this topic and have already received FIVE 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 in advance.

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.

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions