syscall-z88dk: initial fix ups
authorAlan Cox <alan@linux.intel.com>
Sat, 27 Dec 2014 00:40:22 +0000 (00:40 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 27 Dec 2014 00:40:22 +0000 (00:40 +0000)
It now looks plausible but isn't yet tested

Library/tools/syscall-z88dk.c

index 9a26675..6d466cd 100644 (file)
@@ -34,6 +34,7 @@ static void write_call(int n)
     case 0:  
       fprintf(fp, "\tld hl, %d\n", n);
       fprintf(fp, "\tjp syscall\n");
+      break;
     case 1:
       fprintf(fp, "\tpush hl\n");
       fprintf(fp, "\tld hl, %d\n", n);
@@ -42,25 +43,25 @@ static void write_call(int n)
       fprintf(fp, "\tret\n");
       break;
     case 2:
-      fprintf(fp, "\tpop de\n\tpop bc\n\tpush de\n\tpush bc\n");
+      fprintf(fp, "\tpop hl\n\tpop de\n\tpop bc\n\tpush de\n\tpush bc\n\tpush hl\n");
       fprintf(fp, "\tld hl, %d\n", n);
       fprintf(fp, "\tcall syscall\n");
-      fprintf(fp, "\tpop de\n\tpop bc\n\tpush de\n\tpush bc\n");
-      fprintf(fp, "\tret\n");
+      fprintf(fp, "\tpop ix\n\tpop de\n\tpop bc\n\tpush de\n\tpush bc\n");
+      fprintf(fp, "\tjp (ix)\n");
       break;
     case 3:
-      fprintf(fp, "\tpop de\n\tpop bc\n\tpop hl\n\tpush de\n\tpush bc\n\tpush hl\n");
+      fprintf(fp, "\tpop ix\n\tpop de\n\tpop bc\n\tpop hl\n\tpush de\n\tpush bc\n\tpush hl\n\tpush ix\n");
       fprintf(fp, "\tld hl, %d\n", n);
       fprintf(fp, "\tcall syscall\n");
-      fprintf(fp, "\tpop de\n\tpop bc\n\tpop ix\n\tpush de\n\tpush bc\n\tpush ix\n");
-      fprintf(fp, "\tret\n");
+      fprintf(fp, "\tpop ix\n\tpop de\n\tpop bc\n\tpop iy\n\tpush de\n\tpush bc\n\tpush iy\n");
+      fprintf(fp, "\tjp (ix)\n");
       break;
     case 4:
-      fprintf(fp, "\tpop de\n\tpop bc\n\tpop hl\n\tpop ix\n\tpush de\n\tpush bc\n\tpush hl\n\tpush ix\n");
+      fprintf(fp, "\tpop ix\n\tpop de\n\tpop bc\n\tpop hl\n\tpop iy\n\tpush de\n\tpush bc\n\tpush hl\n\tpush iy\n\tpush ix\n");
       fprintf(fp, "\tld hl, %d\n", n);
       fprintf(fp, "\tcall syscall\n");
-      fprintf(fp, "\tpop de\n\tpop bc\n\tpop ix\n\tpop iy\n\tpush de\n\tpush bc\n\tpush ix\n\tpush iy\n");
-      fprintf(fp, "\tret\n");
+      fprintf(fp, "\tpop ix\n\tpop de\n\tpop bc\n\tpop iy\n\tpop af\n\tpush de\n\tpush bc\n\tpush iy\n\tpush af\n");
+      fprintf(fp, "\tjp (ix)\n");
       break;
   }
   fclose(fp);