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

What C51 needs really bad is ...

Inline assembly!

asm {
;you assembly code goes here.
}

My version is so out of date, tho, it may already support it and I don't even know.

Parents
  • Can you say that this 2 ways always produce the same .OBJ:
    1) .C --> .OBJ
    2) .C --> .SRC --> .OBJ
    in case of no using any #pragma asm/endasm ?


    1 != 2.

    There are several reasons why.

    1. When you compile a C file and generate an OBJ file, the compiler injects debug information into the OBJ file. Things like line number-address offsets are included. When you compile a file with SRC and then assemble the SRC file, the object file has debug information from the assembler, and the line numbers refer to the SRC file (not the C file).

    2. When you compile a C file and generate an OBJ file, the C compiler includes references to the standard C library files (C51S, C51C, or C51L). When you create a SRC file, these references are not included. So, if you have a 1-file project that is compiled as a SRC file, you'll have to include the C libraries manually.

    3. When you create a SRC file, most optimizations are disabled to about side-effects that interfere with your in-line assembly. Additionally, the compiler attempts to color registers and doesn't "know" about the in-line code that you enter. That text is passed verbatim to the SRC file for assembly by the assembler. Ergo, the compiler can't make rational decisions about the in-line code you have.

    Jon


Reply
  • Can you say that this 2 ways always produce the same .OBJ:
    1) .C --> .OBJ
    2) .C --> .SRC --> .OBJ
    in case of no using any #pragma asm/endasm ?


    1 != 2.

    There are several reasons why.

    1. When you compile a C file and generate an OBJ file, the compiler injects debug information into the OBJ file. Things like line number-address offsets are included. When you compile a file with SRC and then assemble the SRC file, the object file has debug information from the assembler, and the line numbers refer to the SRC file (not the C file).

    2. When you compile a C file and generate an OBJ file, the C compiler includes references to the standard C library files (C51S, C51C, or C51L). When you create a SRC file, these references are not included. So, if you have a 1-file project that is compiled as a SRC file, you'll have to include the C libraries manually.

    3. When you create a SRC file, most optimizations are disabled to about side-effects that interfere with your in-line assembly. Additionally, the compiler attempts to color registers and doesn't "know" about the in-line code that you enter. That text is passed verbatim to the SRC file for assembly by the assembler. Ergo, the compiler can't make rational decisions about the in-line code you have.

    Jon


Children
No data