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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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