Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12603 Discussions

how to assebler compile and download

Altera_Forum
Honored Contributor II
1,007 Views

I am recently trying to do the pure assembly programming for Nios II. I found from website that there is a tool call Debug Client is tailored for DE2 board for this purpose. However I am using the UP3 board which is not provided such kind of tool. I have tried to do it in Nios II IDE just like I did c programming before, but the only avaiable project type is c/c++ application. My assembly source file can not be compiled properly in that project. No matter what the source code is, the compiler always show the error message as below, 

 

bj/aaa.o(.text+0x0): In function `_start': 

: multiple definition of `_start' 

D:/Design/Nios2Flash/software/asm_syslib/Debug/crt0.o(.text+0x0):/cygdrive/c/Altera/NioII/components/altera_nios2/HAL/src/crt0.S:236: first defined here 

D:/Design/Nios2Flash/software/asm_syslib/Debug/libasm_syslib.a(alt_main.o)(.text+0x60): In function `alt_main': 

/cygdrive/c/Altera/NioII/components/altera_hal/HAL/src/alt_main.c:149: undefined reference to `main' 

collect2: ld returned 1 exit status 

make: *** [asm.elf] Error 1 

 

Could anyone give a proper solution for the assembly programming on UP3 board please? Thanks a million!!!
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
279 Views

You should define symbol "main", orelse you should override alt_main.c;

0 Kudos
Altera_Forum
Honored Contributor II
279 Views

Thanks for the reply. I am still not really sure how to add main in the assembly. I am expecting to use the assembler to reduce the size of the compile file which is to be downloaded to the processor. Will it make the download file bigger if I am using c code or file again?

0 Kudos
Altera_Forum
Honored Contributor II
279 Views

As far as I know (not much) as soon as you enter the main.c function the C environment has to be created in the processor, this at least includes the creation of a stack. There is an option in the Nios IDE for creating assembly files of the compiled code, you can check it to see what the processor does before entering main. 

 

If you are satisfied with about 6kB memory consumption for a simple hello world, you may use hello_alt_main and specify reduced driver size and simplified C library. 

 

iztok jeras
0 Kudos
Altera_Forum
Honored Contributor II
279 Views

If you wanna reduce code size, you'd better study the following files: 

crt0.S 

alt_main.c 

alt_sys_init.c 

 

crt0.S is the enter of processor when resets, then it will call alt_main, alt_main will call alt_sys_init and main.... 

 

FYI. 

David
0 Kudos
Altera_Forum
Honored Contributor II
279 Views

I just found that use the small c library and reduce device drivers can significantly reduce the size of code. And the assembly may improve it further. It is proved to be useful. Thanks very much for all above replies.

0 Kudos
Reply