assigment-2

2
Assigment - 2 Computer System Organization March 13, 2015 1 Problems Problem 1. Towers of Hanoi Given a stack of n disks arranged from largest on the bottom to smallest on top placed on a rod, together with two empty rods, the towers of Hanoi puzzle asks for the minimum number of moves required to move the stack from one rod to another, where moves are allowed only if they place smaller disks on top of larger disks. Write a RECURSIVE ARM assembly code which takes in a number n as input and output the minimum number of steps required to solve the problem. For input/output, use stdin/stdout. Example: Input - 3 Output - 7 Problem 2. Palindrome Write a RECURSIVE ARM assembly code which takes a number n as input from stdin to find given number is palindrome or not. Print ’Yes’ or ’No’ message as output on stdout. Example: Input:121 Output:Yes 2 Submission Guidelines 1. Prepare: Create two files (problem1.s and problem2.s ) and write your codes for the above problems in the corresponding files. 2. Bundle: Create a folder and rename it as your roll number. Place both the files (problem1.s and problem2.s ) into this folder and zip it. 3. Submit: Upload the zipped folder on the courses portal. 3 Other Guidelines 1. Deadline: 25 - March - 2015 1

description

History Art ScienceTheory of Everything

Transcript of assigment-2

  • Assigment - 2

    Computer System Organization

    March 13, 2015

    1 Problems

    Problem 1. Towers of HanoiGiven a stack of n disks arranged from largest on the bottom to smallest on top placed

    on a rod, together with two empty rods, the towers of Hanoi puzzle asks for the minimumnumber of moves required to move the stack from one rod to another, where moves areallowed only if they place smaller disks on top of larger disks. Write a RECURSIVE ARMassembly code which takes in a number n as input and output the minimum number of stepsrequired to solve the problem. For input/output, use stdin/stdout.

    Example:Input - 3Output - 7

    Problem 2. PalindromeWrite a RECURSIVE ARM assembly code which takes a number n as input from stdin

    to find given number is palindrome or not. Print Yes or No message as output on stdout.Example:Input:121Output:Yes

    2 Submission Guidelines

    1. Prepare: Create two files (problem1.s and problem2.s) and write your codes for theabove problems in the corresponding files.

    2. Bundle: Create a folder and rename it as your roll number. Place both the files(problem1.s and problem2.s) into this folder and zip it.

    3. Submit: Upload the zipped folder on the courses portal.

    3 Other Guidelines

    1. Deadline: 25 - March - 2015

    1

  • 2. Do NOT use any shortcut method (like formula, iterative methods, etc.) for gen-erating the output.

    3. Do NOT copy the code from any source (your friends, internet etc.). Any copy (di-rect/indirect, partial/full) case will have serious consequences.

    2