Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OR1K compiler float-to-integer instruction example.
- Code is:
- int main(void)
- {
- volatile float test = 1234.567f;
- return (int) test;
- }
- Compiled with:
- or32-linux-gcc -mhard-float -O2 ftoi.c -o ftoi
- Disassembly (commenting added):
- 000001d8 <main>:
- 1d8: 18 60 00 00 l.movhi r3,0x0
- 1dc: d7 e1 4f fc l.sw 0xfffffffc(r1),r9
- 1e0: a8 63 3a 88 l.ori r3,r3,0x3a88 ; FP value in data section, see below
- 1e4: 9c 21 ff f8 l.addi r1,r1,0xfffffff8
- 1e8: 84 63 00 00 l.lwz r3,0x0(r3) ; Load FP value
- 1ec: d4 01 18 00 l.sw 0x0(r1),r3 ; Put through stack for some reason
- 1f0: 84 61 00 00 l.lwz r3,0x0(r1) ; Off stack
- 1f4: 04 00 03 f4 l.jal 11c4 <__fixsfsi> ; Software float-to-int conversion
- 1f8: 15 00 00 00 l.nop 0x0
- 1fc: 9c 21 00 08 l.addi r1,r1,0x8
- 200: 85 21 ff fc l.lwz r9,0xfffffffc(r1)
- 204: 44 00 48 00 l.jr r9
- 208: 15 00 00 00 l.nop 0x0
- 00003a88 <__thenan_sf-0x8>:
- 3a88: 44 9a 52 25 l.jr r10 ; Float data - 1234.5670166015625
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement