Question: Using the LC-3 simulator, you will construct an assembly-level program to implement the program presented (in C) below. The Towers of Hanoi puzzle is described

 Using the LC-3 simulator, you will construct an assembly-level program to

implement the program presented (in C) below. The "Towers of Hanoi" puzzle

Using the LC-3 simulator, you will construct an assembly-level program to implement the program presented (in C) below. The "Towers of Hanoi" puzzle is described in more detail in Patt, Section 17.4 #include void MoveDisk (int diskNumber, int startPost, int endPost, int midPost) if (diskNumber >1) MoveDisk (diskNumber-1,startPost, midPost, endPost) printf ("Move disk %d from post %d to post %d. ", MoveDisk (diskNumber-1, midPost, endPost, startPost) printf ("M ve disk 1 from p 3t %a t post %d. ", diskNumber, startPost, endPost) lelse startPost, endPost) return; void main int n printf ("Towers of HanoinHow many disks?") scanf ("%d", &n); printf ("Instructions to move d disks from post 1 to post 3:In",n) MoveDisk (n,1,3,2); return; You must call the MoveDisk function/subroutine from your main program located in memory at address x3000 You must implement MoveDisk as a function (though it will return nothing of interest). The bottom of the software stack will be located at address x5000. You can produce the output directly or by using TRAPS such as PUTS -you do not have to implement printf as a function. For simplicity, you may assume that the number of disks ("n") is always a single digit number from 1 to 9 Example output for a 4-disk problem: --Towers of Hanoi How many disks? 3 Instructions to move 3 disks from post 1 to post 3: HInv: :t.nk 1. fr:exn1KN 1 ;( : polri; 3.. Move disk 2 from post 1 to post 2. Move disk 1 from post 3 to post 2. Move disk 3 from post 1 to post 3. Move disk 1 from post 2 to post 1. Move disk 2 from post 2 to post 3. Move disk 1 from post 1 to post 3 Using the LC-3 simulator, you will construct an assembly-level program to implement the program presented (in C) below. The "Towers of Hanoi" puzzle is described in more detail in Patt, Section 17.4 #include void MoveDisk (int diskNumber, int startPost, int endPost, int midPost) if (diskNumber >1) MoveDisk (diskNumber-1,startPost, midPost, endPost) printf ("Move disk %d from post %d to post %d. ", MoveDisk (diskNumber-1, midPost, endPost, startPost) printf ("M ve disk 1 from p 3t %a t post %d. ", diskNumber, startPost, endPost) lelse startPost, endPost) return; void main int n printf ("Towers of HanoinHow many disks?") scanf ("%d", &n); printf ("Instructions to move d disks from post 1 to post 3:In",n) MoveDisk (n,1,3,2); return; You must call the MoveDisk function/subroutine from your main program located in memory at address x3000 You must implement MoveDisk as a function (though it will return nothing of interest). The bottom of the software stack will be located at address x5000. You can produce the output directly or by using TRAPS such as PUTS -you do not have to implement printf as a function. For simplicity, you may assume that the number of disks ("n") is always a single digit number from 1 to 9 Example output for a 4-disk problem: --Towers of Hanoi How many disks? 3 Instructions to move 3 disks from post 1 to post 3: HInv: :t.nk 1. fr:exn1KN 1 ;( : polri; 3.. Move disk 2 from post 1 to post 2. Move disk 1 from post 3 to post 2. Move disk 3 from post 1 to post 3. Move disk 1 from post 2 to post 1. Move disk 2 from post 2 to post 3. Move disk 1 from post 1 to post 3

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!