Browse Source

* m68k: fixed setjmp/longjmp:
* Data registers have to be saved/restored using 'move.l', because 'move' without suffix assumes 16-bit size.
* setjmp must behave as a regular function w.r.t. removing its argument from the stack.

git-svn-id: trunk@28103 -

sergei 11 years ago
parent
commit
23a20f0e50
1 changed files with 19 additions and 17 deletions
  1. 19 17
      rtl/m68k/setjump.inc

+ 19 - 17
rtl/m68k/setjump.inc

@@ -26,8 +26,9 @@ asm
   move.l 4(sp), a0
   move.l 4(sp), a0
   // save a0 (now in d0) to offset 40
   // save a0 (now in d0) to offset 40
   move.l d0, 40(a0)
   move.l d0, 40(a0)
-  // save return address (PC)
-  move.l (sp), d0
+  // save return address (PC) and pop S off the stack
+  move.l (sp)+, d0
+  move.l d0,(sp)
   move.l d0, 8(a0)
   move.l d0, 8(a0)
   // save FP
   // save FP
 {$if defined(amiga)}
 {$if defined(amiga)}
@@ -37,7 +38,8 @@ asm
 {$endif}
 {$endif}
   // save SP
   // save SP
   move.l sp, d0
   move.l sp, d0
-  addq.l #8, d0
+  // 4 bytes already popped, 4 to go.
+  addq.l #4, d0
   move.l d0, 4(a0)
   move.l d0, 4(a0)
   // save a1
   // save a1
   move.l a1,d0
   move.l a1,d0
@@ -55,13 +57,13 @@ asm
   move.l a5,d0
   move.l a5,d0
   move.l d0,60(a0)
   move.l d0,60(a0)
   // save d1..d7
   // save d1..d7
-  move d1, 12(a0)
-  move d2, 16(a0)
-  move d3, 20(a0)
-  move d4, 24(a0)
-  move d5, 28(a0)
-  move d6, 32(a0)
-  move d7, 36(a0)
+  move.l d1, 12(a0)
+  move.l d2, 16(a0)
+  move.l d3, 20(a0)
+  move.l d4, 24(a0)
+  move.l d5, 28(a0)
+  move.l d6, 32(a0)
+  move.l d7, 36(a0)
   // restore a0
   // restore a0
   move.l 40(a0), a0
   move.l 40(a0), a0
 
 
@@ -90,13 +92,13 @@ asm
   move.l 60(a0),d0
   move.l 60(a0),d0
   move.l d0,a5
   move.l d0,a5
   // restore d1..d7
   // restore d1..d7
-  move 12(a0),d1
-  move 16(a0),d2
-  move 20(a0),d3
-  move 24(a0),d4
-  move 28(a0),d5
-  move 32(a0),d6
-  move 36(a0),d7
+  move.l 12(a0),d1
+  move.l 16(a0),d2
+  move.l 20(a0),d3
+  move.l 24(a0),d4
+  move.l 28(a0),d5
+  move.l 32(a0),d6
+  move.l 36(a0),d7
 
 
   // load value to d0
   // load value to d0
   move.l 8(sp),d0
   move.l 8(sp),d0