Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 4.1, Problem 4.7PP
Program Plan Intro
Data movement instructions:
- The different instructions are been grouped as “instruction classes”.
- The instructions in a class performs same operation but with different sizes of operand.
- The “Mov” class denotes data movement instructions that copy data from a source location to a destination.
- The class has 4 instructions that includes:
- movb:
- It copies data from a source location to a destination.
- It denotes an instruction that operates on 1 byte data size.
- movw:
- It copies data from a source location to a destination.
- It denotes an instruction that operates on 2 bytes data size.
- movl:
- It copies data from a source location to a destination.
- It denotes an instruction that operates on 4 bytes data size.
- movq:
- It copies data from a source location to a destination.
- It denotes an instruction that operates on 8 bytes data size.
- movb:
Unary and Binary Operations:
- The details of unary operations includes:
- The single operand functions as both source as well as destination.
- It can either be a memory location or a register.
- The instruction “incq” causes 8 byte element on stack top to be incremented.
- The instruction “decq” causes 8 byte element on stack top to be decremented.
- The details of binary operations includes:
- The first operand denotes the source.
- The second operand works as both source as well as destination.
- The first operand can either be an immediate value, memory location or register.
- The second operand can either be a register or a memory location.
Jump Instruction:
- The “jump” instruction causes execution to switch to an entirely new position in program.
- The “label” indicates jump destinations in assembly code.
- The “je” instruction denotes “jump if equal” or “jump if zero”.
- The comparison operation is performed.
- If result of comparison is either equal or zero, then jump operation takes place.
- The “ja” instruction denotes “jump if above”.
- The comparison operation is performed.
- If result of comparison is greater, then jump operation takes place.
- The “pop” instruction resumes execution of jump instruction.
- The “jmpq” instruction jumps to given address. It denotes a direct jump.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Sea t (k) a function that denotes the number of times that the instruction sum + = i + j will be executed in the code that follows. k is assumed to be a positive integer.
Find the exact formula for t (k). Find a simple function A (k) such that t (k) = Θ (A (k)). Justify the answer with the corresponding theorems. (Note: you are not asking what the value is end of the sum variable)
[Note: You are allowed to use only instructions implemented by the actual MIPS hardwareprovided in attached photos below. Use assembly language format from the references orthe book. Note, base ten numbers are listed as normal (e.g. 23), binary numbers areprefixed with 0b and hexadecimal numbers are prefixed with 0x.]
Write a C program and corresponding assembly program based on MIPS ISA that reads three edges for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is invalid. The input is valid if the sum of every pair of two edges is greater than the remaining edge.
[Direction: You can consult any resources such as books, online references, and videosfor this assignment, however, you have to properly cite and paraphrase your answerswhen it is necessary.] solve it any how urgently please.
In C++, the instruction is given in pic. 2nd img contains the expected output. Please explain what your code is as well so I can understand, thank you so much!
Chapter 4 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 4.1 - Prob. 4.1PPCh. 4.1 - Prob. 4.2PPCh. 4.1 - Prob. 4.3PPCh. 4.1 - Prob. 4.4PPCh. 4.1 - Prob. 4.5PPCh. 4.1 - Prob. 4.6PPCh. 4.1 - Prob. 4.7PPCh. 4.1 - Prob. 4.8PPCh. 4.2 - Practice Problem 4.9 (solution page 484) Write an...Ch. 4.2 - Prob. 4.10PP
Ch. 4.2 - Prob. 4.11PPCh. 4.2 - Prob. 4.12PPCh. 4.3 - Prob. 4.13PPCh. 4.3 - Prob. 4.14PPCh. 4.3 - Prob. 4.15PPCh. 4.3 - Prob. 4.16PPCh. 4.3 - Prob. 4.17PPCh. 4.3 - Prob. 4.18PPCh. 4.3 - Prob. 4.19PPCh. 4.3 - Prob. 4.20PPCh. 4.3 - Prob. 4.21PPCh. 4.3 - Prob. 4.22PPCh. 4.3 - Prob. 4.23PPCh. 4.3 - Prob. 4.24PPCh. 4.3 - Prob. 4.25PPCh. 4.3 - Prob. 4.26PPCh. 4.3 - Prob. 4.27PPCh. 4.4 - Prob. 4.28PPCh. 4.4 - Prob. 4.29PPCh. 4.5 - Prob. 4.30PPCh. 4.5 - Prob. 4.31PPCh. 4.5 - Prob. 4.32PPCh. 4.5 - Prob. 4.33PPCh. 4.5 - Prob. 4.34PPCh. 4.5 - Prob. 4.35PPCh. 4.5 - Prob. 4.36PPCh. 4.5 - Prob. 4.37PPCh. 4.5 - Prob. 4.38PPCh. 4.5 - Prob. 4.39PPCh. 4.5 - Prob. 4.40PPCh. 4.5 - Prob. 4.41PPCh. 4.5 - Prob. 4.42PPCh. 4.5 - Prob. 4.43PPCh. 4.5 - Prob. 4.44PPCh. 4 - Prob. 4.45HWCh. 4 - Prob. 4.46HWCh. 4 - Prob. 4.47HWCh. 4 - Prob. 4.48HWCh. 4 - Modify the code you wrote for Problem 4.47 to...Ch. 4 - In Section 3.6.8, we saw that a common way to...Ch. 4 - Prob. 4.51HWCh. 4 - The file seq-full.hcl contains the HCL description...Ch. 4 - Prob. 4.53HWCh. 4 - The file pie=full. hcl contains a copy of the PIPE...Ch. 4 - Prob. 4.55HWCh. 4 - Prob. 4.56HWCh. 4 - Prob. 4.57HWCh. 4 - Our pipelined design is a bit unrealistic in that...Ch. 4 - Prob. 4.59HW
Knowledge Booster
Similar questions
- Laboratory #1 (part 1) of programming and application of the Assembler instruction set. Exercise 1: Design a program that determines the area of a rhombus and the perimeter of a prism. Note: Explain step by step and put comments on each line of code explaining what each one does. Remember to make the code in assembler and NOT IN C.arrow_forward[2] ( Explain for each line why you chose a certain suffix such as b,w,l or q For each of the following lines of assembly language, determine the appropriate instruction suffix based on the operands. (For example, mov can be rewritten as movb, movw, movl, or movq.) mov mov τον που mov mov Zeax, (%rap) (%rax), %dx $0xFF, %bl (%rap,%rdx, 4), %d1 %rdx), %rax %dx, (%rax)arrow_forwardI. (14 points) The CPU shown below, with the same registers as the Very Simple CPU (as shown in the "CPU Design" lecture notes), has the following instruction set and state diagram. Show the RTL code for the execute cycles for each instruction. Assume that the RTL code for the fetch routine is the same as that of the Very Simple CPU. This problem will test your skill in developing RTL statements of a given CPU behavior. FETCHI FETCH2 FETCH3 IR-00 IR=01 IR=10 IR=11 JMP11 INC21 ADD11 SKIP1 JMP12 INC22 ADD12 Instruction Instruction Operation Code PC← JMP1 00AAAAAA AAAAAA+1 INC2 01XXXXXX AC AC +2 AC AC+ ADD1 10AAAAAA MAAAAAA] + 1 SKIP 11XXXXXX PC PC +1arrow_forward
- (d) You are working on a redesign of a simple 16-bit computer which supports at most 64 kilobytes of memory. Currently, memory is word-addressed and all memory accesses load or store a 16-bit value. For example, LDA Ox6502 loads a 16-bit value from address Ox6502 into register A. The change is to support additionally 8-bit accesses, thanks to an expanded machine language (already designed by a colleague) which now supports instructions such as: ; load 16 bits from addr 6502 into A ; load 8 bits from addr 6502 into A LDAW Ox6502 LDAB Ox6502 Outline, at a high level, how you would bring about this change in the CPU design, and mentioning any difficulties you expect to encounter.arrow_forward2. [4pts] Use the following C-Code for the problems below. int recFunc (int a, int b) { if (b = 0) == return a; else return 1+recFunc (a, b-1); a. Give the flowchart for the C-Code b. Convert to MIPS assembly and comment each assembly instruction to indicate corresponding C-Code.arrow_forward[2] ( Explain for each line why you chose a certain suffix such as b,w,l or q For each of the following lines of assembly language, determine the appropriate instruction suffix based on the operands. (For example, mov can be rewritten as movb, movw, movl, or movq.) mov mov mov που mov mov %oax, (%rsp) (%rax), %dx $0xFF, %bl (%rap,%rdx, 4), %d1 %rdx), %rax %dx, (%rax)arrow_forward
- Answer the given question with a proper explanation and step-by-step solution. LOOK AT THE OUTPUT. Use a loop instruction with indirect addressing to solve the problem. - Do not copy the elements to any other array. - Use the LOOP and XCHG instruction. - The input array, inputStr contains elements: “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”. - The array’s elements after running the program should look like: “G”, “H”, “E”, “F”, “C”, “D”, “A”, “B”. Screenshot of the code and memory window showing the content of the variable inputStrarrow_forwardplease do this in assembly language for x86 using c++ thank you!! I will rate you up if you do it right! Problem 6: The exclusive Sweet Potato Pie Society is planning g its annual Harvest Dinner. There will be 3 tables; one will be headed by the Society president, one by the Society treasurer, and one by the Society secretary. Mary Marchmount, president, wants to honor those members who give the most money and effort to the Society. She wants those members who give the most money in dues AND who have served as an officer in the past to sit at the head table with her. There are 15 members. On all the Society's lists of members, the member number is the place on the list, and the member numbers start at zero. So the third member on the list is member 2. One list of members shows the membership level which is in the range of 1,2,3,4 with 4 being the highest level and require the largest dues payment MemberLvl 1,3,3,4,2.4.0.1.4.2.1.4.2.2.3 Another list shows whether the member has ever…arrow_forwardIt is the compiler's job to associate program variables with registers. Take, for instance, the assignment statement from our earlier example: f = (g + h) (i+j): The variables f, g, h, i, and j are assigned to the registers X 19, X20, X21, X22, and X 23, respectively. What is the compiled LEGV8 code?arrow_forward
- a) b) Explain the following machine independent optimization techniques. Common sub expression and dead code elimination Copy propagation, constant folding. Instruction scheduling.arrow_forwardI need to write a basic code on C, That completes the following taks:arrow_forwardsolve using assembly language x86 processors and compatibles Write a program that prompts the user for the radius of a circle. Calculate and display the circle'sarea. Use the ReadFloat and WriteFloat procedures from the Irvine32 library. Use the FLDPIinstruction to load pi (7) onto the register stack. Also, draw out the floating point stack after eachfloat instruction used.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education