Browse Source

+ de-uglified the previous hack
+ made Amiga syscalls to save/restore the frame pointer (do we really need a frame pointer?)
+ some disabled debug comments (to asm source)
+ compiler is now able to generate some VERY basic, but working Amiga-m68k executables

git-svn-id: trunk@9051 -

Károly Balogh 18 years ago
parent
commit
1536e9e65b
2 changed files with 20 additions and 4 deletions
  1. 7 4
      compiler/m68k/cgcpu.pas
  2. 13 0
      compiler/m68k/n68kcal.pas

+ 7 - 4
compiler/m68k/cgcpu.pas

@@ -1344,10 +1344,9 @@ unit cgcpu;
             writeln('proc exit with stackframe, size:',localsize,' parasize:',parasize);
 {$endif DEBUG_CHARLIE}
             list.concat(taicpu.op_reg(A_UNLK,S_NO,NR_FRAME_POINTER_REG));
-	    parasize := parasize - 8; { FIXME: ugly hack to correct the value...
-	                                but the real fun is, that works for now. 
-					i wonder where the extra 8 size comes from.
-					... maybe return address + framepointer size? (KB) }
+	    parasize := parasize - target_info.first_parm_offset; { i'm still not 100% confident that this is
+	                                                            correct here, but at least it looks less
+								    hacky, and makes some sense (KB) }
             if (parasize<>0) then
               begin
                 { only 68020+ supports RTD, so this needs another code path
@@ -1479,6 +1478,7 @@ unit cgcpu;
                   end
                 else
                   begin
+//    		    list.concat(tai_comment.create(strpnew('sign extend byte')));
                     list.concat(taicpu.op_reg(A_EXTB,S_L,reg));
                   end;
               end;
@@ -1486,15 +1486,18 @@ unit cgcpu;
               begin
                 if (isaddressregister(reg)) then
                    internalerror(20020729);
+//    		list.concat(tai_comment.create(strpnew('sign extend word')));
                 list.concat(taicpu.op_reg(A_EXT,S_L,reg));
               end;
          { zero extend }
          OS_8:
               begin
+//    		list.concat(tai_comment.create(strpnew('zero extend byte')));
                 list.concat(taicpu.op_const_reg(A_AND,S_L,$FF,reg));
               end;
          OS_16:
               begin
+//    		list.concat(tai_comment.create(strpnew('zero extend word')));
                 list.concat(taicpu.op_const_reg(A_AND,S_L,$FFFF,reg));
               end;
         end; { otherwise the size is already correct }

+ 13 - 0
compiler/m68k/n68kcal.pas

@@ -50,14 +50,27 @@ implementation
     procedure tm68kcallnode.do_syscall;
       var
         tmpref: treference;
+	tmpref2: treference;
       begin
         case target_info.system of
           system_m68k_amiga:
             begin
               if po_syscall_legacy in tprocdef(procdefinition).procoptions then
                 begin
+		  { save base pointer on syscalls }
+		  { FIXME: probably this will need to be extended to save all regs (KB) }
+                  reference_reset_base(tmpref2, NR_STACK_POINTER_REG, 0);
+                  tmpref2.direction := dir_dec;
+		  current_asmdata.CurrAsmList.concat(taicpu.op_reg_ref(A_MOVE,S_L,NR_FRAME_POINTER_REG,tmpref2));
+		  
+		  { the actuall call }
                   reference_reset_base(tmpref,NR_A6,-tprocdef(procdefinition).extnumber);
                   current_asmdata.CurrAsmList.concat(taicpu.op_ref(A_JSR,S_NO,tmpref));
+		  
+		  { restore frame pointer }
+                  reference_reset_base(tmpref2, NR_STACK_POINTER_REG, 0);
+                  tmpref2.direction := dir_inc;
+		  current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(A_MOVE,S_L,tmpref2,NR_FRAME_POINTER_REG));
                 end
               else
                 internalerror(2005010403);