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
Anuta_ua [19.1K]
3 years ago
10

Write a C function which mimics the behavior of the assembly language function below. Note that this time, the assembly language

code is recursive (despite –O2 compilation), and your C code should likewise be recursive.
f:
cmpl $1, %edi
je .L3
xorl %eax, %eax
testl %edi, %edi
jle .L7
subq $8, %rsp
subl $1, %edi
call f
testl %eax, %eax
sete %al
addq $8, %rsp
movzbl %al, %eax
.L7:
ret
.L3:
movl $1, %eax
ret
Computers and Technology
1 answer:
Digiron [165]3 years ago
6 0

Answer:

#include <stdio.h>

int f(int edi) {

 

  if (edi == 1) {

      return 1;  

  }

  if (edi <= 0) {

      return 0;

  }

 

  edi--;

  int eax = f(edi);

 

  if(eax == 0) {

      return 1;

  } else {

      return 0;

  }

}

int main(void) {

  int edi = 9;

  int ret;

  ret = f(edi);

  printf("%d", ret);

  return 0;

}

Explanation:

  • Inside the function f, check if edi is 1 or less than 1 and then return a number accordingly.
  • Decrement the edi variable, call the f function and assign its value to eax.
  • Check if eax is equal to 0 then return 1 else return 0.
  • Inside the main function, call the f function by passing the edi value and finally display the value of ret.
You might be interested in
Which statement is true about parity in RAM?
mihalych1998 [28]

Answer:

There needs to be an odd number of 1 bits

Explanation:

In memory, parity checking method is used to test the memory. There are two parity conditions. Either the parity is even or the parity is odd.

Odd parity means, number of 1's in eight bits of data. If the number 1's are odd  it means parity is odd. In case of the memory testing result the parity should be odd.

So, In case of Parity of RAM, the parity should be odd, if the data is stored in the RAM.

8 0
3 years ago
In chapter 11, we finally learn how the book got its title. What is the sign of the beaver? Is that what you expected when you r
Ostrovityanka [42]

Answer:

:D

Explanation:

Literally speaking, the sign of the beaver is a scratched pattern the Beaver clan uses to mark their territory. Symbolically, though, it lets other clans know not to hunt on the land it marks.

Authors help readers understand their characters in two different ways: direct characterization and indirect characterization. When an author uses words and phrases that describe a character, it's called direct characterization.

Some books use this technique more than others. Although direct characterization can be interesting if done well, most authors prefer to present their characters using indirect characterization—that is, by showing the reader what characters are like by how they act, what they think, and what other people say about them.

3 0
3 years ago
Applications require you to provide the following basic elements: social security number, experience, and favorite memories. Tru
Aleonysh [2.5K]

Answer:

False. Only Experience and sometime your social security number

Explanation:

Most job applications will require you to provide your past and current work experience. Some will ask you to provide your social security number while many of them will not. No companies will ever ask you to provide your favorite memories as a basic element in a CV or Cover Letter. It might happen on rare occasions but that would sound funny if they did.

3 0
3 years ago
What are the five generations of computer software​
Lerok [7]

Answer:

1st gen: Vacuum Tubes(1940–1956)

2nd gen: Transistors(1956–1963)

3rd gen: Integrated Circuits: (1964–1971)

4th gen: Microprocessors (1971–PRESENT)

5th gen: Artificial Intelligence (present)

Explanation:

8 0
2 years ago
Which best compares portrait and landscape orientations?
julsineya [31]
#2: Portrait taller than wide & landscape wider than tall
8 0
3 years ago
Other questions:
  • What is a taskbar?
    5·1 answer
  • 2. What's the keyboard command that will allow you to "copy" text?
    8·2 answers
  • Help! live preview in brackets is not working
    8·1 answer
  • Good afternoon guys !!!
    14·2 answers
  • J. A computer on a network that acts as the central storage location for
    5·1 answer
  • #include #include int main( ) { int value = 10; int pid; value += 5; pid = fork( ); if (pid &gt; 0 ) { value += 20; } printf(val
    10·1 answer
  • Which function of a word processing program enables you to apply a preset formatting
    5·1 answer
  • Who has gotten a random file link from someone? What file does it contain?
    8·2 answers
  • Which of these is NOT a usual result of having friends at work?
    8·1 answer
  • A good information that contains the facts necessary for decision makers to solve a problem is characterized by the __________.
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!