Question

In: Computer Science

Given the following program: Mailbox Contents 00 505 01 206 02 307 03 902 04 000...

Given the following program: Mailbox Contents 00 505 01 206 02 307 03 902 04 000 05 007 DAT 06 002 DAT 07 000 DAT What is the value in the calculator after the instruction in mailbox 04 is completed?

Solutions

Expert Solution

Given Program is as following:

Mailbox Content
00 505
01 206
02 307
03 902
04 000
05 007 DAT
06 002 DAT
07 000 DAT

Now step by step execution is as following:

Step 1: Program counter is at 00
Incrementing program counter
Reading mailbox 00
Instruction:505 opCode:5 Address:05
Loading calculator with data from address 05
Calculator: 007
Step 2: Program counter is at 01
Incrementing program counter
Reading mailbox 01
Instruction:206 opCode:2 Address:06
Subtracting from address 06
Subtracting 002 from claculator
Calculator: 005
Step 3: Program counter is at 02
Incrementing program counter
Reading mailbox 02
Instruction:307 opCode:3 Address:07
Storing calculator value 005 in address 07
Step 4: Program counter is at 03
Incrementing program counter
Reading mailbox 03
Instruction:902 opCode:9 Address:02
Input/Output - Address 02: output
Send calculator value to output: 005
Step 5: Program counter is at 04
Incrementing program counter
Reading mailbox 04
Instruction:000 opCode:0 Address:00
Halting

In the above steps all sequence of program execution is shown. Thus given Instruction can be concluded as following:

00 --- load data from address location 505 i.e. 05 . Data value is 007 stored in calculator.

01 --- load data from address location 206 i.e 06 and substract it from from calculator value. Thus Data value at 06 is 2. 007 - 002 = 005 stored in calculator

02 --- Stores calculator value i.e. 005 at address location 307 or 07

03 --- Sends calculator value 005 to output

04 --- Halts

Thus, calculator stores 005 after execution of instruction 04.


Related Solutions

p .00 .01 .02 .03 .04 .05 .06 .07 .08 .09 .0 .5000 .5040 .5080 .5120...
p .00 .01 .02 .03 .04 .05 .06 .07 .08 .09 .0 .5000 .5040 .5080 .5120 .5160 .5199 .5239 .5279 .5319 .5359 .1 .5398 .5438 .5478 .5517 .5557 .5596 .5636 .5675 .5714 .5753 .2 .5793 .5832 .5871 .5910 .5948 .5987 .6026 .6064 .6103 .6141 .3 .6179 .6217 .6255 .6293 .6331 .6368 .6406 .6443 .6480 .6517 .4 .6554 .6591 .6628 .6664 .6700 .6736 .6772 .6808 .6844 .6879 .5 .6915 .6950 .6985 .7019 .7054 .7088 .7123 .7157 .7190 .7224 .6 .7257 .7291...
car.txt 0001|Mercury|LeSabre|2005|Brown|11000|2019-09-01 0002|Chevrolet|Aveo|2013|Blue|12000|2019-09-02 0003|Datsun|240Z|1979|Orange|13000|2019-09-03 0004|Ford|Galaxie|1964|Black|14000|2019-09-04 0005|Porsche|Boxster|2014|Green|15000|2019-09-05 0006|Honda
car.txt 0001|Mercury|LeSabre|2005|Brown|11000|2019-09-01 0002|Chevrolet|Aveo|2013|Blue|12000|2019-09-02 0003|Datsun|240Z|1979|Orange|13000|2019-09-03 0004|Ford|Galaxie|1964|Black|14000|2019-09-04 0005|Porsche|Boxster|2014|Green|15000|2019-09-05 0006|Honda|Insight|2007|Silver|16000|2019-09-06 1) Design and implement a class of "car" with constructor and destructor, with member variable for each field, and method for get and set each field. (2) Read the file (car.txt) to instantiate each object for each record read from the file. (3) After the file input is done, then display each object to the console. Car List Record #1 (1) carID=0001 (2) carManufacturer=Mercury (3) carModel=LeSabre (4) carYear=2005 (5) carColor=Brown (6) carPrice=11000 (7)...
C++ UNIX car.txt 0001|Mercury|LeSabre|2005|Brown|11000|2019-09-01 0002|Chevrolet|Aveo|2013|Blue|12000|2019-09-02 0003|Datsun|240Z|1979|Orange|13000|2019-09-03 0004|Ford|Galaxie|1964|Black|14000|2019-09-04 0005|Porsche|Boxster|2014|Green|15000|2019-09-0 #i
C++ UNIX car.txt 0001|Mercury|LeSabre|2005|Brown|11000|2019-09-01 0002|Chevrolet|Aveo|2013|Blue|12000|2019-09-02 0003|Datsun|240Z|1979|Orange|13000|2019-09-03 0004|Ford|Galaxie|1964|Black|14000|2019-09-04 0005|Porsche|Boxster|2014|Green|15000|2019-09-0 #include <fstream> #include <iostream> #include <string> #include <sstream> using namespace std; int main() {       const int RECORDS = 42;    ifstream reader("car.txt");    if(!reader) {        cout << "Error: cannot open input file" << endl;        return -1;    }    string item[RECORDS];    int i = 0;    while(!reader.eof()) {        if((i+1) % 7 == 0)            getline(reader,item[i++],'\n');        else           ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT