Guest User

Untitled

a guest
Jan 25th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. //intr.asm
  2. intr_common_handler:
  3. push ebp
  4. push edi
  5. push esi
  6. push edx
  7. push ecx
  8. push ebx
  9. push eax
  10. push esp
  11. call handle_interrupt
  12. add esp, 4
  13. pop eax
  14. pop ebx
  15. pop ecx
  16. pop edx
  17. pop esi
  18. pop edi
  19. pop ebp
  20. add esp, 8
  21. intr_debug_handler: // BP 2
  22. iret
  23. // main.c
  24. void invoke_timer() { // BP 1
  25. asm volatile ("int $0x20");
  26. }
  27. // intr.c
  28. void handle_interrupt(struct cpu_state* cpu)
  29. {
  30. printf("\nException %x, Fehlercode %x!", cpu->intr, cpu->error);
  31. printf("\nEAX: %x, EBX: %x, ECX: %x, EDX: %x", cpu->eax, cpu->ebx, cpu->ecx, cpu->edx);
  32. printf("\nESI: %x, EDI: %x", cpu->esi, cpu->edi);
  33. printf("\nSS:EBP: %x:%x, SS:ESP: %x:%x",cpu->ss, cpu->ebp,cpu->ss, cpu->esp);
  34. printf("\nCS:EIP: %x:%x",cpu->cs, cpu->eip);
  35. printf("\nEFLAGS: %b%B",2,cpu->eflags);
  36. printf("Exception!");
  37. if (cpu->intr >= 0x28) {
  38. outb(0xa0, 0x20);
  39. }
  40. outb(0x20, 0x20);
  41. // Ok! Hier kommt der Code für den INT hin!
  42. // Derzeitig können wir nicht viel Tun!
  43. if (cpu->intr <=0x1f) {
  44. printf("\nException %x, Fehlercode %x!", cpu->intr, cpu->error);
  45. printf("\nEAX: %x, EBX: %x, ECX: %x, EDX: %x", cpu->eax, cpu->ebx, cpu->ecx, cpu->edx);
  46. printf("\nESI: %x, EDI: %x", cpu->esi, cpu->edi);
  47. printf("\nSS:EBP: %x:%x, SS:ESP: %x:%x",cpu->ss, cpu->ebp,cpu->ss, cpu->esp);
  48. printf("\nCS:EIP: %x:%x",cpu->cs, cpu->eip);
  49. printf("\nEFLAGS: %b%B",2,cpu->eflags);
  50. while(1) {
  51. asm volatile("cli; hlt");
  52. }
  53. }
  54. printf("\nException %x, Fehlercode %x!", cpu->intr, cpu->error);
  55. printf("\nEAX: %x, EBX: %x, ECX: %x, EDX: %x", cpu->eax, cpu->ebx, cpu->ecx, cpu->edx);
  56. printf("\nESI: %x, EDI: %x", cpu->esi, cpu->edi);
  57. printf("\nSS:EBP: %x:%x, SS:ESP: %x:%x",cpu->ss, cpu->ebp,cpu->ss, cpu->esp);
  58. printf("\nCS:EIP: %x:%x",cpu->cs, cpu->eip);
  59. printf("\nEFLAGS: %b%B",2,cpu->eflags);
  60. int * stackpointer = (int *) (cpu->esp+0x28);
  61. printf("\nReturn-Position: %x", *(stackpointer));
  62. }
Advertisement
Add Comment
Please, Sign In to add comment