{ "key_pair_value_system": true, "answer_rating_count": "", "question_feedback_html": { "html_star": "", "html_star_feedback": "" }, "answer_average_rating_value": "", "answer_date_js": "2024-09-13T00:05:38-04:00", "answer_date": "2024-09-13 00:05:38", "is_docs_available": "", "is_excel_available": "", "is_pdf_available": "", "count_file_available": 0, "main_page": "student_question_view", "question_id": "10521975", "url": "\/study-help\/questions\/solve-this-problem-in-java-problem-overview-the-project-will-10521975", "question_creation_date_js": "2024-09-13T00:05:38-04:00", "question_creation_date": "Sep 13, 2024 12:05 AM", "meta_title": "[Solved] Solve this problem in Java Problem Overvi | SolutionInn", "meta_description": "Answer of - Solve this problem in Java Problem Overview The project will simulate a simple computer system consisting of a CPU and | SolutionInn", "meta_keywords": "solve,problem,java,overview,project,will,simulate,simple,computer,system,consisting,cpu", "question_title_h1": "Solve this problem in Java Problem Overview The project will simulate a simple computer system consisting of a CPU and Memory. The CPU and Memory", "question_title": "Solve this problem in Java Problem Overview The project will simulate a", "question_title_for_js_snippet": "Solve this problem in Java Problem Overview The project will simulate a simple computer system consisting of a CPU and Memory The CPU and Memory will be simulated by separate processes that communicate a Processor interaction with main memory b Processor instruction behavior c Role of registers d Stack processing e Procedure calls f System calls g Interrupt handling h Memory protection i I O Problem Details CPU It will have these registers PC, SP, IR, AC, X, Y It will support the instructions shown on the next page of this document It will run the user program at address 0 Instructions are fetched into the IR from memory The operand can be fetched into a local variable Each instruction should be executed before the next instruction is fetched The user stack resides at the end of user memory and grows down toward address 0 The system stack resides at the end of system memory and grows down toward address 0 There is no hardware enforcement of stack size The program ends when the End instruction is executed The 2 processes should end at that time The user program cannot access system memory (exits with error message) Memory It will consist of 2000 integer entries, 0 999 for the user program, 1000 1999 for system code It will support two operations read(address) returns the value at the address write(address, data) writes the data to the address Memory will initialize itself by reading a program file Timer A timer will interrupt the processor after every X instructions, where X is a command line parameter Interrupt processing There are two forms of interrupts the timer and a system call using the int instruction In both cases the CPU should enter kernel mode The stack pointer should be switched to the system stack SP and PC registers should be saved on the system stack (The handler may save additional registers) A timer interrupt should cause execution at address 1000 The int instruction should cause execution at address 1500 Interrupts should be disabled during interrupt processing to avoid nested execution The iret instruction returns from an interrupt Instruction set 1 Load value 2 Load addr 3 LoadInd addr 4 LoadIdxX addr 5 LoadIdxY addr 6 LoadSpX 7 Store addr 8 Get 9 Put port 10 AddX 11 AddY 12 SubX 13 SubY 14 CopyToX 15 CopyFromX 16 CopyToY 17 CopyFromY 18 CopyToSp 19 CopyFromSp 20 Jump addr 21 JumpIfEqual addr 22 JumpIfNotEqual addr 23 Call addr 24 Ret 25 IncX 26 DecX 27 Push 28 Pop 29 Int 30 IRet 50 End Load the value into the AC Load the value at the address into the AC Load the value from the address found in the given address into the AC (for example, if LoadInd 500, and 500 contains 100, then load from 100) Load the value at (address X) into the AC (for example, if LoadIdxX 500, and X contains 10, then load from 510) Load the value at (address Y) into the AC Load from (Sp X) into the AC (if SP is 990, and X is 1, load from 991) Store the value in the AC into the address Gets a random int from 1 to 100 into the AC If port 1, writes AC as an int to the screen If port 2, writes AC as a char to the screen Add the value in X to the AC Add the value in Y to the AC Subtract the value in X from the AC Subtract the value in Y from the AC Copy the value in the AC to X Copy the value in X to the AC Copy the value in the AC to Y Copy the value in Y to the AC Copy the value in AC to the SP Copy the value in SP to the AC Jump to the address Jump to the address only if the value in the AC is zero Jump to the address only if the value in the AC is not zero Push return address onto stack, jump to the address Pop return address from the stack, jump to the address Increment the value in X Decrement the value in X Push AC onto stack Pop from stack into AC Perform system call Return from system call End execution Input File Format Each instruction is on a separate line, with its operand (if any) on the following line The instruction or operand may be followed by a comment which the loader will ignore Anything following an integer is a comment, whether or not it begins with A line may be blank in which case the loader will skip it without advancing the load address A line may begin by a period followed by a number which causes the loader to change the load address Your program should run correctly with the any valid input files sample1 txt 1 Load 0 0 14 CopyToX 4 LoadIdxX 32 (load from A Z table) 32 21 JumpIfEqual 12 12 9 Put 2 (output as char) 2 25 IncX 20 Jump 3 3 1 Load 0 0 16 CopyToY 5 LoadIdxY 59 (load from 1 10 table) 59 21 JumpIfEqual 27 27 9 Put 1 (output as int) 1 1 Load 1 (because no IncY instruction) 1 11 AddY 16 CopyToY 20 Jump 15 15 1 Print newline 10 9 2 50 End 65 Data A Z 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 0 1 Data 1 10 2 3 4 5 6 7 8 9 10 0 1000 30 sample2 txt 23 line one 15 23 line two 30 23 line three 51 23 line four 86 23 line five 103 23 line six 142 23 line seven 163 50 line one 1 ld 4 4 27 push 23 call spaces 206 28 remove parm 1 ld 6 6 27 push 23 call line 178 28 remove parm 23 call newline 220 24 return line two 1 32 9 2 1 ld 47 9 2 1 ld 9 9 27 push 23 call spaces 206 28 remove parm 1 load 92 9 2 23 call newline 220 24 return line three 1 ld 47 9 output 2 1 three spaces 32 9 2 9 2 9 2 23 print eye 225 1 two spaces 32 9 2 9 2 23 print eye 225 1 two spaces 32 9 2 9 2 1 load 92 9 2 23 call newline 220 24 return line four 1 load 124 9 put 2 1 ld 11 11 27 push 23 call spaces 206 28 remove parm 1 load 124 9 put 2 23 call newline 220 24 line five 1 load 92 9 2 1 three spaces 32 9 2 9 2 9 2 1 load 92 9 2 1 ld 4 4 27 push 23 call underscore 192 28 remove parm 1 load 47 9 2 1 two spaces 32 9 2 9 2 1 load 47 9 2 23 call newline 220 24 return line six 1 32 9 2 1 ld 92 9 2 1 ld 9 9 27 push 23 call spaces 206 28 remove parm 1 load 47 9 2 23 call newline 220 24 return line seven 1 ld 4 4 27 push 23 call spaces 206 28 remove parm 1 ld 6 6 27 push 23 call line 178 28 remove parm 23 call newline 220 24 return print dash 1 ld 1 1 14 CopyToX 6 LoadSpX get parm 14 CopyToX 1 ld 45 9 output 2 26 decX 15 CopyFromX 22 JNE 183 183 24 print underscore 1 ld 1 1 14 CopyToX 6 LoadSpX get parm 14 CopyToX 1 ld 95 9 output 2 26 decX 15 CopyFromX 22 JNE 197 197 24 print space 1 ld 1 1 14 CopyToX 6 LoadSpX get parm 14 CopyToX 1 ld ' ' 32 9 output 2 26 decX 15 CopyFromX 22 JNE 211 211 24 print newline 1 10 9 2 24 print 1 ld dash 45 9 output 2 1 ld asterisk 42 9 output 2 24 return 1000 30 interrupt handler just return sample3 txt 0 1 Load 10 10 14 CopyToX 1 Load A 65 9 Output A 2 1 Load newline 10 9 Output newline 2 29 Syscall 26 DecX 15 CopyFromX 22 Jump NE Load A 3 50 1000 27 Push 15 CopyFromX 27 Push 17 CopyFromY 27 Push 2 load data 1700 14 CopyToX 25 IncX 15 CopyFromX 7 Store data 1700 28 Pop 16 CopyToY 28 Pop 14 CopyToX 28 Pop 30 IRet 1500 27 Push 15 CopyFromX 27 Push 17 CopyFromY 27 Push 2 load data 1700 9 write value 1 1 load newline 10 9 write newline 2 28 Pop 16 CopyToY 28 Pop 14 CopyToX 28 Pop 30 IRet 1700 0 data sample4 txt 19 CopyFromSp 9 Output 1 1 10 9 2 27 push 19 CopyFromSp 9 Output 1 1 10 9 2 28 pop 19 CopyFromSp 9 Output 1 1 10 9 2 29 interrupt 2 try to load from protected memory, should fail with error 1000 50 1000 30 1500 19 CopyFromSp 9 Output 1 1 10 9 2 27 push 19 CopyFromSp 9 Output 1 1 10 9 2 28 pop 19 CopyFromSp 9 Output 1 1 10 9 2 30", "question_description": "

Solve this problem in Java<\/strong><\/p>

Problem Overview<\/p>

The project will simulate a simple computer system consisting of a CPU and Memory. The CPU and Memory will be simulated by separate processes that communicate.<\/p>

a. Processor interaction with main memory. b. Processor instruction behavior. c. Role of registers. d. Stack processing. e. Procedure calls. <\/p>

f. System calls. g. Interrupt handling. h. Memory protection. i. I\/O.<\/p>

Problem Details<\/p>

CPU It will have these registers: PC, SP, IR, AC, X, Y. It will support the instructions shown on the next page of this document. It will run the user program at address 0. Instructions are fetched into the IR from memory. The operand can be fetched into a local variable. Each instruction should be executed before the next instruction is fetched. The user stack resides at the end of user memory and grows down toward address 0. The system stack resides at the end of system memory and grows down toward address 0. There is no hardware enforcement of stack size. The program ends when the End instruction is executed. The 2 processes should end at that time. The user program cannot access system memory (exits with error message). Memory It will consist of 2000 integer entries, 0-999 for the user program, 1000-1999 for system code. It will support two operations: read(address) - returns the value at the address write(address, data) - writes the data to the address Memory will initialize itself by reading a program file.<\/p>

Timer A timer will interrupt the processor after every X instructions, where X is a command-line parameter.<\/p>

Interrupt processing There are two forms of interrupts: the timer and a system call using the int instruction. In both cases the CPU should enter kernel mode. The stack pointer should be switched to the system stack. SP and PC registers should be saved on the system stack. (The handler may save additional registers). A timer interrupt should cause execution at address 1000. The int instruction should cause execution at address 1500. Interrupts should be disabled during interrupt processing to avoid nested execution. The iret instruction returns from an interrupt.<\/p>

Instruction set<\/p>

1 = Load value 2 = Load addr 3 = LoadInd addr 4 = LoadIdxX addr 5 = LoadIdxY addr 6 = LoadSpX 7 = Store addr 8 = Get 9 = Put port<\/p>

10 = AddX 11 = AddY 12 = SubX 13 = SubY 14 = CopyToX 15 = CopyFromX 16 = CopyToY 17 = CopyFromY 18 = CopyToSp 19 = CopyFromSp 20 = Jump addr 21 = JumpIfEqual addr 22 = JumpIfNotEqual addr 23 = Call addr 24 = Ret 25 = IncX 26 = DecX 27 = Push 28 = Pop 29 = Int 30 = IRet 50 = End Load the value into the AC Load the value at the address into the AC Load the value from the address found in the given address into the AC (for example, if LoadInd 500, and 500 contains 100, then load from 100). Load the value at (address+X) into the AC (for example, if LoadIdxX 500, and X contains 10, then load from 510). Load the value at (address+Y) into the AC Load from (Sp+X) into the AC (if SP is 990, and X is 1, load from 991). Store the value in the AC into the address Gets a random int from 1 to 100 into the AC If port=1, writes AC as an int to the screen If port=2, writes AC as a char to the screen Add the value in X to the AC Add the value in Y to the AC Subtract the value in X from the AC Subtract the value in Y from the AC Copy the value in the AC to X Copy the value in X to the AC Copy the value in the AC to Y Copy the value in Y to the AC Copy the value in AC to the SP Copy the value in SP to the AC Jump to the address Jump to the address only if the value in the AC is zero Jump to the address only if the value in the AC is not zero Push return address onto stack, jump to the address Pop return address from the stack, jump to the address Increment the value in X Decrement the value in X Push AC onto stack Pop from stack into AC Perform system call Return from system call End execution<\/p>

<\/p>

Input File Format<\/p>

Each instruction is on a separate line, with its operand (if any) on the following line. The instruction or operand may be followed by a comment which the loader will ignore. Anything following an integer is a comment, whether or not it begins with \/\/. A line may be blank in which case the loader will skip it without advancing the load address. A line may begin by a period followed by a number which causes the loader to change the load address. Your program should run correctly with the any valid input files.<\/p>

sample1.txt<\/p>

1 \/\/ Load 0 0 14 \/\/ CopyToX 4 \/\/ LoadIdxX 32 (load from A-Z table) 32 21 \/\/ JumpIfEqual 12 12 9 \/\/ Put 2 (output as char) 2 25 \/\/ IncX 20 \/\/ Jump 3 3 1 \/\/ Load 0 0 16 \/\/ CopyToY 5 \/\/ LoadIdxY 59 (load from 1-10 table) 59 21 \/\/ JumpIfEqual 27 27 9 \/\/ Put 1 (output as int) 1 1 \/\/ Load 1 (because no IncY instruction) 1 11 \/\/ AddY 16 \/\/ CopyToY 20 \/\/ Jump 15 15 1 \/\/ Print newline 10 9 2 50 \/\/ End 65 \/\/ Data A-Z 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 0 1 \/\/ Data 1-10 2 3 4 5 6 7 8 9 10 0<\/p>

.1000 30<\/p>

sample2.txt<\/p>

23 \/\/ line one 15 23 \/\/ line two 30 23 \/\/ line three 51 23 \/\/ line four 86 23 \/\/ line five 103 23 \/\/ line six 142 23 \/\/ line seven 163 50<\/p>

\/\/ line one 1 ld 4 4 27 push 23 call spaces 206 28 remove parm 1 ld 6 6 27 push 23 call line 178 28 remove parm 23 call newline 220 24 return<\/p>

\/\/ line two 1 32 9 2 1 ld \/ 47 9 2 1 ld 9 9 27 push 23 call spaces 206 28 remove parm 1 load \\ 92 9 2 23 call newline 220 24 return<\/p>

\/\/ line three 1 ld \/ 47 9 output 2 1 three spaces 32 9 2 9 2 9 2 23 print eye 225 1 two spaces 32 9 2 9 2 23 print eye 225 1 two spaces 32 9 2 9 2 1 load \\ 92 9 2 23 call newline 220 24 return<\/p>

\/\/ line four 1 load | 124 9 put 2 1 ld 11 11 27 push 23 call spaces 206 28 remove parm 1 load | 124 9 put 2 23 call newline 220 24<\/p>

\/\/ line five 1 load \\ 92 9 2 1 three spaces 32 9 2 9 2 9 2 1 load \\ 92 9 2 1 ld 4 4 27 push 23 call underscore 192 28 remove parm 1 load \/ 47 9 2 1 two spaces 32 9 2 9 2 1 load \/ 47 9 2 23 call newline 220 24 return<\/p>

\/\/ line six 1 32 9 2 1 ld \\ 92 9 2 1 ld 9 9 27 push 23 call spaces 206 28 remove parm 1 load \/ 47 9 2 23 call newline 220 24 return<\/p>

\/\/ line seven 1 ld 4 4 27 push 23 call spaces 206 28 remove parm 1 ld 6 6 27 push 23 call line 178 28 remove parm 23 call newline 220 24 return<\/p>

\/\/ print dash 1 ld 1 1 14 CopyToX 6 LoadSpX - get parm 14 CopyToX 1 ld - 45 9 output 2 26 decX 15 CopyFromX 22 JNE 183 183 24<\/p>

\/\/ print underscore 1 ld 1 1 14 CopyToX 6 LoadSpX - get parm 14 CopyToX 1 ld _ 95 9 output 2 26 decX 15 CopyFromX 22 JNE 197 197 24<\/p>

\/\/ print space 1 ld 1 1 14 CopyToX 6 LoadSpX - get parm 14 CopyToX 1 ld ' ' 32 9 output 2 26 decX 15 CopyFromX 22 JNE 211 211 24<\/p>

\/\/ print newline 1 10 9 2 24<\/p>

\/\/ print -* 1 ld dash 45 9 output 2 1 ld asterisk 42 9 output 2 24 return<\/p>

.1000 30 interrupt handler - just return<\/p>

sample3.txt<\/p>

.0 1 \/\/ Load 10 10 14 \/\/ CopyToX 1 \/\/ Load A 65 9 \/\/ Output A 2 1 \/\/ Load newline 10 9 \/\/ Output newline 2 29 \/\/ Syscall 26 \/\/ DecX 15 \/\/ CopyFromX 22 \/\/ Jump NE Load A 3 50<\/p>

.1000 27 \/\/ Push 15 \/\/ CopyFromX 27 \/\/ Push 17 \/\/ CopyFromY 27 \/\/ Push<\/p>

2 \/\/ load data 1700 14 \/\/ CopyToX 25 \/\/ IncX 15 \/\/ CopyFromX 7 \/\/ Store data 1700<\/p>

28 \/\/ Pop 16 \/\/ CopyToY 28 \/\/ Pop 14 \/\/ CopyToX 28 \/\/ Pop 30 \/\/ IRet<\/p>

.1500 27 \/\/ Push 15 \/\/ CopyFromX 27 \/\/ Push 17 \/\/ CopyFromY 27 \/\/ Push<\/p>

2 \/\/ load data 1700 9 \/\/ write value 1 1 \/\/ load newline 10 9 \/\/ write newline 2<\/p>

28 \/\/ Pop 16 \/\/ CopyToY 28 \/\/ Pop 14 \/\/ CopyToX 28 \/\/ Pop 30 \/\/ IRet<\/p>

.1700 0 \/\/ data<\/p>

sample4.txt<\/p>

19 \/\/ CopyFromSp 9 \/\/ Output 1 1 10 9 2 27 \/\/ push 19 \/\/ CopyFromSp 9 \/\/ Output 1 1 10 9 2 28 \/\/ pop 19 \/\/ CopyFromSp 9 \/\/ Output 1 1 10 9 2 29 \/\/ interrupt 2 \/\/ try to load from protected memory, should fail with error 1000 50 .1000 30 .1500 19 \/\/ CopyFromSp 9 \/\/ Output 1 1 10 9 2 27 \/\/ push 19 \/\/ CopyFromSp 9 \/\/ Output 1 1 10 9 2 28 \/\/ pop 19 \/\/ CopyFromSp 9 \/\/ Output 1 1 10 9 2 30<\/p>", "transcribed_text": "", "related_book": { "title": null, "isbn": null, "edition": null, "authors": null, "cover_image": null, "uri": null, "see_more_uri": "" }, "free_related_book": { "isbn": "", "uri": "", "name": "", "edition": "" }, "question_posted": "2024-09-13 00:05:38", "see_more_questions_link": "\/study-help\/questions\/computer-science-operating-system-2022-August-09", "step_by_step_answer": "The Answer is in the image, click to view ...", "students_also_viewed": [ { "url": "\/study-help\/industrial-organizational-psychology-understanding-the-workplace\/3-according-to-allport-what-particular-aspects-of-the-contact-2002870", "description": "=+3. According to Allport, what particular aspects of the contact between groups could help to reduce prejudice?", "stars": 0 }, { "url": "\/united-parcel-service-ups-provides-package-delivery-services-throughout-the", "description": "United Parcel Service (UPS) provides package delivery services throughout the United States and the world. Discuss the impact of seasonal variations in the delivery business for forecasting the firms...", "stars": 3 }, { "url": "\/study-help\/questions\/solve-this-problem-in-java-problem-overview-the-project-will-10521975", "description": "Solve this problem in Java Problem Overview The project will simulate a simple computer system consisting of a CPU and Memory. The CPU and Memory will be simulated by separate processes that...", "stars": 3 }, { "url": "\/study-help\/questions\/3-to-the-right-of-the-projects-table-camille-wants-1559427", "description": "3. To the right of the Projects table Camille wants you to summarize project information. Start by calculating the number of each project type. a . Use a function to count the number of expansion...", "stars": 3 }, { "url": "\/study-help\/questions\/question-2-2-points-saved-what-is-the-purpose-1056993", "description": "Question 2 (2 points) Saved What is the purpose of a speech that invites audience members to do something they have not done before? A) discontinuance B) adoption C) continuance D) reinforcement B", "stars": 3 }, { "url": "\/study-help\/questions\/janet-has-applied-for-coverage-under-an-assigned-risk-plan-1056904", "description": "Janet has applied for coverage under an assigned risk plan. Without knowing anything about Janet other than this fact, what can you conclude about her driving history? She may be snow", "stars": 3 }, { "url": "\/study-help\/questions\/you-must-write-a-small-application-in-java-that-can-1052933", "description": "You must write a small application in JAVA that can assist a shopper by calculating the total price of the items that he or she wants to buy and displaying a tillslip-like list of the products, their...", "stars": 3 }, { "url": "\/study-help\/questions\/is-the-pow-function-overloaded-how-do-you-know-how-1056979", "description": "Is the pow function overloaded? How do you know? How many arguments does the pow function require?", "stars": 3 }, { "url": "\/study-help\/questions\/in-microeconomics-head-ideas-incorporate-market-interest-marginalism-levelheaded-decision-1056954", "description": "In microeconomics, head ideas incorporate market interest, marginalism, levelheaded decision hypothesis, opportunity cost, spending plan limitations, utility, and the hypothesis of the firm.[85]...", "stars": 3 } ], "next_back_navigation": { "previous": "\/study-help\/questions\/which-one-is-dataops-product-category-10521974", "next": "\/study-help\/questions\/cramer-company-vendi-bonos-a-cinco-aos-al-8-10521976" }, "breadcrumbs": [ { "name": "Study help", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers" }, { "name": "Computer Science", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers\/computer-science" }, { "name": "Databases", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/computer-science-databases" }, { "name": "Solve this problem in Java Problem Overview The project will simulate a", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/solve-this-problem-in-java-problem-overview-the-project-will-10521975" } ], "skill_details": { "skill_id": "656", "skill_name": "Databases", "parent_id": "8" } } }