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

  • SEARCH
  • Home
  • 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 8610861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:13:40+00:00 2026-06-12T04:13:40+00:00

Consider following piece of C code – char sum_char(char a,char b) { char c

  • 0

Consider following piece of C code –

char sum_char(char a,char b)
{
   char c = a+b;
   return c;
}

It involves –

  1. Convert second parameter to sign extension.
  2. Push signed extension parameter on stack as b.
  3. Convert first parameter to sign extension.
  4. Push signed extension parameter on stack as a.
  5. Add a & b, result cast to char and store it in c.
  6. C is again sign extended.
  7. Sign extended c is copied to return value register and function return to caller.
  8. To store result caller function again convert int to char.

My questions are –

  1. Who does this ?
  2. What is necessity of doing so many conversions ?
  3. Will it reduce/increase the performance of machine/compiler ?
  4. If it is reducing performance what should we do in order to increase it ?
  • 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-06-12T04:13:42+00:00Added an answer on June 12, 2026 at 4:13 am
    1. Who does this? – Ultimately, it’s the CPU who does this; the compiler generates all the relevant instructions for the CPU to perform the conversions
    2. What is necessity of doing so many conversions? – The conversions are necessary to ensure consistency of the results across multiple platforms supported by multiple C compilers.
    3. Will it reduce/increase the performance of machine/compiler? – This will reduce the performance compared to “doing nothing”, but nobody will notice the difference.
    4. If it is reducing performance what should we do in order to increase it? – Nothing: if you must perform arithmetic operations on chars, then you perform arithmetic operations on chars. Let the optimizer take care of removing all unnecessary instructions for your platform. In most cases, CPU has instructions that are compatible with the semantic required by the C language, so the generated code will be very short.

    Of course if you do not need to perform operations on signed characters, you can perform operations on unsigned characters. This eliminated a good deal of sign extending.

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

Sidebar

Related Questions

Consider the following piece of code #include<iostream> #include<string> class A { private: char name[10];
Consider the following piece of code: char* str1 = new char [30]; char* str2
Consider the following piece of code - class MyThread extends Thread { private int
Consider the following piece of code: #include <stdio.h> #include <sys/types.h> #include <unistd.h> int main(void)
Consider the following piece of code: 1 typedef std::deque<int> mydeque_t; 2 mydeque_t mydeque; 3
Consider the following piece of code: int i, k, m; k = 12; m
Consider the following piece of LaTeX code: \begin{tabular}{p{1in}p{1in}} A & B\\ C & D\\
Consider the following piece of code: As you can see we are on line
Consider the following piece of code : <select> <option value=0>foo</option> <option value=1 selected=selected>bar</option> </select>
Consider the following piece of code: $tests = array( array (a, b, c), array

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.