Write a function that prints the frequency

Assignment Help Assembly Language
Reference no: EM131601789

Objectives of this practical session

To be able to write MIPS programs involving lists, local variables, and functions.

Note:
- Local variables must be stored on the runtime stack.
- For all the MIPS programs you should first implement a Python version, and work out a faithful translation into MIPS. Both, the Python and MIPS code are required for your prac to be marked. However,Python solutions alone do not result in any marks, all exercises are about MIPS and MIPS solutions are required in all exercises to achieve more than 0 marks.
- Use only instructions on the MIPS reference sheet and use comments to document each piece of code.
- You may copy and paste your code between tasks where you need to reuse code.
- Create a new file/module for each task or subtask.
- Name your files task[num]_[part] to keep them organised.

Task 1

In the Gregorian calendar a year is a leap year if the year is divisible by 4 but not divisible by 100, or if the year is divisible by 400.

(a)Write a Python program task1_a.py, which reads in a year (i.e., an integer ≥ 1582), and if the year is a leap year prints "Is a leap year", otherwise prints "Is not a leap year". In your module you should include a function with the signature def is_leap_year(year) that returns true if it is a leap year otherwise it returns false. You should avoid doing any input or output in this function, instead do the input and output as part of the main function..

Run test_task1_a.py to ensure it works properly. Alternatively you can write your own test. (b)Re-write your Python program without using any user-defined functions. This will help you with a faithful MIPS translation in the following sub-question.

(c)Write a MIPS program which implements task1_b.py.

Task 2

(a) Write a Python program task2_a.py, which performs the steps below.

-Reads in the size of the the_list.
-Reads in all the items of the_list.
-Prints out every other element in the_list. That is, it always prints the first element, skips the second, prints the third, skips the fourth and so on.

Replace any Python for loops for while loops in order to facilitate your MIPS translation.

(b) Write a MIPS program which implements task2_a.py faithfully - there is no need to use functions at this stage.

Task 3

(a) Write a Python program task3_a.py, which does the following:

-Reads in the size of the the_list.

-Reads in all the items of the_list, storing them in a list.

-Prints the range of the list. The range is defined as the difference between the maximum and the minimum element in the list.

Replace any Python for loops for while loops in order to facilitate your MIPS translation. (b)Write a Python program ( task3_b.py ) which implements task3_a.py without using any defined functions. Again, this is in preparation for the following MIPS translation.

(c) Write a MIPS program which implements task3_b.py faithfully.

Background

The bureau of climate research has a device that records the average temperature in the city for each one of the days in a month. The office is interested in understanding climate variation and has commissioned you to design a collection of programs to help analyse the data collected. The programs will run in a small portable device based on a MIPS processor. For each task, first design the algorithm to be used in Python then write the algorithms in MIPS. In each task, the input list is a list containing a number for each day in the month, one temperature record per day.

An example of one such list is:

26, 18, 22, 20, 13, 22, 19, 22, 20, 27, 18, 24, 15, 28, 26, 27, 20, 21, 23, 24, 27, 26, 15,

23, 22, 20, 23, 17, 18,     18

This list is to be read in at the beginning of each task. We assume that the list will only contain natural numbers. The result of each task must be printed. The following tasks describe the functionality required.

Task 4

Write some code to find how many times a given temperature appears in the list. The user should be able to enter the list (including its size), and then the target number that he/she wishes to count.
CHECKPOINT
(You should reach this point during week 3)

Task 5

Write a function that finds the minimum temperature in the list. And use the function to write a program that prints the minimum temperature in any list given by the user. Suggestion: Write your program without using functions first.

Task 6

Write a function that prints the frequency of each temperature in the list between two given temperatures a and b (such that a < b). It is a good idea to decompose this problem in several functions using Python, and then do a faithful translation. Make sure you use Python structures that you know how to translate into MIPS. For example, use lists instead of dictionaries.

For example, if the input is the list given in the Background section, and the user also gives a = 20 and

b = 26, the output should be:
20 appears 4 times
21 appears 1 times
22 appears 4 times
23 appears 3 times
24 appears 2 times
26 appears 3 times

You are encouraged to use re-use functions you have written for other tasks in this assignment.

Task 7

Now we want to store a range of temperatures for different cities. The temperature data should be stored in a matrix, such that each row represents a city and each column represents a day's temperature. Write a program to read in the number of days and the number of cities. The program should then use a menu to ask the user for a city and print the maximum temperature in such city.

Note: Cities are represented by numbers, so there is no need to ask, or store, for any string, simply numbers.

Verified Expert

This assignment prepared in python and mips language to implement the 7 programs. The python programs are formatted in ms word and mips programs are executed in Mar simulator tool and screen shots of the programs are attached .

