1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Gnesinka [82]
3 years ago
5

int decode2(int x, int y, int z); is compiled into 32bit x86 assembly code. The body of the code is as follows: NOTE: x at %ebp+

8, y at %ebp+12, z at %ebp+16 movl 12(%ebp), %edx subl 16(%ebp), %edx movl %edx, %eax sall $31, %eax sarl $31, %eax imull 8(%ebp), %edx xorl %edx, %eax Parameters x, y, and z are stored at memory locations with offsets 8, 12, and 16 relative to the address in register %ebp. The code stores the return value in register %eax. The shl or sal instruction is used to shift the bits of the operand destination to the left, by the number of bits specified in the count operand Write C code for decode2 that will have an effect equivalent to our assembly Code. int decode2(int x, int y, int z) { }
Computers and Technology
1 answer:
kherson [118]3 years ago
8 0

Answer: provided in the explanation segment

Explanation:

This looks a bit confusing but you can follow through using the provided code.

/*

Line 1. x at %ebp+8, y at %ebp+12, z at %ebp+16

Line 2. movl 12(%ebp), %edx

Line 3. subl 16(%ebp), %edx

Line 4. movl %edx, %eax

Line 5. sall $31, %eax

Line 6. sarl $31, %eax

Line 7. imull 8(%ebp), %edx

Line 8. xorl %edx, %eax

*/

#include<stdio.h>

// function decode above program

int decode2(int x,int y,int z){

  // In Line 2 y is stored in variable

  int var1 = y;

 

  // In Line 3 subtract z from var1 and store in var1

  var1 = var1 - z;

  // In Line 4 move var1 value to another value count

  int count = var1;

  // In Line 5 left shift by 31 value in count

  count<<31;

  // In Line 6 right shift by 31 value in count

  count>>31;

  // In Line 7 multiply x with value in var1

  var1 = var1*x;

  // In Line 8 xor the var1 and count and store in count

  count = var1 ^ count;

  // return count;

  return count;

}

// main function for testing

int main(){

  printf("Enter the value of x ");

  int x;

  scanf("%d",&x);

  printf("Enter the value of y ");

  int y;

  scanf("%d",&y);

  printf("Enter the value of z ");

  int z;

  scanf("%d",&z);

  printf("value of decode2(%d,%d,%d) is %d\n",x,y,z,decode2(x,y,z));

  return 0;

}

cheers i hope this helps

You might be interested in
Which would increase electric current? increasing the resistance increasing the size of the wire decreasing the voltage
Neko [114]
The answer is the second answer Increasing the size of the wire.
8 0
3 years ago
Advantages and disadvantages of internet
Papessa [141]
Advantages of Internet:
1. Easy and fast access to information2. Up to date news information3. Communications made over internet connecting people around the world4. Convenience in doing like research where you can now do it at home instead of visiting libraries.
Disadvantages of Internet:
1. Possible theft of personal information2. Internet addiction which leads to social isolation3. Inappropriate Contents 
7 0
3 years ago
Read 2 more answers
Which item is essential to know before sketching a navigation menu flowchart?
alisha [4.7K]

Answer:

A, template specifics, such as horizontal or vertical menu layout

Explanation:

4 0
2 years ago
Read 2 more answers
How do I change my keyboard's debounce time?
Zanzabum

in the control board type:

HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response\BounceTime

3 0
3 years ago
Read 2 more answers
2. The part of the computer that provides access to the Internet is the A. monitor. B. keyboard. C. system unit. D. modem.
allochka39001 [22]
The modem provides access to the internet.
4 0
3 years ago
Read 2 more answers
Other questions:
  • The n modifier after the tilde forces the index variable to expand only to the ______
    15·1 answer
  • In what ways us cyberspace is real? list at least 3 examples to support your response .
    9·1 answer
  • Write a method named lastFirst that accepts a string as its parameter representing a person's first and last name. The method sh
    13·1 answer
  • Write syntactically correct Javascript code to sort an array of sub-arrays containing integers using the sort and reduce array f
    11·1 answer
  • Write a program to display the roll number of students who have scored 100 in math. display appropriate message if none have sco
    5·1 answer
  • Write an application that allows a user to input the height and width of a rectangle. It should output the area and perimeter of
    10·1 answer
  • Picking up sound over a great distance while making it seem to come from close up.
    11·1 answer
  • Which generation computer supported GUI operating system?​
    11·1 answer
  • (Just wondering and for fun) What can humanity do to survive after the universe dies? Assuming we have advanced tech and there a
    9·1 answer
  • What is the importance of test documentation?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!