Computer Systems: A Programmer's Perspective (3rd Edition)
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
Expert Solution & Answer
Book Icon
Chapter 4.1, Problem 4.6PP

Explanation of Solution

Given assembly code:

long sum(long *start, long count)

start in %rdi, count in %rsi

sum:

irmovq $8, %r8

irmovq $1, %r9

xorq %rax, %rax     

andq %rsi, %rsi

jmp test

loop:

mrmovq (%rdi),%r10

addq %r10, %rax

addq %r8, %rdi

subq %r9, %rsi

test:

jne loop

ret

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.

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...

Blurred answer
Students have asked these similar questions
2. [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.
(e) Instruction(s) to copy contents at one memory location to another: C[g] =A[i+j-3). Assume i, j,g values are in registers x5, x6, x7. Assume base address in memory of Array data structures 'A, B' (or address in memory of 'A[O]' and 'B[O]') are stored in Registers x28, 29• In RISCV, only load and store instructions access memory locations • These instructions must follow a 'format' to access memory • Assume a 32 bit machine in all problems unless asked to assume otherwise
[1] ( Show your work. Show hoe you compute memory address by using the effective memory address computation. Assume the following values are stored at the indicated memory addresses and registers: Address Value 0x100 OxFF 0x104 OxAB 0x108 0x13 0x10c 0x11 Register %rax %rcx %rdx $0x108 (%rax) 4(%rax) 9(%rax, %rdx) 260(%rcx,%rdx) OxFC (,%rcx, 4) (%rax, %rdx, 4) Value 0x100 0x1 0x3 Fill in the following table showing the values for the indicated operands: Operand Value %rax 0x104

Chapter 4 Solutions

Computer Systems: A Programmer's Perspective (3rd Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education