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

  Cpp file of the program

Student must submit each lab assignment along with two files: a working .cpp file of the program design and a screenshot of its program execution output in Word format.

  Dns servers and dhcp servers

Assume that both the DNS servers and the DHCP servers send your client PC and IP addresses. Write down the differences between these two addresses.

  Tcp and udp

UDP and TCP utilize the 1s complement for their checksums. Assume you have the following three 8-bit bytes: 01010101, 01110000, 01001100. Along with the 1s complement schema, how does receiver detect the errors?

  Display all 52 cards in a standard deck of playing cards

Display all 52 cards in a standard deck of playing cards

  Decreasing risk of malicious attacks

While a large percentage of the information technology security budgets is devoted to decreasing the risk of malicious attacks, there exist other ways in which systems or data become damaged.

  Wordpad application

Whenever you select the print from WordPad application. Which printer among the three starts to print? Why? Explain is it possible to state which printer to print from the WordPad or any other application? Explain why?

  Developing the class square

Write down the class definition of the subclass of Square known as Fancy Square which has a method known as getDiagonal.

  Contrast abstract classes and interfaces

evaluate and contrast abstract classes and interfaces

  Estimatedrtt in terms of four sample rtts

For a provided TCP connection, assume four acknowledgments have been returned with corresponding sample RTTs SampleRTT4, SampleRTT3, SampleRTT2, and SampleRTT1. Express EstimatedRTT in terms of four sample RTTs.

  Economic life of technology product

Explain what do you understand by the economic life of a technology product. Discuss how does economic life of the technology product is compared with the technology life and product life?

  Program that reads letters from a file called"inputlet.txt"

This program must open an inputLet.txt file , read in one character at a time and repeat this for the number of games the user wants to play.

  Multiplexer and decoder

A bus organized the CPU has 32 registers with 16 bits in each, an ALU and a destination decoder. Specify how many multiplexers are there within the bus, and specify the size of each multiplexer?

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