Change assembly from AT&T to Intel syntax.
[pintos-anon] / src / threads / intr-stubs.pl
index ea20e9668ede5de1669138957c5e205079c6e3f4..a5ad9b0514bd251f5aec0ab9222d659c503a9c64 100755 (executable)
@@ -1,9 +1,11 @@
 #! /usr/bin/perl
 
 print <<'EOF';
-#include "mmu.h"
+#include "threads/loader.h"
 
-       .globl intr_stubs
+       .data
+       .intel_syntax noprefix
+.globl intr_stubs
 intr_stubs:
 EOF
 
@@ -11,46 +13,50 @@ for $i (0...255) {
     $x = sprintf ("%02x", $i);
     print "\t.long intr${x}_stub\n";
 }
-print "\n";
+
+print <<'EOF';
+
+       .text
+EOF
 
 for $i (0...255) {
     $x = sprintf ("%02x", $i);
-    print "\t.globl intr${x}_stub\n";
+    print ".globl intr${x}_stub\n";
     print "intr${x}_stub:\n";
-    print "\tpushl \$0\n"
+    print "\tpush 0\n"
        if ($i != 8 && $i != 10 && $i != 11
            && $i != 13 && $i != 14 && $i != 17);
-    print "\tpushl \$0x$x\n";
+    print "\tpush 0x$x\n";
     print "\tjmp intr_entry\n";
 }
 
 print <<'EOF';
 intr_entry:
-       # FIXME: build a fake stack frame to improve backtraces.
        # Save caller's registers.
-       pushl %ds
-       pushl %es
-       pushal
+       push ds
+       push es
+       pusha
 
        # Set up kernel environment.
        cld
-       movl $SEL_KDSEG, %eax
-       movl %eax, %ds
-       movl %eax, %es
+       mov eax, SEL_KDSEG
+       mov ds, eax
+       mov es, eax
 
-       # Call handler.
-       pushl %esp
-       .globl intr_handler
+       # Call interrupt handler.
+       push esp
+.globl intr_handler
        call intr_handler
+       add esp, 4
 
-       .globl intr_exit
+.globl intr_exit
 intr_exit:
-       addl $4, %esp
-
        # Restore caller's registers.
-       popal
-       popl %es
-       popl %ds
-       addl $8, %esp
+       popa
+       pop es
+       pop ds
+       add esp, 8
+
+        # Return to caller.
        iret
 EOF