- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can I use some low-level programming language (assembler) to programm NIOS II?
I need to integrate NIOS II deeply in my system and I need only core functionality of NIOS II, so I want to have a full control over ALU of NIOS II. As I understand, NIOS II IDE dosn't allow me so much freedom. Please, Someone, suggest me some IDE wich will allow to use assembler commands, or macros. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/ohmy.gifLink Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use the Nios II IDE to write assembler. Just name your source file with a .s or .S extension, and it will be compiled as assembly.
You can start your code from the standard full c entry point by providing the main function in assembler: .section .text
.globl main
main:
This will give you the full device driver initialisation before your code starts. Presumably you want greater control than that, so you can use the alt_main entry point intstead: .section .text
.globl alt_main
alt_main:
In this case the only code that will run before yours is the code defined in crt0.S. This deals with initialising the caches, the stack pointer, bss and the global pointer. If you want to take full control of the boot process, then copy the file crt0.S from the nios2 component into your system library project (not application project), and then modify this file as required. This copy will be used in preference to the one supplied by the nios2 component.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Special thanks to monkeyboy ! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif
Another question - about mixed programming (asm + c++). How can I call to functions in *.s files from C++ files in NIOS II lDE? Thanks.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If all you want to do is run a few lines of assembler, then it would be easiest to use the compiler's asm statement. This is described in the gcc documentation that comes with the kit. You can also find examples of this within the HAL.
If you really want to write the entire function in assembler, then you will need to ensure that the function adheres to the processors "application binary interface". This is described in the appendix of the Nios II Processor Reference Handbook, which is also supplied with the kit. To make the call from C++ rather than C you should declare the function as "extern C", e.g.:extern "c"
{
extern void my_asm_func (void);
}
That way you don't have to worry about the effects of the C++ mangler.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page