Question

In: Computer Science

Provided code: .data arrayB: .word 0xffff, 0xffff, 0xffff, 0xffff .text Using syscalls o A “syscall” is...

Provided code:
.data
arrayB: .word 0xffff, 0xffff, 0xffff, 0xffff
.text

Using syscalls

o A “syscall” is a function that is provided by the operating system of the MIPS computer, not by the MIPS architecture itself. Examples are the ability to print data to the MIPS computer’s display monitor, obtain the time of day, etc.

o Open the MARS help screen, and select the Syscalls tab to bring up the available syscalls. Find and review the section “How to use SYSCALL system services.”

o You will use syscall 41, “random int.” Use of a syscall requires a series of MIPS instructions. You must provide the “setup” of a syscall by setting values in registers, then make the syscall itself.

  • MIPS instruction to put the value 41 into register $v0. This specifies which syscall will be executed.
  • The random integer syscall needs no other parameters. In general, a syscall may require that other parameter values be placed in registers.
  • MIPS instruction syscall (just the word “syscall” by itself on a line)
  • The outcome of this syscall is that a random number will have been placed into a register. Use the documentation in the help page to find out which register.

Write a loop that will generate 6 random integers and store them in arrayB.

Write instructions to prepare for a future loop, including the following actions:

  • Initialize a loop counter
  • Put the address of arrayB into a register, using the la instruction.

Write instructions to complete the body of the loop, including the following actions:

  • Syscalls for random integer (see above)
  • Store that random integer into the the arrayB at the correct location.
  • Modify the base address for the next iteration of the loop
  • Modify the loop counter value

Solutions

Expert Solution

Answer:

Given that

provided code:

.data

arrayB:.word 0xffff,0xffff,0xffff,0xffff

.text

I have implemented Using "syscall" is a function that is provided by the operating system of the MIPS computer, not the MIPS architecture itself.

code:

.data

arrayB: .word 0:5

.text

la $a1, arrayB

loop:

bgt $t0,5,exit #check if greater than 6

li $v0, 41 #syscall for random int

syscall

mul $t1, $t0, 4 #multiply to calculate offset for array

addu $t2, $t1, $a1 #calculate offseted address

sw $a0, 0($t2) #store at offseted address

addi $t0,$t0,1 #increment loop counter

j loop #jump to label

exit:

Screenshot:


Related Solutions

The following are to be completed using MIPS Assembly code. A.   Using syscall #4, display a...
The following are to be completed using MIPS Assembly code. A.   Using syscall #4, display a prompt for the user to enter a number. Then using syscall #5, get a decimal number from the user and save it to data memory (not into a register). After you have stored the number, display it back to the user as a 32-bit binary value. B.   Prompt the user to enter a decimal number and save it to data memory. Using addition and/or...
pseudo-code, please If a word has a tag O, it means that the word has nothing...
pseudo-code, please If a word has a tag O, it means that the word has nothing to do with the named entity (it is not a part of a named entity such as a location, person name, organization, and etc.) If a word has a tag starting with B, it means that the word is the beginning of a named entity. For instance, the tag B-per means that the associated word is the beginning of a person's name. On the...
I have a Python code that reads the text file, creates word list then calculates word...
I have a Python code that reads the text file, creates word list then calculates word frequency of each word. Please see below: #Open file f = open('example.txt', 'r') #list created with all words data=f.read().lower() list1=data.split() #empty dictionary d={} # Adding all elements of the list to a dictionary and assigning it's value as zero for i in set(list1):     d[i]=0 # checking and counting the values for i in list1:     for j in d.keys():        if i==j:           d[i]=d[i]+1 #Return all non-overlapping...
ZAKI LLP is a networking entity. Required Using the data provided below Draw an A-O-A diagram...
ZAKI LLP is a networking entity. Required Using the data provided below Draw an A-O-A diagram based on normal times and identify the critical path, calculate the normal cost for the project. Determine the minimum project completion time with the least cost and calculate the percentage increase in costs. Use the network diagram in (a) above to construct a simple Gantt chart. Note: Time is in Weeks and Cost in USD. Activity Normal time Crash time Normal cost Crash cost...
Using C++, write a code that this program always stores text file output into a text...
Using C++, write a code that this program always stores text file output into a text file named "clean.txt". -The program should read one character at a time from "someNumbers.txt", and do the following. -If it is a letter, print that letter to the screen, AND also store it in the text file. All letters should be converted to lowercase beforehand. -If it is a number, print that number to screen, but do NOT store it in the text file....
using java, parse a text file to be able to list the word(s) with the highest...
using java, parse a text file to be able to list the word(s) with the highest frequency in a sentence across all sentences in the whole file, also print its frequency and the corresponding sentence. cannot use hash maps. assume text file will be multiple paragraphs long.
Create C# code that can search a text file and output the data at the line...
Create C# code that can search a text file and output the data at the line number inputted and amount of entries needed. Example of call in command window: Search16s filename.txt 273   10 Where 273 is the line number to start the output from, and 10 is the number of sequences that the program should output. The number of sequences entered on call should always be a odd number or give an error in console. The output should also display...
Write a C++ program using produces Huffman code for a string of text entered by the...
Write a C++ program using produces Huffman code for a string of text entered by the user. Must accept all ASCII characters.
C++ Code You will write a program to process the lines in a text file using...
C++ Code You will write a program to process the lines in a text file using a linked list and shared pointers. You will create a class “Node” with the following private data attributes: • Line – line from a file (string) • Next (shared pointer to a Node) Put your class definition in a header file and the implementation of the methods in a .cpp file. The header file will be included in your project. If you follow the...
Create a 50+ word ethics code for your small business based upon the information provided below....
Create a 50+ word ethics code for your small business based upon the information provided below. You may want to search for various codes of conduct/code of ethics to see how these are typically written for a business. You are the owner of a new pet grooming boutique called Cats Rule-Dogs Obey. You will need to hire three groomers. In addition to grooming cats and dogs, the groomers will be responsible for scheduling appointments, keeping the boutique clean and stock...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT