Complete the supplied mips program skeleton

Assignment Help Assembly Language
Reference no: EM132389750

Just needs to be translated into MIPS from C

Setting Up

Create a private directory for doing the assignment, and put the assignment files in it by running the following command:

$ unzip /home/dp1092/public_html/19T3/assignments/assign1/assign1.zip

If you''re working on this at home, download the ZIP file and create the files on your home machine. It''s fine to work on your own machine but remember to always test your code on the CSE machines before submitting.

The above command will create the following files:

Makefile
A file to control compilation of scroll.c. It is not critical for the MIPS assembler part: it creates the executable C program to give you an exemplar, and can produce the exe.s file.

scroll.c
A complete solution, written in C. Your goal is to write a MIPS assembler program to copy the behaviour of this program.

chars.h
The array of big characters used in producing the scrolling text. This is #include''d in scroll.c.

scroll.s
A partly complete solution to the assignment, written in MIPS assembler.

chars.s
A MIPS version of the array of big characters used in producing the scrolling text. This file requires no modification.

Initially, it would be worth compiling the C program and running it on some examples to get a feel for its behaviour. The compiled C program, called scroll, expects a single command-line argument: the text string to be scrolled.

You can compile and run the C program (scroll) as follows:

$ make
gcc -g -Wall -Werror -std=c99 scroll.c -o scroll
$ ./scroll
Usage: ./scroll String
$ ./scroll "It''s fun"
Only letters and spaces are allowed in the string!
$ ./scroll abc def
... scrolls "abc"; it only uses the first commond-line argument
$ ./scroll "Hello there"
... scrolls "Hello there", like the above video
The Program
What the scrolling program should do, whether implemented in MIPS or C:

check the command-line argument (< 100 chars, only letters and spaces)
create a buffer containing big versions of the characters in argv[1]
add part of the content of the big-char buffer into the display buffer, starting at starting_pos
write the contents of the display buffer to standard output
repeat, moving one column to the left each time, until the message scrolls of the left of the display
Both the C and the MIPS programs are structured the same, with a main function to handle the command-line arguments and then run the scrolling. The programs also have the same set of lower-level functions. In scroll.c, there are comments describing the purpose of each function and the code is hopefully clear enough that you can understand how each function works.

The diagram below shows the major data structures used by the programs:

theString[100] holds a copy of the string from argv[1]
bigString[9][1000] holds a copy of theString in big characters and with one column of space between adjacent big characters
display[9][80] is where characters are placed before being written out to the screen
all_chars[52*9*9] array containing representation of ''A''-''Z'' and ''a''-''z'' as big chars (not shown in the diagram; defined in the chars.s file)

Exercise
The aim of this exercise is to complete the supplied MIPS program skeleton (in the file scroll.s) to behave exactly like the C program (in scroll.c). You should not change the chars.s file; treat its contents as a read-only data structure.

In scroll.s each function has comments to:

indicate which registers the function uses
indicate which registers the function overwrites (clobbers)
give a mapping between local variables in the C code and registers in MIPS
Note that these are suggestions only; you can use whatever registers you like, provided that you save and restore any $s? registers that you overwrite in the function code. And, of course, provided that the code behaves the same as the C code.

To save you some time, we have included function prologues and epilogues in some functions. These save and restore registers $fp, $ra, and any $s? registers that the function happens to use, and also maintain the stack. You can use these as templates for how to implement the prologue and epilogue in the functions that do not provide them.

Some of the functions from scroll.s are already implemented, but others require you to write MIPS assembler for them. Here''s a rundown of the functions in scroll.s and their status:

main Partly complete, including the epilogue and prologue, and the command-line argument checking.
setUpDisplay Function prologue and epilogue ok. ToDo: function body.
showDisplay Function prologue and epilogue ok. ToDo: function body.
delay Already complete, but you can tweak the numbers if you want, to speed up or slow down the animation.
As supplied, the delay function in scroll.s will be way too slow. The numbers work fine for compiled C, but for interpreted MIPS assembler (which is 1000 times slower). Tweak the loop bounds in delay until you get decent scrolling speed.

