Question: THIS IS A ASSEMBLY LANGUAGE ASSIGNMENT PLS DO IT ACCORDINGLY Following components should be submitted in zipped format on Moodle. Code files Report should carry

THIS IS A ASSEMBLY LANGUAGE ASSIGNMENT PLS DO IT ACCORDINGLY

Following components should be submitted in zipped format on Moodle.

  • Code files

  • Report should carry

    o An introduction to the concepts that you have applied in the program.

    o Your algorithm in simple English.

    o Code

    o Output of the program. Specifically use different inputs to your program showing how your program behaves / handles invalid inputs (if cater for in the program)

    Task-1 [30 Marks]

    In this task you are supposed to write a code in MIPS assembly language that should prompt user to enter two numbers and then it should add these and display the result in an appropriate format.

    The format that you need to follow for the program is given below in the form of a skeleton code. You MUST follow the format. Note that you MUST not add any additional function/subroutine in your program. You need to use the skeleton code provided and complete the functionality by adding your logic. Make sure you must provide the information on top of each code file as given in the skeleton code:

    ########################## #Name: #Roll Number: #Name of program: a1-t1.asm #Course Code:

    #Section: ######################## .data #your data segment goes here

.text main:

#ask user to enter first number jal displayPrompt #get first number jal getNumber

#ask user to enter second number jal displayPrompt #get second number jal getNumber

#process the numbers (add in this case) jal processNumbers #display the result jal displayResult

#to avoid infinite loop, and to gracefully terminate the program li $v0,10 syscall

#subroutines go here displayPrompt: 
getNumber: processNumbers: displayResult: 

Sample Run

Text in bold font shows the user response in the first two lines and third line is the output of the program. Enter first number: 2 Enter second number: 3 2+3=5

#Section: ######################## .data #your .text main:

#we need to add five integers #first create appropriate space on stack

#ask user to enter first number jal displayPrompt

#get first number jal getNumber

#ask user to enter second number jal displayPrompt

data segment goes here

Task-2 [35 Marks]

In this task you are supposed to

  • Get five numbers from user.

  • Add these numbers.

  • Display the result as shown in the sample run.

    While coding, adhere to the following instructions:

  • DO NOT use $v1

  • DO not use $a1, $a2, $a3

  • You can use $v0, $a0, and $ra as per your logic.

  • Can only use $t1 -- $t5 as temporary registers. No other register should be used in your program.

  • MUST NOT use temporary registers to pass input arguments to your functions, nor should these be used to return values from the functions.

  • Use stack memory to pass and return values to and from the functions.

    ########################## #Name: #Roll Number: #Name of program: a1-t2.asm #Course Code:

#get second number jal getNumber

#ask user to enter third number jal displayPrompt

#get third number jal getNumber

#ask user to enter fourth number jal displayPrompt

#get fourth number jal getNumber

#ask user to enter fifth number jal displayPrompt

#get fifth number jal getNumber #let us call processNumbers function jal processNumbers

#let us call displayResult function jal displayResult

#to avoid infinite loop, and to gracefully terminate the program li $v0,10 syscall

#subroutines displayPrompt: 
getNumber: processNumbers: 
displayResult: 

Sample Run Enter first number: 1 Enter second number: 3 Enter third number: 5 Enter fourth number: 7 Enter fifth number: 9 1 + 3 + 5 + 7 + 9 = 25

Task-3 [35 Marks]

In this task we will write a program in MIPS assembly language that should do the following functionality:

  • Prompt the user to enter a number. It should be a number between 1 and 16. Your program should check the validity of user input and should terminate the program if an invalid number is entered after displaying an appropriate message.

  • Prompt the user again for a number. This time the number should be in the range of 5 to 10. Your program should again check the validity of the input and terminate the program in case of an invalid input.

  • Based on the input provided by the user your program should then display an arithmetic table on the console.

  • A sample run of the program is shown below. The values in bold face represent the user response.

    The skeleton code is shown below. Make sure that your program MUST use the same functions. No additional function is allowed. You can use either the conventional registers or stack memory for input arguments / return address.

    ########################## #Name: #Roll Number: #Name of program: a1-t3.asm #Course Code:

#Section: ######################## .data #your .text main:

#prompt the user to enter table number jal inputNumber

data segment goes here

#prompt the user to enter range of table (Note that same function is #used)

jal inputNumber #display table jal displayTable li $v0,10 syscall

inputNumber: 
displayTable: 

######END OF PROGRAM########

Sample Run Enter table number: 4 Enter range of table: 5 The table is shown below: 4x1=4 4x2=8 4 x 3 = 12 4 x 4 = 16 4 x 5 = 20

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!