//------------------------------------------------------------------- // overflow.cpp // // This program attempts to trigger an 'interrupt-on-overflow' // exception (Interrupt 4) by executing the 'into' instruction // following a calculation which will set the OF-bit (Overflow // Flag) in the processor's EFLAGS register. For this purpose // we can simply square the largest (unsigned) 32-bit integer. // // to compile: $ g++ overflow.cpp -o overflow // to execute: $ ./overflow // // NOTES: The 'into' instruction is not supported when the CPU // is executing in 64-bit mode. Linux's exception-handler for // the 'interrupt-on-overfow' exception displays the incorrect // diagnostic message "Segmentation fault" (kernel 2.6.27.10). // // programmer: ALLAN CRUSE // written on: 14 SEP 2009 //------------------------------------------------------------------- int main( int argc, char **argv ) { // square the largest unsigned 32-bit integer asm(" mov $-1, %eax \n mul %eax \n into "); }