This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

i'm a beginner i need program which multiply 2 real inputs

hi, i'm a beginner i need program which multiply 2 real inputs , i want to know: how can i declare real variables on C ,also i can't deal with 8-bit registers R0--R7.
in ASM language Mov R0,#10
i need to convert this code to C
thnx;

  • I DONT WANY TO BE ABRASIVE, BUT YOURE USING A LOT OF CODE FOR THE JOB.......
    NEVER MIND IF ITS LEDS OR LCDS. WITH LESS OUTPUT HEX-CODE YOU COULD DRIVE THE OUTPUT WITH A UART TO COMUNICATE WITH RS482 TO THE PC.
    I REPEAT MY FORMER GENERIC CODE (BASIC,C,FORTRAN,FORTH,COBOL,LIST,ORCAD,ASM,PASCAL,DELPHY OR WHATEVER):

  • Mahmoud,
    Look, forgive me for saying this, but it sounds as if you have opened a text book (which is a good thing) and quoted from it without understanding what it all means, so you might need to learn C first. Either way, if you do this:

    int res, x = 4, y = 2 ;
    
    res = x * y ;
    

    you have multiplied 2 numbers.

    If I were you, I would'nt try to "deal" with assembly until you manage to understand (and master) the basics.
    Good luck.

  • i need to convert this code to C

    No. You need to stop thinking in assembly language, and start to actually learn C. "Converting" assembly code patterns is no way to write C programs.

  • i know what u say;i mean x=4.569;y=5.369;
    res=x*y;
    if i wrote:
    double res;
    an error appear.
    in the beginning of program i wrote
    #include<reg52.h>
    i want to know which header file is used to declare
    double i/p & o/p
    also math. functions as sin(x) ,..etc

  • ok; i want to use register but i haven't code to write
    i need to store data in these register
    if u know send me

  • So, what would be a good way to find out in which file sin(x) is declared?

    - Searching through the header files in the Keil directory?
    - Checking the manual?
    - Asking on a forum?

    What do you expect would happen if everybody who had a question always selected the "Asking on a forum" solution? Do you think anyone would get anything done then? You could have found the answer yourself several hours ago.

    an error appear.

    I don't know if this should be taken as a question. If it was, don't you think it would be better to specify exactly what error you received?

    Note that embedded processors doesn't like floating point so very much. Most embedded processors does not have hardware support for floating point, so they have to emulate it - just as if you have to manage with a pen and paper instead of having a pocket calculator.

    i need to store data in these register
    Don't write "I need to...". Write why you need to... If you don't write any motivation, we will not feel motivated to answer - and we will be unable to know if you are un the right track or not. Most people wo "need to" on this forum are basing their questions on an incorrect assumption.

  • i need to store data in these register

    No, you quite certainly don't. R0 to R8 are no place to store something. Not in the middle of C code, anyway, because the compiled code needs those registers for itself.

    You need to stop running head-first into the wall and go back to the chapter "What's a door, and why might I find it useful?"

  • "an error appear."
    What does it say? keil for the 8051 does not support double use float. And if you have the Evaluation Version Look at the limitations.

  • i study programming micro using c well;
    but if i declare any i/p as double or float
    error: file or path not found
    file C:\keil\c52\lib\c51fbs.lib
    #include<reg52.h> if i write
    int a; ok
    but double a; or float a;
    error appear
    plz give me the start

  • vvv the answer is entered before your question vvv