While you''re debugging (e.g. in qtspim) the delay is not helpful. The simplest fix would be to comment out the call to delay in the main program.

When we test it, we will comment out the calls to the delay function.

isUpper ToDo: function prologue and epilogue, and function body.
isLower Already complete (and makes isUpper very easy).
Running the program
Note that scroll.s is not stand-alone MIPS program; it requires access to the all_chars[] array in the file chars.s. In order to run the program (either via spim or qtspim), you''ll need to combine the two files. Here''s an example of you might run the program using spim:

$ cat chars.s scroll.s > exe.s
$ spim -file exe.s
... program executes ...
The file exe.s is a complete program that can be loaded into qtspim as well. You will need to do the cat step each time you change the scroll.s file and want to test it. The Makefile knows how to create this file too.

Reference no: EM132389750

Questions Cloud

Customary ratios for a conventional mortgage : How much home can you afford? Customary ratios for a conventional mortgage require that:
Amount of the payments they make each year : K-Ville Sanitation & Garbage Disposal Corp has a $1M outstanding loan they have been paying on for 30 full years, without paying any of the principal.
What is the maximum supportable annual debt service : Property generates $500,000 of net operating income over 12 months.
What is the payback period : After the three years, the cart is expected to be worthless. What is the payback period?
Complete the supplied mips program skeleton : Complete the supplied MIPS program skeleton (in the file scroll.s) to behave exactly like the C program (in scroll.c). You should not change the chars.s file
Write response on Neurological : Write response on Neurological that might occur for that body system which does not have to be something that can be performed in the medical assisting office
What is the present value of investment : If the company uses a discount rate of 15 percent on its investments, what is the present value of this investment?
Overview of the current housing construction methods : Evaluate the risks associated with moving from a traditional housing construction method, to a prefabricated method that will be designed to take advantage
What is the embedded rate of return : a) What is the embedded rate of return associated with the two alternative modes of payoff?

Reviews

Write a Review

Assembly Language Questions & Answers

  Arm assembly programming

ARM Assembly Programming- Complete the task1.s code to produce an assembly program that. Waits for the user to enter an integer (this part is already coded).

  Calculate the number of one bits in bx

Calculate the number of one bits in bx and complement an equal number of least significant bits in ax hint use the xor instruction

  Write a program called knapsack that solves knapsack problem

Write a program called knapsack.s that solves the 0-1 knapsack problem recursively. In the knapsack problem you have a knapsack that can hold W weight.

  Write an assembly program

Prepare an Assembly program that reads in a number of cents.

  Cache statistics for two versions of matrix multiplication

Explore the cache statistics for two versions of matrix multiplication - Cache can be configured using the preference in ARMSim. For getting cache statistics, first put a breakpoint on SWI 0x11 instruction, and then note the statistics from cache

  Arm assembly language program

Arm Assembly language Program: The safe starts unlocked, cannot be locked and there are no valid codes. Whenever there are no codes the safe cannot be locked

  Use maries isa program a stack structure for unsigned

use maries isa program a stack structure for unsigned integers.stackyou should write three subroutines for the stack

  What is the hallmark of an assembly language

What is the hallmark of an assembly language? Distinguish between an assembler and a compiler. Distinguish between a compiler and an interpreter.

  Compute the boolean expression a and b or c

Compute the Boolean expression ( A AND B) OR C for. Devise a way to interchange two variables A and B without using a third variable or register. Hint: Think about the EXCLUSIVE OR instruction.

  Write a procedure for generating fibonacci numbers

Write a procedure for generating Fibonacci numbers of O(log(n)) by creating pairs of consecutive Fibonacci numbers based on the obseivations.

  Why do we need to know the registers and the flags

Why do we need to know the registers and the flags in any computer architecture in order to write assembly language programs?

  Write an assembly language program in armv-eight

Write (and test using DS5) an assembly language program in ARMv8 to find the sum, the largest and the smallest of n non-zero positive integers.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd