Forum Discussion

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

asemblle cope

Hi all!

I need to write an assemby code that will do some thing like this

float callee(float a, float b1)

{

int c=7;

return (b1-a)/c;

}

i know i could use nios-2-elf-objdump to produce assemblee code

but when i do that , whenever there is use of floating point the assemblee code

produce is

call 0 <_ZSt17__verify_groupingPKcmRKSs>

i have checked using the debugger and saw that code should be:

0x00805534 <_Z6calleeff>: addi sp,sp,-20

0x00805538 <_Z6calleeff+4>: stw ra,16(sp)

0x0080553c <_Z6calleeff+8>: stw fp,12(sp)

0x00805540 <_Z6calleeff+12>: mov fp,sp

0x00805544 <_Z6calleeff+16>: stw r4,0(fp)

0x00805548 <_Z6calleeff+20>: stw r5,4(fp)

0x0080554c <_Z6calleeff+24>: movi r2,7

0x00805550 <_Z6calleeff+28>: stw r2,8(fp)

0x00805554 <_Z6calleeff+32>: ldw r4,8(fp)

0x00805558 <_Z6calleeff+36>: call 0x876fa4 <__floatsisf>

0x0080555c <_Z6calleeff+40>: ldw r4,0(fp)

0x00805560 <_Z6calleeff+44>: mov r5,r2

0x00805564 <_Z6calleeff+48>: call 0x876d68 <__divsf3>

0x00805568 <_Z6calleeff+52>: ldw r4,4(fp)

0x0080556c <_Z6calleeff+56>: mov r5,r2

0x00805570 <_Z6calleeff+60>: call 0x876b3c <__subsf3>

0x00805574 <_Z6calleeff+64>: ldw ra,16(sp)

0x00805578 <_Z6calleeff+68>: ldw fp,12(sp)

0x0080557c <_Z6calleeff+72>: addi sp,sp,20

0x00805580 <_Z6calleeff+76>: ret

How can i find how to refere to floating points command in assemblee??

How do i figure out where is the address of ,for example, <__divsf3>??

does this address get change from one compilation to another??

Thanks

Ilan

3 Replies

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

    Hello,

    if you search the objectdump for __divsf3, you will find the address for the function. Yes, the address will change every time you change the source code.

    If you have a quick look to the code you posted, you will not save a lot by doing this in assembly, if you call the __divsf3 , __subsf3 and __floatsisf functions. Most of the work is done there.

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

    Try also to call the gcc with the -S option... it will produce assembler source code you can use as a starting point...

    __divsf3 and the other functions called from the assembly code are contained inside the C library...

    bye

    Paolo