Reference no: EM131601789

Questions Cloud

What are your thoughts about impact of cash flow forecasting : What are your thoughts about impact of cash flow forecasting in hospitals based on utilization, physician competition, technology and cost of providing care.
Discuss family and medical leave act : Develop a PowerPoint presentation It should include a title slide, an agenda slide, body content slides, a closing slide
Sales outstanding on its cash conversion cycle : Chastain Corporation is trying to determine the effect of its inventory turnover ratio and days sales outstanding (DSO) on its cash conversion cycle.
Analyze competitive forces across dynamic environments : Analyze competitive forces across dynamic and mature environments. Assess external growth strategy and trend in strategic management in competitive environment.
Write a function that prints the frequency : FIT1008 - Intro to Computer Science - Write a function that prints the frequency of each temperature in the list between two given temperatures
What is standard deviation of the return on our portfolio : In comparison, the return on Company B's stock in the coming year could be - 5%, - 1%, 4%, or 12%. The corresponding probabilities are 10%, 30%, 20%.
A quick overview of the agile approach : A quick overview of the Agile approach is to include several iterations providing some of the expected features until the product is complete.
Exploring effects of climate change on antarctic ice sheet : This activity is based on exploring the effects of climate change on the Antarctic ice sheet using satellite images from Google Earth.
Prepare income statement and retained earnings statement : The objective of this project is to give the students an opportunity to learn accounting for intangibles, Prepare Income and Retained Earnings Statement

Reviews

inf1601789

9/18/2017 5:44:08 AM

Dear Team, I'm writing this mail to let you know that My assignment has been successfully submitted and before submitting I showed it to my professor. He said this is one of your best work I have seen till now and he praised my work in class. Many of my friends were asking me how I did it. I will refer them to you once I get the best score. Hope to get best marks this time. Thanks for your efforts.

inf1601789

9/18/2017 5:28:41 AM

Hello I have made the payment through 2checkout Please confirm, thank you Please let the expert know that the simulator for MIPS is Mars please let the experts know that, every python program needs to transfer into mips program, and for any questions involved with list, the user needs to input the elements for list, list elements cannot be predefined. Thank you very much coding can vary from different microprocessor and which software u r using to execute the program. The compiler is Mars MIPS simulator. I have attached a sample program as a reference,you can modify the sample program to match the requirements in the assignment, there are 7 tasks in the assignment, so the solution should contain 7 MIPS programs. Thank you very much 24673549_1listMake.asm

len1601789

8/16/2017 1:31:05 AM

• Local variables must be stored on the runtime stack. • For all the MIPS programs you should first implement a Python version, and work out a faithful translation into MIPS. Both, the Python and MIPS code are required for your prac to be marked. However,Python solutions alone do not result in any marks, all exercises are about MIPS and MIPS solutions are required in all exercises to achieve more than 0 marks. • Use only instructions on the MIPS reference sheet and use comments to document each piece of code. • You may copy and paste your code between tasks where you need to reuse code. • Create a new file/module for each task or subtask. • Name your files task[num]_[part] to keep them organised.

Write a Review

Assembly Language Questions & Answers

  Create a assembly language subroutine

Create a assembly language subroutine MULSUM that takes an array named A containing n bytes of positive numbers, and fills two arrays, array B containing n words and array C containing n long words

  Write a function in linux assembly

Write a function in Linux assembly

  Analog measurements

Prepare an assembly program for the correctly measures the wind direction

  Design a simple digital clock

Design a simple digital clock

  Write an assembly program

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

  Write an assembly language program

Write an assembly language program for encrypting alphabates of a string

  Greatest common divisor of integers-masm assembly language

Must be done in MASM assembly language: Greatest common divisor of two integers is largest integer which will evenly divide both integers. GCD algorithm involves integer division in a loop.

  Write assembly program-find right admission price to movie

Write the Assembly program to find correct admission price to movie. Price of admission to a movie is $7 for kids (under 12) and $9 for adults.

  Create simple 8-bit alu using add-subtract-shift functions

Create a simple 8-bit ALU. Requirements:The eight functions that you will implement are: add, subtract, and, or, shift left logical, less than, shift right logical.

  Write assembly program print binary representation-integers

Write the assembly program called hw6_ex1, stored in file hw6_ex1.asm. This program must prompt user to enter signed 32-bit integer. Program must print out binary representation of the integer.

  Allot op-codes and add microcode to microprogram

Allot op-codes and add microcode to microprogram of Mic-1 to implement following instructions which are then included with IJVM instruction set.

  Write mips assembly program to read two non-negative numbers

Write MIPS assembly program to repeatedly read two non-negative integers and print integer product and quotient without using multiplication and division instructions.

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