Concept explainers
This problem will give you a chance to reverb engineer a switch statement from disassembled machine code. In the following procedure the body of the switch statement has been omitted:
Figure 3.53 shows the disassembled machine cods for the procedure.
The jump table resides in a different area of memory. We can see from the indirect jump on line 5 that the jump table begins at address 0×4006f8. Using the GDB debugger, we can examine the six 8-byte words of memory comprising the jump table with the command x/6gx 0×4006f8. QDB prints the following:
Fill in the body of the switch statement with C code that will have the same behavior as the machine code.
Trending nowThis is a popular solution!
Chapter 3 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
Java How To Program (Early Objects)
Starting out with Visual C# (4th Edition)
Database Concepts (7th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Digital Fundamentals (11th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
- Write code to implement the expression: A = (B + C) * (D + E) on 3-, 2-, 1- and 0-addressmachines. In accordance with programming language practice, computing theexpression should not change the values of its operands.arrow_forwardWhich Direction flag setting causes index registers to go backwards across memory when string primitives are executed?arrow_forwardWrite a 2 to 4 decoder program using Verilog and Gate level modeling.Here is the source code but can you please write a working test bench for this. And if you are using a modelsim it would be a great help if you can simulate/trigger it to see if the program is really working. Thankyou so much! module decoder( D, A, B, enable );output [0:3] D; // vector of 4 bitsinput A, B;input enable;wire Anot, Bnot, enableNot; notG1 (Anot, A), // note syntax: list of gatesG2 (Bnot, B), // separated by ,G3 (enableNot, enable);nandG4 (D[0], Anot, Bnot, enableNot ),G5 (D[1], Anot, B, enableNot ),G6 (D[2], A, Bnot, enableNot ),G7 (D[3], A, B, enableNot );endmodulearrow_forward
- Question 4: There is an application that requires the hardware: an Intel 8031, a Program ROM of 8Kx8, a Data ROM of 4Kx8 for look-up tables, TWO Data RAMs of 8Kx8. The memory map of the design should be: Program ROM should start at address 0000μ. Then, the Data ROM should come above the Program ROM. Finally the Data RAMs must go to the top of the memory map. There should be no gaps between the memory addresses of the external ROMs or RAMS. A. Using logic gates, draw the pin connections of the design. Label your diagram fully. B. Calculate the address space of the ROMs and RAMs of your design. C. Show the design's address space on a memory map, starting with 0000μ at the bottom and FFFFH at the top.arrow_forwardWrite a Verilog code with testbench for 16-bit up/down counter with synchronous reset and synchronous up/down.If up/down is set the counter is up counter and if it is not set, the counter is a down counter. Execute the module code, testbench code, and the simulation results. PLEASE EXECUTE CODE IN VERILOGarrow_forwardMIPS Simulator QtSpim: You are to have a complete program in MIPS assembly language that behaves exactly as the included C program. This program contains four functions in addition to the main() one. Your solution must contain all five C routines as they have been coded in the example. Make sure to run the program in MIPS and show the same output on MIPS as well to make sure there are no errors. Below is the five C routines and attached is the image of what the output must print out on QtSpim. #include <stdio.h> int getMax(int arr[], int n){int mx = arr[0];for (int i = 1; i < n; i++)if (arr[i] > mx)mx = arr[i];return mx;}void countSort(int arr[], int n, int exp){int output[n];int i, count[10] = { 0 };for (i = 0; i < n; i++)count[(arr[i] / exp) % 10]++;for (i = 1; i < 10; i++)count[i] += count[i - 1];for (i = n - 1; i >= 0; i--) {output[count[(arr[i] / exp) % 10] - 1] = arr[i];count[(arr[i] / exp) % 10]--;}for (i = 0; i < n; i++)arr[i] = output[i];}void…arrow_forward
- Write a program in HACK assembly, without using symbols, that computes thebitwise exclusive or (XOR) of the values stored in RAM[1] and the value of thememory location with address stored in RAM[2]. The result of the computationshould be stored in RAM[0].You can think of RAM[2] as being a pointer to where the second operand of the XORis stored.arrow_forwardQuiz 5: In this problem we want to set the control signals of the datapath shown below (also in in slide # 1 of "chapter3_single_cycle_datapaths.pptx") so that it supports execution of a new instruction called swi. Single Cycle Datapath: PC Read Instru- address ction [31-0] Instruction memory Sns Add Ins 1 [25-21] 1 [20-16] [15-11]. 1[10-0] RegWrite Read register 1 Read register 2 Write register Write data Read data 1 Read data 2 Read Ins Write 3ns Sign extend 2ns MemWrite Read Read address data Write address Read Gns Write data Write 10ns ins ALUSTO1 MemRead ALU Result 2ns ALUOP1 -XEWO) ins ALUSrc2 ALUSrc3 x=3 ins ALU Result 2ns ALUOP2 swi rd, rs, rt, imm # Memory [R[rs]]= R[rt], R[rd] =R [rs]+R [rt]+Imm #this instruction copies contents of "rt" register into the main memory addressed by the "rs" register. In the same cycle it add "rs" and "rt" register contents along with the "imm" field of the instruction and writes the final result into the "rd" register. You are NOT allowed to…arrow_forwardWrite a counting program in MIPS assembly. The program should print the first sixteen powers of 2 beginning with 20 with a space between each value. The output of the program should be exactly as follows: 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 Additional requirements for this problem: You must use a logical shift operation in your implementation. You must use a loop (i.e., a conditional branch that causes program instructions to repeat).arrow_forward
- Show the dynamics of the operandStack (i.e show a picture of the operandStack after every push operation or a pop operation) if the following algorithm is used to evaluate the postfix expression:64 2 3 ** / 10 5 * + 6 9 * -arrow_forwardfor (i=0; i<1000; i++){ y[i] = w * x[i] + b[i]; } Above C-code has a for loop which will repeat 1000 times of the operation. This code will be running on very simple machine. Change the code to reduce the number of branch instructions. You can have up to 5 lines (statements) within the for loop. What is the number of branch operations before and after?arrow_forwardIn this problem we want to modify the single cycle datapath shown below (also in in slide #1 of "chapter3_single_cycle_datapaths.pptx") so that it supports execution of a new instruction called jump register (jr). PC Add Read address Instruction [31:0) Instruction [25:21) Instruction [20:16] Instruction Instruction [15:11] memory (DMUXT RegDst Instruction [15:0] RegWrite Read register 1 Read register 2 Read data 1 Write Read register data 2 Write data Registers 16 Sign- extend Instruction [5:0] 32 Shift left 2/ ALUSrc (OMUXI) ALU Addresult Zero ALU ALU result ALU control ALUOP #copy contents of "rs" register to PC (PC = $rs) PCSrc ( E3X MemWrite Read data Address Data Write memory data MemRead MemtoReg (-MUXO) jr $rs You are allowed to add new control signal(s), wire(s), muxe(s) to support this instruction. First briefly explain the required modifications. Then indicate the value of each control signal (RegDst, RegWrite, ALUSrc, ALUOP, MemRead, Mem Write, MemToReg). You must use "X"…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education