- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
does the nios ii ide support assemble language? why does my assemble codes occur errors? my setup project proceed as follows: 1 Start the Nios II IDE. (Start->All Programs->Altera->NiosII EDS 9-> NiosII 9 IDE 2 Creat a new project. File->New->Project Nios II C/C++ Application 3 Select blankproject from templates 4 Set the project name 5 Select the target hardware( sopc builder system has been setup) 6 Click Next 7 Click New system libary 8 Click Finish 9 Add a file with name basics.s (File->New->Other This opens a popup where you can pick File from under the General Category, after selecting File, you need to specify the name at the bottom (use basics.s) 10 enter the code: .include"nios_macros.s" .text .equ TEST_NUM,0x90abcdef .global _start _start: movia r7,TEST_NUM mov r4,r7 STRING_COUNTER: mov r2,r0 STRING_COUNTER_LOOP: beq r4,r0,END_STRING_COUNTER srli r5,r4,1 and r4,r4,r5 addi r2,r2,1 br STRING_COUNTER_LOOP END_STRING_COUNTER: mov r16,r2 END: br END .end 11 Use Debug As -> Nios II Instruction Set Simulator which will build the project (assemble the file) and start the debugger. then errors occur errors: /cygdrive/d/altera/90/nios2eds/components/altera_hal/HAL/src/alt_main.c undefined reference to `main' /cygdrive/d/altera/90/quartus/FPGA_code/computer_organization/lab_ex1/part1_1/software/asm_first_syslib/Debug/crt0.o(.text+0x0):/cygdrive/d/altera/90/ip/altera/nios2_ip/altera_nios2/HAL/src/crt0.S first defined here /cygdrive/d/altera/90/quartus/FPGA_code/computer_organization/lab_ex1/part1_1/software/asm_first_syslib/Debug/libasm_first_syslib.a(alt_main.o) In function `alt_main': Can't open nios_macros.s for reading: No such file or directory obj/part2.o In function `_start': Warning: end of file not at end of a line; newline inserted ps: 1 i'm sure the codes are right(de2-70 labs exercises/computer organization/lab1) 2 the operator proceed is from duke.edu by google forgive my ugly English,:D. Best regards hanshaohuaLink Copied
14 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use:
.global _alt_main _alt_main: instead of: .global _start _start: you need the C runtime startup to initialize the NIOS II system and it jumps to _alt_main. Bill- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- you need the C runtime startup to initialize the NIOS II system and it jumps to _alt_main. --- Quote End --- Strictly speaking, this isn't true. If you drop the Altera provided syslib/bsp entirely, you can avoid all the default C runtime and initialization stuff. If you include the syslib/bsp as it appears the OP has done, then you do need to define either _alt_main or _main as you have suggested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you,Bill.
I'm new to nios ii system. By now, i don't know the assembly code or my wrong operating proceed cause wrong. But from the nios ide errors tips, nios ii can't recognize the assembly code .- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Strictly speaking, this isn't true. If you drop the Altera provided syslib/bsp entirely, you can avoid all the default C runtime and initialization stuff. If you include the syslib/bsp as it appears the OP has done, then you do need to define either _alt_main or _main as you have suggested. --- Quote End --- Hi,Kevin. It's kind of you . I have modifed the assembly code using .global _alt_main _alt_main: instead of .global _start _start: But it does not work, yet occur errors as mentioned by me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you tried _main instead of _alt_main?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Have you tried _main instead of _alt_main? --- Quote End --- yes,have the same errors. If there is something wrong with the code, i can continue to work on labs exercises. But,if nios ii does not support assembly code , i have no idea how to go on. May be i can try nios ii command shell( i'm familiar with linux and know of many commands). :) Thanks all the same. hanshaohua
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry to ask this but why use assembly language? Why not use C? The NIOS II GCC compiler generates code as good as and probably better than any assembly code I've written.
Bill- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- Sorry to ask this but why use assembly language? Why not use C? The NIOS II GCC compiler generates code as good as and probably better than any assembly code I've written. Bill --- Quote End --- Hi,bill. yes,i am more familiar with C more than assembly language. Acutually speaking, i am doing labs exercises using DE2 . And DE2 provides assembly codes exercises. Most of all, i am new to niso ii system. hanshaohua
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Finally, the problem is solved.
1 assembly file is xx.S,not xx.s 2 You must have a function or label called main. If main is written in assembly-language, the label main must be declared global with the .global directive. 3 Project default in Eclipse woring dir would be best. Thank you ,Bill,Kevin.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
I still have the error, my asm sour file is main.S, the code from a NIOSII tutorial: .include "nios_macros.s"
.equ switches, 0x41020
.equ leds, 0x41030
.global main
main:
movia r2, switches
movia r3, leds
loop:
ldbio r4, 0(r2)
stbio r4, 0(r3)
br loop but: alt_main.c:154: undefined reference to `main' :(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm using Monitor program and C language setting. I have a .s file which itself includes the "macros.s" . But I get the same error : Can't open macros.s for reading: No such file or directory 1. I tried using .S file instead of .s 2. I used Eclipse as default working directory 3. I have main function in C and tried _main or _start or _alt_main in my assembly file Any suggestion?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Failure to open macros.s is a problem with the list of directories passed to gcc (acting as cpp) as -I dir_name.
I've no idea what is in it - but I don't think your little file relies on any of it. You'll cut out a lot of the library code that gets added by the build it you call your function alt_main (not main). Also, as is mentioned earlier in this thread, if you aren't using any of the Altera BSP or libc functions, you don't need any of their setup code. The only initialisation required before jumping into C code is to set %sp and %gp. For your two instruction loop even those aren't needed.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[SOLVED] here's how I fixed the problem.
I copied the compilation command from monitor program in info & Errors window and pasted in nios2 command shell and it compiled the program with no error. Now my program works but 1 problem still remains; In the compilation command there's a option -mno-cache-volatile. nios2 Command shell complains that this option is not known so I have to remove it. here's the full command: nios2-elf-gcc -g -O1 -ffunction-sections -fverbose-asm -fno-inline -mno-cache-volatile -mno-hw-mulx -mhw-mul -mhw-div -Ic:/altera/91sp2/nios2eds/components/altera_nios2/HAL/inc -DSYSTEM_BUS_WIDTH=32 -DALT_SINGLE_THREADED -D_JTAG_UART_BASE=0x10001000 -Wl,--defsym -Wl,nasys_stack_top=0x800000 -Wl,--defsym -Wl,nasys_program_mem=0x1000 -Wl,--defsym -Wl,nasys_data_mem=0x10000 -Wl,--section-start -Wl,.exceptions=0x20 -Wl,--section-start -Wl,.reset=0x0 -Wl,--script=c:/altera/91sp2/quartus/../University_Program/Monitor_Program/build/nios_cpp_build.ld -o "C:/Documents and Settings/user/Desktop/test1/main.elf" "C:/Documents and Settings/user/Desktop/test1/main.c" "C:/Documents and Settings/user/Desktop/test1/playback.s" c:/altera/91sp2/quartus/../University_Program/Monitor_Program/lib/jtag_uart.c Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The -mno-cache-volatile causes gcc (3.4.6) to use the 'io' forms of instructions for volatile memory accesses (thus bypassing the data cache).
This is likely to cause more grief than it fixes. Not sure why it would fail the compile. In any case it shouldn't be the default for the IDE, so you must have ticked something to enable it.
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