0% found this document useful (0 votes)
7 views

Tut3 assemblyLangProgramming

The document discusses three MIPS assembly language programming problems: 1) A program to read an integer, count the number of ones in its binary representation, store the count in a variable, and print the result. 2) A program to read an array of integers, sum them, find the minimum and maximum using a function, and print the results. 3) A program to read two integers n and r, compute nCr recursively using a given formula, and print the original values and result.

Uploaded by

battiman
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Tut3 assemblyLangProgramming

The document discusses three MIPS assembly language programming problems: 1) A program to read an integer, count the number of ones in its binary representation, store the count in a variable, and print the result. 2) A program to read an array of integers, sum them, find the minimum and maximum using a function, and print the results. 3) A program to read two integers n and r, compute nCr recursively using a given formula, and print the original values and result.

Uploaded by

battiman
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1 Tutorial 3 Assembly Language Programming 1. (a) Write a MIPS assembly language program which is to i. ii. iii. iv.

. read an integer in a local variable inp through the prompt: Feed an integer:, nd the number of ones in its internal representation by a function store the count (returned by the function) in a local variable count1 and print the following text : The number of ones in the internal representation of ... is ....

(b) Write the corresponding C main function and the function subprogram for ease of understanding or adequate comments in the assembly language program; in the latter case, identify the mapping of the local variables with their address expressions. Note that local variables must be allocated on the stack. Allocation is by providing for the required number of bytes on the stack (by decreasing the stack pointer value, if the stack grows towards the lower memory). Access is with respect to the frame base pointer. Space allocated on the stack must be released (by increasing the stack pointer) before returning from the function. 2. Write a MIPS program which (a) reads a set of ten integers into a local array and (b) computes their sum, the minimum element and the maximum element by means of a function, (c) prints the array elements and these values (returned by the function) with proper prompt message(s). Ensure readability of the program by either writing a coresponding C program or putting meaningful comments as indicated in the previous problem. 3. Write a MIPS assembly langauage program which (a) reads two integers n and r in two local variables, (b) computes n Cr using a recursive function which uses the following formula n Cr =n Cr1 +n1 C r1 , (c) prints the original values of n and r and the returned value n Cr using proper prompt. Ensure readability as before.

You might also like