Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
21 years ago

Nios assemble

Hi,everyone.

In the debug perspective,we can see the code of function _start( ).It is only exits in assemble form.

0x0000035c <main>: addi sp,sp,-12

0x00000360 <main+4>: stw ra,8(sp)

0x00000364 <main+8>: stw fp,4(sp)

0x00000368 <main+12>: mov fp,sp

0x0000036c <main+16>: movi r2,9

0x00000370 <main+20>: stw r2,0(fp)

0x00000374 <main+24>: movhi r4,0

0x00000378 <main+28>: addi r4,r4,10912

0x0000037c <main+32>: call 0x3ac <printf>

0x00000380 <main+36>: movhi r4,0

0x00000384 <main+40>: addi r4,r4,10936

0x00000388 <main+44>: ldw r5,0(fp)

0x0000038c <main+48>: call 0x3ac <printf>

0x00000390 <main+52>: movhi r3,1

0x00000394 <main+56>: addi r3,r3,2080

0x00000398 <main+60>: movui r2,45220

0x0000039c <main+64>: stw r2,0(r3)

0x000003a0 <main+68>: movi r4,3000

0x000003a4 <main+72>: call 0xcb4 <usleep>

0x000003a8 <main+76>: br 0x390 <main+52>

I want to know the function of the above code.what is the _start function? And,especially movui r2,45220 what is it mean? Do I need to know about all of this?

Thank you !very much.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,everyone.

    In the debug perspective,we can see the code of function _start( ).

    It is only exits in assemble form.

    -> except error :

    0x0000035c <main>: addi sp,sp,-12 ; sp = sp - 12

    0x00000360 <main+4>: stw ra,8(sp) ; saving return address

    0x00000364 <main+8>: stw fp,4(sp) ; saving frame pointer

    0x00000368 <main+12>: mov fp,sp ; fp = stack pointer

    0x0000036c <main+16>: movi r2,9 ; r2 = 0x00000009

    0x00000370 <main+20>: stw r2,0(fp) ; [fp] = 0x00000009

    0x00000374 <main+24>: movhi r4,0 ; r4 = 0x00000000

    0x00000378 <main+28>: addi r4,r4,10912 ; r4 = 0x00002AA0

    0x0000037c <main+32>: call 0x3ac ; <printf>

    0x00000380 <main+36>: movhi r4,0 ; r4 = 0x00000000

    0x00000384 <main+40>: addi r4,r4,10936 ; r4 = 0x00002AB8

    0x00000388 <main+44>: ldw r5,0(fp) ; r5 = 0x00000009

    0x0000038c <main+48>: call 0x3ac ; <printf>

    loop :

    0x00000390 <main+52>: movhi r3,1 ; r3 = 0x00010000

    0x00000394 <main+56>: addi r3,r3,2080 ; r3 = 0x00010820

    0x00000398 <main+60>: movui r2,45220 ; r2 = 0x0000B0A4

    0x0000039c <main+64>: stw r2,0(r3) ; [0x00010820] = 0x0000B0A4

    0x000003a0 <main+68>: movi r4,3000 ; delay = 3 ms

    0x000003a4 <main+72>: call 0xcb4 ; <usleep>

    0x000003a8 <main+76>: br 0x390 ; <main+52> = loop

    I want to know the function of the above code.

    what is the _start function?

    -> see ...\altera_nios2\HAL\src\crt0.S

    and http://www.altera.com/support/kdb/2004/12/...62004_5733.html (http://www.altera.com/support/kdb/2004/12/rd12062004_5733.html)

    And,especially movui r2,45220 what is it mean?

    -> r2 = 0x0000B0A4 with B0A4h = 45220d

    Do I need to know about all of this?

    -> perhaps

    best regards.