Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3324288
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:24:13+00:00 2026-05-17T23:24:13+00:00

I wrote a function named absD that i want to return the absolute value

  • 0

I wrote a function named absD that i want to return the absolute value of its argument..
I am using GCC inline assembly with cygwin..

I dont see why its not working. i m loading into memory. then into st(0)
where i am using fabs – absolute value. Do i have to allocate memory?

I am trying to learn assembly with C here so please be nice. Please give me good help.
Thank you

heres the code and then the error:

#include <stdio.h>
#include <stdlib.h>
#define PRECISION   3

double absD (double n)
{


asm(
        "fldl %[nIn]\n"
        "fabs\n"
        "fstpl %[nOut]\n"
        : [nOut] "=m" (n)
        : [nIn] "m" (n)
);



return n;


}

int main (int argc, char **argv)
{
double  n = 0.0;

printf("Absolute value\n");
if (argc > 1)
    n = atof(argv[1]);

printf("abs(%.*f) = %.*f\n", PRECISION, n, PRECISION, absD(n));

return 0;
}

here is the output:

~ $ gc a3
gcc -Wall -g a3.c -o a3
~ $ ./a3
Absolute value
abs(0.000) = 0.000
~ $

Not outputing its absolute value…
Thank you..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:24:14+00:00Added an answer on May 17, 2026 at 11:24 pm

    It is completely working..!! You are just forgetting to put values to argv. You can run the program with something like this:

    ./a3 -1.3

    and it should return 1.3

    you were done before posting it here…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a javascript function that uses the innerHtml of a named div (that
I wrote this function that's supposed to do StringPadRight("Hello", 10, "0") -> "Hello00000" .
I have this Array i wrote a function MostFreq that takes an array of
I wrote a SQL function to convert a datetime value in SQL to a
I wrote a managed C++ class that has the following function: void EndPointsMappingWrapper::GetLastError(char* strErrorMessage)
I wrote a sample program at http://codepad.org/ko8vVCDF that uses a template function. How do
I am trying to write a function that will pull the name of a
Recently I wrote a function to generate certain sequences with nontrivial constraints. The problem
I wrote a while loop in a function, but don't know how to stop
I just wrote the following C++ function to programmatically determine how much RAM a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.