How to implement the printf function in risc-v? [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 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.

Related

Does Memory allocation in C is a machine dependent? [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 1 year ago.
Improve this question
Does Memory allocation in C is a machine dependent?
I want my program to be transferred from a UNIX system to another system without any problem.
As #mediocrevegetable1 said in the comments, as long as you use functions from the standard library, it should work. (But just make sure that you used an ANSI C compiler before, and to use an ANSI C compiler when compiling for another system. You can see Here a list of ANSI C compilers.)

including "vartype" library to the beginning of the C program [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 5 years ago.
Improve this question
I want to have some information about (#include)
in the beginning of my C program.
What does this library do?I have search before and found nothing.....
#include is a preprocessor directive, not a library. You can read below Wikipedia page about it.
https://en.wikipedia.org/wiki/Include_directive

Can any program of C be written in R programming language? [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 want to know whether any program which is written using C programming language can be written using R programming language or not. I know that it is possible to call C code from R, but I want to know if I want to write every algorithm in R from scratch whether it is possible or not.
I want to know does R has all constructs required to implement all programs written in C lanuage?
Yes, both are Turing complete.

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.

C: recognize variable type [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 7 years ago.
Improve this question
I'm learning C. I wonder whether there is an instruction or command to recognize the type of the variable.
To be more practical: I have a program which works with integers, I want to show an error message if the user inserts a real number when running the program.
Hope you can help!
This is not part of the C standard, but GCC has the typeof keyword.
You have to be using the GCC compiler for it though.

Resources