- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 problemLink Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thankyou smcnutt and slvn. I will be in touch with both of you if i have any more doubts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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'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/offfile "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
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