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
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
Going missing Some calculations involving blank values may give different results to what you might expect. For example, when you pass a blank value into the AND() function, it is treated as TRUE. This is often unhelpful. To make blanks behave in a sensible way in calculations, you must first convert them to be "not available" using NA(). This function takes no inputs, and returns a missing value. To convert a blank value to a missing value, use this pattern. =IF(ISBLANK(cell), NA(), cell) Instruction In column H, use AND() to find women who have kids and get benefits. In column I, convert the blanks in column G to missing values. In column J, again find women who have kids and get benefits, this time using column I rather than G. please show the formula used to "has kids and gets benefits" , "gets benefits with missing values", has kids and gets benefits". Thank you  Is non-white Has over 12 years of school? Is married? Has kids? Has young kids? Is head of household? Gets…
Modify the below program that the input values representingfractions are stored with denominators that are positive integers. You cannot require the user to only enter a positive denominator value; the user should not be inconvenienced by such a restriction. For example, whilst values of 1 / -2 are acceptable inputs for a fraction, the output representation should be -1 / 2. Your solution should check the denominator input; if it is negative, swap the sign of both numerator and denominator instance variables.    //Import the essential package import java.util.ArrayList; import java.util.Scanner; //Define the class Fraction class Fraction {         private int n, d;       public Fraction()     {         //Initialize the values         this.n = this.d = 0;     }     public Fraction(int n, int d)     {         //Initialize the variables         this.n = n;         this.d = d;     }     //Define the getter function getNum() that returns the numerator     public int getNum()     {…
Experiment 1: IMPLEMENTATION OF CAESAR CIPHER Objective: To implement the simple substitution technique named Caesar cipher using C+ language. Theory: To enerypt a message with a Caesar cipher, each letter in the message is changed using a simple rule: shift by three. Each letter of the message is shifted a fixed distance (3 for example) down the alphabet, A becomes D, B becomes E, and so on. For the last letters, we can think of alphabet as a circle and "wrap around", W becomes Z. X becomes A, Y becomes B, and Z becomes C. To change a message back, cach letter is replaced by the one three before it. Example ABCDEFGHIJKLMNOPQRSTUVWXYZ t t t t t t t t ttt t t t t t t tt t t t t t t ft DEFGHIJKLMNOPQRSTUVW XY Z ABc) digorithm STEP-1: Read the plain text from the user. STEP-2: Read the key value from the user. STEP-3: If the key is positive then encrypt the text by adding the key with each character in the plain text. STEP-4: Else subtract the key from the plain text. STEP-5: Display the…

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
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning