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 12ENTRY_NO_HIDE CheckForARMSDIVInstruction 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 25