Write down a not so bad cardiac simulator

Assignment Help Computer Engineering
Reference no: EM1331503

Write a not so bad CARDIAC simulator (in C++) that tells the user how to execute an instruction typed as a 3 digit number by the user.

The user should be prompted to type in a 3 digit number, and then the program should print to the screen whatever the CARDIAC Instruction Decoder box would show had that been the instruction.

* Use a pleasant switch statement for decoding the instructions based on op-codes, rather than nested if, consecutive if, or if/elseif monstrosity.

* Use a loop to allow users to provide as many instructions as they would like. Inform the users what they could type to exit the program (e.g., entering "1234" as an instruction).

* Keep track of the accumulator for the user. Use an accumulator variable for this purpose.

Assume that the accumulator contains 0 when the program starts. If the instruction modifies the accumulator (i.e., instructions 1xx, 2xx, 4xx, and 7xx), prompt the user for whatever data is necessary to execute the instruction, and execute
it ensuring that the accumulator is modified appropriately. Do not forget that the accumulator is only 3 digits long.

* Instruction 6xx should replace the word "accumulator" with the current value of the accumulator in its output to the user.

An example run of program might look like this.

Enter a 3 digit CARDIAC instruction (negative to exit): 123
Replace accumulator with cell 23
Enter the data in cell 23: 431
Enter a 3 digit CARDIAC instruction (negative to exit): 412
Shift accumulator left 1 digits, then right 2 digits
The accumulator now contains 3
Enter a 3 digit CARDIAC instruction (negative to exit): 375
Move bug to cell 75
Enter a 3 digit CARDIAC instruction (negative to exit): 250
Add the contents of cell 50 to the accumulator
Enter the data in cell 50: 99
Enter a 3 digit CARDIAC instruction (negative to exit): 348
Enter a 3 digit CARDIAC instruction (negative to exit): 630
Copy accumulator to cell 30
The accumulator now contains 96
Enter a 3 digit CARDIAC instruction (negative to exit): -1

Operation codes are as follows:

Code Abbreviation Meaning
0 INP Copy input to memory.
1 CLA Copy memory to accumulator.
2 ADD Add memory to accumulator.
3 TAC Move bug if accumulator < 0.
4 SFT Shift accumulator left then right.
5 OUT Copy memory to output.
6 STO Copy accumulator to memory.
7 SUB Subtract memory from accumulator.
8 JMP Backup bug to 99 then move bug.
9 HRS move bug and stop computing.

Reference no: EM1331503

Questions Cloud

Write down the worst cardiac simulator of all time : make the worst CARDIAC simulator of all time (in C++) that tells the user how to execute only a single instruction typed as a 3 digit number by the user.
Zero sampling risk : Besides the medical and environmental field what other testing issues do we demand 100% accuracy on (zero sampling risk)?
Explaining cross-cultural motivational leadership : Is Hofstede's cultural dimensions model an adequate and thorough paradigm for cross-cultural motivational leadership?
Explain how the below game should be set-up : Explain how the below game should be set-up, played and solved a consumer decide.
Write down a not so bad cardiac simulator : The user has to be prompted to type in a 3 digit number, and then the program should print to the screen whatever the CARDIAC Instruction Decoder box would show had that been the instruction.
Evaluating strategy : Identify the types of organizations that may need to evaluate strategy more frequently than others.
Incremental cash flows : Discuss qualitatively how you might have incorporated the likely growth of digital photography in the sales projections developed above?  (Remember hindsight is 20-20.)
How we can implement a cardiac machine simulator in c++ : Keep track of the bug location; which could be an index into the memory array. Watch out for cells 0 and 99; they are special. Read the input tape from a file that starts with a number telling you how various items are on the tape.
Explaining individualism and collectivism affectivity : Define the following relationships: Individualism v collectivism affectivity

Reviews

Write a Review

Computer Engineering Questions & Answers

  Explain the risks and benefits of virtualization

How would you recommend that your IT department prepare for disaster.

  What is time estimate

How does an estimator arrive at a time estimate for a particular task.

  What is a backup strategy or active directory?

What is a backup strategy or Active Directory? The small business that you created new domain controllers for now wants you to develop a backup and recovery plan for Active Directory.

  Routers concept

Suppose a BGPv4 router receives an update for the prefix P which indicates AS1 as the next hop (and router has never seen P before).

  Execute a shell script to read in 3 numbers

Write down and execute a shell script to read in 3 numbers and display which is the largest and which is smallest.

  Find terms of elimination of redundant data

Thinking in terms of elimination of redundant data hopefully eliminating data corruption from operator input, would it not make sense to normalize and let new Duo-Core, Quad-Core processors take-up the slack and even decrease query times.

  Developing the constants

You will require to set up the constants within your program for the following: number of square feet per square yard (9), inches per foot (12), price per square yard of saxony carpet (15.62).

  Define why a company or organization would migrate

define why a company or organization would migrate to a relational database architecture from a network or hierarchical architecture.

  How many register windows must be saved to memory

How many register windows must be saved to memory.

  What is the advantage when target is throughput and security

What is the advantage when target is throughput and securityty

  Program that creates an instance of the string class

Write down a Java application that creates an instance of the String class and initializes this instance with a String literal. Use a for loop structure to print the string in reverse order. Implement the following two String member methods to com..

  Need to re-connectd when being mobile

I want some good examples of challenges individuals and organizations face with wireless VOIP telephony. With all of the flexibility and added functionality comes a price for stability. So how does an organization handle these challenges.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd