-->
How can i get inline assembly to work in dev-cpp in can get it to work in msvcpp but not in dev-cpp. Any help would be greatly appreciated. Inline Assembly/Examples. From OSDev Wiki. Jump to: navigation, search. What follows is a collection of Inline Assembly functions so common that they should be useful to most OS developers using GCC. Other compilers may have intrinsic alternatives (see references).
Jan 29, 2010 I know that DevC allow us to write Assembly. Can anyone explain little bit that how we can compile assembly via DevC IDE. DevC is an IDE designed for C/C, hence its name. That said I'm going to assume you mean inline assembly. Next time, please state the compiler your using. I'll assume GCC. See Inline Assembly On GCC using Intel Syntax. For some reason I have been unable to use the inline assembler in Dev-C/C ver 5.11. For testing purposes I injected this simple line of asm for the fun of it.
Microsoft Specific
If you write a function with inline assembly code, it's easy to pass arguments to the function and return a value from it. The following examples compare a function first written for a separate assembler and then rewritten for the inline assembler. The function, called
power2
, receives two parameters, multiplying the first parameter by 2 to the power of the second parameter. Written for a separate assembler, the function might look like this:Since it's written for a separate assembler, the function requires a separate source file and assembly and link steps. C and C++ function arguments are usually passed on the stack, so this version of the
power2
function accesses its arguments by their positions on the stack. (Note that the MODEL directive, available in MASM and some other assemblers, also allows you to access stack arguments and local stack variables by name.)Example
This program writes the
power2
function with inline assembly code:The inline version of the
power2
function refers to its arguments by name and appears in the same source file as the rest of the program. This version also requires fewer assembly instructions.Because the inline version of
power2
doesn't execute a C return
statement, it causes a harmless warning if you compile at warning level 2 or higher. The function does return a value, but the compiler cannot tell that in the absence of a return
statement. You can use #pragma warning to disable the generation of this warning.END Microsoft Specific
See also
Using C or C++ in __asm Blocks
Technical Support
Support Resources
- Support Knowledgebase
Product Information
- Software & Hardware Products
Information in this article applies to:
- C51 All Versions
QUESTION
Dev C++ Inline Asm Example 2
How do I implement inline assembly in C51 using the ASM and ENDASM directives. I have read some of the knowledgebase articles relating to this problem, but I still cannot get it to work.
ANSWER
The following example program, MAIN.C, demonstrates some simple inline assembly.
The following rules apply to C51 inline assembly:
- To use #pragma ASM/ENDASM, you must set the Generate Assembler SRC File and Assemble SRC File source file compile options in µVision by right-clicking your source file name in the Project Workspace and selecting Options for File.
- When using the Generate Assembler SRC File and Assemble SRC File options in µVision, if there are no other C modules in your project, you must manually include the C51 Run-Time Library (C51S.LIB, C51C.LIB, or C51L.LIB).
MORE INFORMATION
- Refer to ASM in the Cx51 User's Guide.
- Refer to Interfacing C to Assembler in the Cx51 User's Guide.
SEE ALSO
FORUM THREADS
The following Discussion Forum threads may provide information related to this topic.
Last Reviewed: Monday, April 8, 2013
ProductsDevelopment Tools | Hardware & Collateral | Downloads | Support | Contact |
Cookie Settings | Terms of Use | Privacy | Accessibility | Trademarks | Contact Us | Feedback Copyright © 2005-2019 Arm Limited (or its affiliates). All rights reserved. |