fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int dividend = -42, divisor = 3, quotient, remainder;
  5.  
  6. __asm__ ( "movl %2, %%edx;"
  7. "sarl $31, %%edx;"
  8. "movl %2, %%eax;"
  9. "movl %3, %%ebx;"
  10. "idivl %%ebx;"
  11. : "=a" (quotient), "=d" (remainder)
  12. : "g" (dividend), "g" (divisor)
  13. : "ebx" );
  14.  
  15. printf("%i / %i = %i, remainder: %i\n", dividend, divisor, quotient, remainder);
  16. }
Runtime error #stdin #stdout 0.02s 1720KB
stdin
Standard input is empty
stdout
-42 / 3 = -14, remainder: 0