《操作系统》的实验代码。

17 lines
441 B

  1. void inline ex1(void){
  2. asm ("movl $0xffff, %eax\n");
  3. }
  4. void inline ex2(void){
  5. unsigned cr0;
  6. asm volatile ("movl %%cr0, %0\n" :"=r"(cr0));
  7. cr0 |= 0x80000000;
  8. asm volatile ("movl %0, %%cr0\n" ::"r"(cr0));
  9. }
  10. void inline ex3(void){
  11. long __res, arg1 = 2, arg2 = 22, arg3 = 222, arg4 = 233;
  12. __asm__ __volatile__("int $0x80"
  13. : "=a" (__res)
  14. : "0" (11),"b" (arg1),"c" (arg2),"d" (arg3),"S" (arg4));
  15. }