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++

assembly prog

Altera_Forum
Honored Contributor II
1,074 Views

Hi 

 

Has anyone tried to write assembly language programs for nios II processor? If so plz tell me how to start the program i.e., i mean to say are any initial statements required like main() in c-lang. I wrote a sample program as follows but the error is that " %g0 not a valid register" , "%g1 not a valid register". 

 

 

.text 

MOVI %g0,9 

MOV %g1,%g0 

NOP 

 

So someone please tell me how to overcome the problem
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
305 Views

Hi rakesh, 

 

You can find example assemble code in u-boot: 

 

-cpu/nios2/start.S 

-cpu/nios2/exceptions.S 

-lib_nios2/cache.S 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
305 Views

you are writing NiosI asm for NiosII cpu ... 

 

here's something:  

 

    .file    "Main.s"     .section    .text     .align    3     .global    main     .type    main, @function main:     //sp <- sp -8     addi    sp, sp, -8     //ra -> *(sp +4)         stw  ra,4(sp)           // fp -> *(sp)  stw  fp,0(sp)      // fp -> sp     mov  fp,sp         aaa:    //#define LED_BASE 0x00000820     movhi    r13, %hiadj(0x00000820)     addi    r13, r13, %lo(0x00000820)          //valeur par bit (1) allume  (0) eteint     movhi    r12, %hiadj(255)     addi    r12, r12, %lo(255)          //allume led     stwio    r12, 0(r13)          call    delay1 ....
0 Kudos
Altera_Forum
Honored Contributor II
305 Views

Thankyou smcnutt and slvn. I will be in touch with both of you if i have any more doubts.

0 Kudos
Altera_Forum
Honored Contributor II
305 Views

rakesh,  

 

if you need more details about assembly and instruction. you should refer to reference and developper handbooks for Nios II. 

 

about the prog I did, it&#39;s just stupid and incomplete showing you what it looks like. (you were using Nios I assembly in your post I guess). 

 

If your SPOC has some leds you can replace Base Led by the address where are mapped your leds, and try something like turning the led on/off 

file "Main.s" .section .text .align 3 .global main .type main, @function main:     //#define LED_BASE 0x00000820 movhi r13, %hiadj(0x00000820) addi r13, r13, %lo(0x00000820) //valeur par bit (1) allume  (0) eteint movhi r12, %hiadj(255) addi r12, r12, %lo(255) //turn led on stwio r12, 0(r13) hope it can help Sylvain
0 Kudos
Reply