Advertisement
Guest User

OR1K GCC FTOI BUG

a guest
Mar 12th, 2011
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. OR1K compiler float-to-integer instruction example.
  2.  
  3. Code is:
  4.  
  5.  
  6. int main(void)
  7. {
  8. volatile float test = 1234.567f;
  9.  
  10. return (int) test;
  11. }
  12.  
  13.  
  14. Compiled with:
  15.  
  16. or32-linux-gcc -mhard-float -O2 ftoi.c -o ftoi
  17.  
  18. Disassembly (commenting added):
  19.  
  20. 000001d8 <main>:
  21. 1d8: 18 60 00 00 l.movhi r3,0x0
  22. 1dc: d7 e1 4f fc l.sw 0xfffffffc(r1),r9
  23. 1e0: a8 63 3a 88 l.ori r3,r3,0x3a88 ; FP value in data section, see below
  24. 1e4: 9c 21 ff f8 l.addi r1,r1,0xfffffff8
  25. 1e8: 84 63 00 00 l.lwz r3,0x0(r3) ; Load FP value
  26. 1ec: d4 01 18 00 l.sw 0x0(r1),r3 ; Put through stack for some reason
  27. 1f0: 84 61 00 00 l.lwz r3,0x0(r1) ; Off stack
  28. 1f4: 04 00 03 f4 l.jal 11c4 <__fixsfsi> ; Software float-to-int conversion
  29. 1f8: 15 00 00 00 l.nop 0x0
  30. 1fc: 9c 21 00 08 l.addi r1,r1,0x8
  31. 200: 85 21 ff fc l.lwz r9,0xfffffffc(r1)
  32. 204: 44 00 48 00 l.jr r9
  33. 208: 15 00 00 00 l.nop 0x0
  34.  
  35.  
  36. 00003a88 <__thenan_sf-0x8>:
  37. 3a88: 44 9a 52 25 l.jr r10 ; Float data - 1234.5670166015625
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement