how use div in or1k

View: New views
3 Messages — Rating Filter:   Alert me  

how use div in or1k

by yueng :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

in the C code

a = b/c ; // all integers

after compiler link
it generate a      l.jal 0 <_reset_100-0x100>  , not a div instruction
then jump to here
Disassembly of section .vectors:
     23      
     24 00000000 <_reset_100-0x100>:
     25         ...
     26
     27 00000100 <_reset_100>:
     28      100:       15 00 00 00     l.nop 0x0
     29      104:       00 00 08 1b     l.j 2170 <_reset_except>
     30      108:       15 00 00 00     l.nop 0x0
     31         ...


but a=b*c, will generate a     l.mul r3,r3,r4

how can i compile a correct div?

thank you.




Re: how use div in or1k

by Dimitri?s Orfanos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

As far as I know the only way to do this is to compile the source with
-S option and write the l.div with your hand.

yueng wrote:

> in the C code
>
> a = b/c ; // all integers
>
> after compiler link
> it generate a      l.jal 0 <_reset_100-0x100>  , not a div instruction
> then jump to here
> Disassembly of section .vectors:
>      23      
>      24 00000000 <_reset_100-0x100>:
>      25         ...
>      26
>      27 00000100 <_reset_100>:
>      28      100:       15 00 00 00     l.nop 0x0
>      29      104:       00 00 08 1b     l.j 2170 <_reset_except>
>      30      108:       15 00 00 00     l.nop 0x0
>      31         ...
>
>
> but a=b*c, will generate a     l.mul r3,r3,r4
>
> how can i compile a correct div?
>
> thank you.
>
>
>
>
>  
_______________________________________________
http://www.opencores.org/mailman/listinfo/openrisc

Re: how use div in or1k

by Sabri Gecal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here an Example:

or32-uclinux-gcc -I. -nostartfiles -mhard-div -g -T startup.ld -o test.o -Wall -W startup.S main.c

the option: -mhard-div is your solution



yueng wrote:
in the C code

a = b/c ; // all integers

after compiler link
it generate a      l.jal 0 <_reset_100-0x100>  , not a div instruction
then jump to here
Disassembly of section .vectors:
     23      
     24 00000000 <_reset_100-0x100>:
     25         ...
     26
     27 00000100 <_reset_100>:
     28      100:       15 00 00 00     l.nop 0x0
     29      104:       00 00 08 1b     l.j 2170 <_reset_except>
     30      108:       15 00 00 00     l.nop 0x0
     31         ...


but a=b*c, will generate a     l.mul r3,r3,r4

how can i compile a correct div?

thank you.