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: Program... -Access
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)
- In the Intel 8086 microprocessor, suppose the register AX contains the data 35AB H. What will be the contents of AX after executing the following programs? Assume that the initial content on the Carry Flag (CF) is one for all the calculations. You MUST clearly show ALL your steps in obtaining your final result for getting full and/or partial credit. Please present your final result in Hexadecimal format. (a) MOV CL,04H SHR AX,CL RET (b) MOV CL,04H RCR AX,CL RETarrow_forwardThere is an application that requires the following hardware: an Intel 8031, a Program ROM of 8Kx8, a Data ROM of 4Kx8 for look-up tables and a Data RAMs of 8Kx8. The memory map of the design: Program ROM should start at address 0000H. Then, the Data ROM should come above the Program ROM. Finally the Data RAM must go to the top of the memory map. There should be no gaps between the memory addresses of the external ROMs. Show the design’s address space on a memory map, starting with 0000H at the bottom and FFFFH at the top.arrow_forwardMust run on JsSpim online assembler and simulator: https://shawnzhong.github.io/JsSpim/ Write a counting program in MIPS assembly. The program should print the first sixteen powers of 2 beginning with 2^0 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
- Here is a small snippet of code that saves $t0 $t1 and $t2 in order to stack ie first saves t0 then t1 and finally t2 what instruction should be put in the place of x y z X sw $t0, 8($sp) Y Zarrow_forwardGadgets that pop values from the stack into a register are especially useful, as the value to be loaded in the register can be put on the stack as part of the exploit, providing control over what gets loaded into the register. Suppose there is a gadget popq %rdi; ret at address 0x0000555555555473. Your goal is to place the value 0xfeedface00000000 in register %rdi and then transfer control to a function called foo, which is at address 0x000055555557960e. The return address from the vulnerable function (i.e., the function whose buffer you will overflow with your exploit) starts exactly 48 bytes from the start of the buffer where your exploit goes. Give your exploit string in the form of input to hex2raw. (Hint: The information you need is all here; you just have to figure out in what order things should be in the exploit string. It will probably help to draw a picture.)arrow_forwardIn 32-bit mode, aside from the stack pointer(ESP), what other register points to variables on the stack? Name at least four CPU status flags. Which flag is set when the result of an unsigned arithmetic operation is too large to fit into the destination? Which flag is set when the result of a signed arithmetic operation is either too large or too small to fit into the destination? (True/False): When a register operand size is 32 bits and the REX prefix is used, the R8D register is available for programs to use. Which flag is set when an arithmetic or logical operation generates a negative result? Which part of the CPU performs floating-point arithmetic? On a 32-bit processor, how many bits are contained in each floating-point data register? (True/False):The x86-64 instruction set is backward-compatible with the x86 instruction set. (True/False): In current 64-bit chip implementations, all 64 bits are used for addressing. (True/False):The Itanium…arrow_forward
- Write an assembly code to implement the y = (x1+x2) * (x3+x4) expression on 2-address machine, and then display the value of y on the screen. Assume that the values of the variables are known. Hence, do not worry about their values in your code. The assembly instructions that are available in this machine are the following: Load b, a Load the value of a to b Add b, a Add the value of a to the value of b and place the result in b Subt b, a Subtract the value of a from the value of b and place the result in b Mult b, a Multiply the values found in a and b and place the result in b Store b, a Store the value of a in b. Output a Display the value of a on the screen Halt Stop the program Note that a or b could be either a register or a variable. Moreover, you can use the temporary registers R1 & R2 in your instructions to prevent changing the values of the variables (x1,x2,x3,x4) in the expression. In accordance…arrow_forwardFor your discussion question response, please provide a response to each of the following questions. Make sure that you include the question followed by your answer to the question in your posting. In the description of the Hack machine language in chapter 4, it is stated that in well-written programs a C-instruction that may cause a jump should not contain a reference to M, and vice versa. Discuss why this should be avoided. Research the concept of interrupts in a computer. You may want to look into how the Z80 microprocessor handles interrupt. A good source of Z80 information is Zaks, R. (1980). Programming the Z80. Sybex. Download the pdf. FYI, The Z80 8 bit microprocessor has been in production for forty years. Knowledge of the Z80 is a great lead-in for further study in more complicated machines.arrow_forwardImprove the assembly code on the next page, minimizing memory accesses as appropriate. Make sure that you properly save and restore registers as necessary. You may start from the assembler code and modify it or you may simply write assembler implementing the same C code. Include a comment about which variables are in which registersvoid simple(int a,int b, int c,int * answers){ int numNeg = 0; int numPos = 0; if (a < 0) numNeg++; else numPos++; if (b < 0) numNeg++; else numPos++; if (c < 0) numNeg++; else numPos++; answers[0] = numNeg; answers[1] = numPos;}_simple: pushq %rbp movq %rsp, %rbp subq $24, %rsp movl $0, -16(%rbp) movl $0, -12(%rbp) cmpl $0, %ecx jge L2 incl -16(%rbp) jmp L4L2: incl -12(%rbp)L4: cmpl $0, %edx jge L5 incl -16(%rbp) jmp L7L5: incl -12(%rbp)L7: cmpl $0, %r8d jge L8 incl -16(%rbp) jmp L10L8: incl -12(%rbp)L10: movl -16(%rbp), %eax movl %eax, (%r9) movq %r9, %rdx addl $4, %rdx movl -12(%rbp), %eax movl %eax, (%rdx) leave retarrow_forward
- What happens if an instruction isn't received, and it's recorded on VA page 30? Software-managed TLBs are quicker than hardware-managed TLBs in the following scenarios:arrow_forwardConsider the following MIPS loop:Loop: slt $t2, $0, $t1beq $t2, $0, Donesubi $t1, $t1, 1addi $s2, $s2, 4j LoopDone:a) Assume that the register $t1 is initialized to the value 6. What is the value in register $s2assuming $s2 is initially zero?b) For each of the loops above, write the equivalent C code routine. Assume that the register$s1, $s2, $t1, and $t2 are integers a, b, i, and temp, respectively. c) For the loops written in MIPS assembly above, assume that the register $t1 is initializedto the value 9. How many MIPS instructions are executed?arrow_forward25: . Find the time delay in the following program if the crystal frequency is 1 MHz. Do not ignore the time delay due to the first and last instruction. DELAY: LDI R16, 30 AGAIN: LDI R17, 35 HERE: NOP NOP DEC R17 BRNE HERE DEC R16 BRNE AGAIN RET 26: Write a program to display 2 on 7 segment. A 7 segment is connected to PortD.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