Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 1 | // This function is used to check for the CPU's support for the sdiv |
| 2 | // instruction at runtime. It will either return the value 1 or |
| 3 | // will cause an invalid instruction trap (SIGILL signal). The |
| 4 | // caller must arrange for the signal handler to set the r0 |
| 5 | // register to 0 and move the pc forward by 4 bytes (to skip |
| 6 | // the invalid instruction). |
| 7 | |
| 8 | |
| 9 | #include "asm_support_arm.S" |
| 10 | |
| 11 | .section .text |
Andreas Gampe | 29b3841 | 2014-08-13 00:15:43 -0700 | [diff] [blame] | 12 | ENTRY_NO_HIDE CheckForARMSDIVInstruction |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 13 | mov r1,#1 |
| 14 | // depending on the architecture, the assembler will not allow an |
| 15 | // sdiv instruction, so we will have to output the bytes directly. |
| 16 | |
| 17 | // sdiv r0,r1,r1 is two words: 0xfb91 0xf1f0. We need little endian. |
| 18 | .byte 0x91,0xfb,0xf1,0xf0 |
| 19 | |
| 20 | // if the divide worked, r0 will have the value #1 (result of sdiv). |
| 21 | // It will have 0 otherwise (set by the signal handler) |
| 22 | // the value is just returned from this function. |
| 23 | bx lr |
| 24 | END CheckForARMSDIVInstruction |