How to insert asm code in c file. I don't want to generate asm file and not to call asm function. example : void f1(void) { ... ... nop <----- put asm code here ... } how to write in Keil C compile ?
I think on way is to implement your nop as an assembly function. Try downloading the C51 compiler mannual and chapter6 teaches you how to interface to assembly routines.
Read the sections on using the ASM and ENDASM directives in the C51 User's Guide and the Getting Started with µVision2 manual. If all you want is NOP, use _nop_ - see the Library Reference chapter in your C51 User's Guide. You can open the C51 User's Guide and Getting Started with µVision2 from the 'Books' tab in the uVision Project window. They're C51.pdf and GS51.PDF
I think on way is to implement your nop as an assembly function. That hardly gives you a "NO-Operation" does it!?
But ASM/ENDASM is used for generating asm code not obj code, right? Is there a solution to insert asm code in c file and compile to obj code ? thanks for the nop solution Is there c code to implement ADDC command ?
Keil C51 cannot generate a .obj from a source file containing inline assembler; instead, C51 generate a .src which you must then pass to the assembler (A51) to generate the .obj. That's the way Keil does it (they're not alone in choosing that method). In uVision, you need to check both the 'Generate Assembler SRC file' and the 'Assemble SRC File' options for the .c file in question (on the 'C51' tab). Is there c code to implement ADDC command? why would you want to do that!? Surely the whole point of using a HLL like 'C' is that you don't need to worry about that sort of thing? Can't you just use an int instead of a char?
Is there c code to implement ADDC command? why would you want to do that!? Surely the whole point of using a HLL like 'C' is that you don't need to worry about that sort of thing? Can't you just use an int instead of a char? Because I need to reduce code size, and some data type is 3 bytes. "using a HLL like 'C' ...." What's that mean?
If code size is really that tight, maybe you should just do the lot in assembler? But have you tried doing it all in 'C', with maximum compiler optimisations for Code Size? Rather than just try to implement ADDC in 'C', I think you'd be better to implement a 3-byte Add; you could implement it in assembler & call it from 'C'. "HLL" = High-Level Language - C, Pascal, etc; "LLL" = Low-Level Language - assembler "nGL" = nth-Generation Language