CS计算机代考程序代写 assembly c++ HW4 (90 points total) (Exercises 40 Problems 50)

HW4 (90 points total) (Exercises 40 Problems 50)
CSC 376 Computer Organization and Architecture

Exercises (Twenty 2-point Questions on HW4 Exercise Quiz)
5.03
5.04
5.05
5.06
5.07
5.08
5.09
5.11
5.12
5.14
5.16

Problems

• Start Early. You have two weeks.
• Review presentation on Using Pep8 Trace Tags.
• Work each of these programs in steps.
• Get one part working before trying to add all the requirements.
• If you feel you cannot complete it, submit what you have that works
• Please post questions and respond to the DB HW4 posts.

Problem 1: (8 points) Run the mystery program from Fig 6.16 with the values supplied in the help solution of Pep8 and one of your own
• Show 2 screenshots with different inputs. Include the Batch I/O panel.

• State in one sentence, what does this program does?

• Modify the program to make the output clearer – Describe – Do not paste the code. Show the same 2 screenshots with the modification.

• Is this spaghetti code or structured code? What would make the code easier to modify?

Problem 2: (14 points) Translate the program below into PEP/8 assembly language
• Start with Assembly code for Fig 6.36 (Use Pep8 help)
• Change to output array in same order as input
• Add function twoVect
• Pass array as parameter as shown in Fig 6.38
• Use trace tags on all variables.

#include using namespace std;

void twoVect(int v[], int n){
int k;
for(k = 0; k < n; k++){ v[k] = v[k] * 2; } } int main () { int vector[4]; int j; for (j=0; j<4; j++){ cin >> vector[j];
}
twoVect(vector, 4); for (j=0; j<4; j++){ cout << j << ' ' << vector[j] << endl; } return 0; } • Comment lines of the source code to trace the C++ code. Cut & paste the Source Code Listing into your assignment document. • Run for a set of 4 inputs and paste a screen shot of the Output area of PEP/8. • Step thru & Cut and paste the memory trace when in the twoVect function. Problem 3: (14 points) Translate the program below into PEP/8 assembly language /****************************************************************************** C++ Code HW4 Problem 3 *******************************************************************************/ #include
using namespace std;
int main ()
{
int finish;
cout << "Enter your score: 1, 2, 3, 4, or 5" << endl; cin >> finish;
switch (finish)
{
case 1:
cout << "You win!" << endl; break; case 2: cout << "You place!" << endl; break; case 3: cout << "You show!" << endl; break; case 4: cout << "You didn't even show" << endl; break; default: cout << "You weren't even competing" << endl; } cout << endl; return 0; } • Use a jump table to implement the switch statement. • Use trace tags on all variables. • For invalid scores, output should be the same as the C++ program. • Add something to the output that makes this program uniquely yours. • The variable finish needs to be local. • This is similar to Fig 6.40. • Comment lines of the source code to trace the C++ code. Cut & paste the Source Code Listing into your assignment document. • Run for each score and paste a screenshot of each of the PEP/8 Output Area. • Step thru & Cut and paste the memory trace at any point. Problem 4: (14 points) Write a C++ program that inputs a lower-case character, and converts it according the following: char uppercase (char ch) {if ((ch >=
‘a’) && (ch <= 'z')) {return ch - 'a' + 'A'; } else { return ch; } } • A character that is not a letter should be returned as is • A lower case character is converted to an upper case character using the function below. It also increments it to the next character (b is changed to C, z is changed to A, etc.) • Character variables will need character trace tags. • Hint: characters only use one byte of storage and should be manipulated with byte instructions. • Add something to the output that makes this program uniquely yours. • Then translate it to Assembly language. • Paste a link to your C++ Source Code • Comment lines of the source code to trace the C++ code. Cut & paste the Assembly Source Code Listing into your assignment document. • Run for 4 inputs: one uppercase, one lowercase, one non-letter, and one for capital Z. Paste a screenshot of each in the Output area of the PEP/8. • Step thru & Cut and paste the memory trace at a point when in uppercase subroutine.