different execution time or the same with different options? [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
If i compile a C program with different options like '-o, -o2, -o3' Will there be any difference in the execution time or memory utilization?.

Maybe.
Depends. You're telling the compiler to spend a bit of additional time into looking for places where it could probably optimize the code from the standard approach. It might find such places, but it also might not. On all but the most trivial programs, there is, however, quite a high probability the compiler will be able to optimize ("Hello World" doesn't optimize very well, though...).

Related

How to implement the printf function in risc-v? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Here's the C representation of what I'm trying to do in RISC-V assembly:
printf ("x=%d\n", x);
https://godbolt.org/ is an interesting site. If you paste in c code, it can be transfered into others, such as RISC-V assembly. The sample c code is available from menie.org/georges/embedded/small_printf_source_code.html. It does work. Good luck.
Here is a very simple printf (actually only integers and strings and no advanced formatting)
https://godbolt.org/z/sgMVs7
It is not my code - it is tiny ptinf from the atolic studio. But it is a good base to implement something simple but more decent.

Can Endianess of system be changed using c code [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I know that endianess little or big is inherent to the system. Then, how is it possible to change using c code, as I have seen a code, which says it can change the endianess.
Endianess depends on the CPU hardware. So normally you can't do anything about it.
The code you have seen was most likely just tossing bytes around from one endianess to the other. Though some CPUs (for example some PowerPC) do have the possibility to configure endianess by writes to a hardware register.
You can't change the endianness of the system in general (there are bi-endian architectures), this would require you to change the instruction set. You can change the endianness of the data you use though. Take a look at this question to see how.

Does comment style affect binary size? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am getting started to the embedded system's world. During this journey I came across to a "different" way to comment functions:
ISR(INT0_vect) { /* Run every time there is a change on button*/
I particularly prefer something like:
// Run every time there is a change on button
ISR(INT0_vect) {
Is it just a "taste thing" or by commenting like that I can "save" some EEPROM space in my ATMEGA168A?
The style of comments is purely an aesthetic concern. Compilers disregard all comments in your code when generating an object file, so how you format comments will have no bearing on EEPROM space.

Fastest C conditions execution [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Today I stumbled upon one simple part of code and I would like to know more people opinion.
What would be the fastest code to evaluate this graph
There is no such thing as the fastest code to evaluate this graph. It depends on the processor architecture. What can be faster on one architecture, will be slower on another, or not even possible.
Nowadays, the compilers excel at block optimizations, and you should write the code as natural as you can and let the compiler decide what "the fastest" means. If the compiler doesn't have an optimization option, the best way to handle this type of conditions is to use 'conditional move' instructions, because they do not stall the pipeline, but this is very much specific to certain architectures.

A byte has 8-bits. Can it be larger in another system? give an example [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
A byte has 8-bits. Can it be larger in another system? Give an example.
Also, how many different types of calls such as writeint,writedec,writestring,writechar are there in assembly language.
Thanks.
Not any more. There was a time, yes, when there were systems without a fundamental 8-bit byte.
System where 1 byte != 8 bit?
how many different types of call such as writeint,writedec,writestring,writechar are there in assembly language
This question makes no sense. Assembly language is just a means of writing code that translates directly to machine instructions. call is just one of these instructions - it jumps to some other section of code, with the intent of returning to the place where the call was made.
The things you're referring to sound more like library routines - in which case there are any number of them, depending on the programming environment.

Resources