Computer Systems: Program... -Access
Computer Systems: Program... -Access
3rd Edition
ISBN: 9780134071923
Author: Bryant
Publisher: PEARSON
Question
Book Icon
Chapter 4, Problem 4.48HW
Program Plan Intro

Given Y86-64 code:

.pos 0

 irmovq stack, %rsp

 call main

 halt

.align 8

data:

  .quad 0x0000000000000004

  .quad 0x0000000000000003

  .quad 0x0000000000000002

data_end:

  .quad 0x0000000000000001

main:

  irmovq data,%rdi

  irmovq data_end,%rsi

  call ysBubbleP

  ret

ysBubbleP:

  jmp L2

L4:

  mrmovq 8(%rax), %r9

  mrmovq (%rax), %r10

  rrmovq %r9, %r8

  subq %r10, %r8

  jge L3

  rmmovq %r10, 8(%rax)

  rmmovq %r9, (%rax)

L3:

  irmovq $8, %r8

  addq %r8, %rax

  jmp L5

L6:

  rrmovq %rdi, %rax

L5:

  rrmovq %rsi, %r8

  subq %rax, %r8

  jg L4

  irmovq $8, %r8

  subq %r8, %rsi

L2:

  rrmovq %rsi, %r8

  subq %rdi, %r8

  jg L6

    ret

.pos 0x200

stack:

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

Blurred answer
Students have asked these similar questions
Consider the event-controlled loop in the code fragment above and the eight counter-controlled loops beneath it. Which of these counter-controlled loops will perform precisely the same operations as the event-controlled loop? This question is internally recognized as variant 221.   Q.1   fragment 1 contains the correct code   fragment 2 contains the correct code   fragment 3 contains the correct code   fragment 4 contains the correct code   fragment 5 contains the correct code   fragment 6 contains the correct code   fragment 7 contains the correct code   fragment 8 contains the correct code   none of the above
The values of x and y should be swapped. Does the following algorithm work?
Suppose the statement “X is an integer and X < 5” is a loop invariant at the point at which the test for termination is performed in the loop outlined below. What can be concluded about the value of X immediately after the loop is terminated?

Chapter 4 Solutions

Computer Systems: Program... -Access

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