xa51, work in progress
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 7 Feb 2002 18:55:43 +0000 (18:55 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 7 Feb 2002 18:55:43 +0000 (18:55 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1904 4a8a32a2-be11-0410-ad9d-d568d2c75423

as/xa51/xa_link.c
device/examples/xa51/Makefile
src/SDCCmain.c
src/xa51/main.c

index 64d89e5dd8dc5300c9d47922a203ffba74ded051..b89015651acec2b29aeb96957d629912f87da5c8 100644 (file)
@@ -1,3 +1,7 @@
+/* WORK IN PROGRESS: do not watch this if you don't have the legal
+   age in your country to watch this.
+*/
+
 /* This is a cheap hack. The xa51 has a couple of ways to scramble
    relocation info into it's opcode that the standard linker can't
    handle. 
 
    The only things that are handled now are:
 
-   "SDCCXA rel, version %f" must be the first line
+   "SDCCXA rel, version %f" must be the first line, sort of MAGIC word
    "H %d areas %d global symbols" defines the # of areas and globals
    "S <symbol> [Ref000 | DefXXXX]" Def's are supposed to be defined in
      their own area/segment
    "A <seg> size %d flags %d" switch to another segment. this can happen
-     multiple times and should be equal. flags is ignored
-   "T xx xx bb bb ..." where x is the address within the current segment
+     multiple times and should be equal. flags is ignored for now
+   "T xx xx bb bb ..." where xx xx is the address within the current segment
      and bb are the bytes
-   "R xx <how> <symbol>" the relocation tag. xx is the offset within the
+   "R xx <how> <symbol>" the relocation info. xx is the offset within the
      previous "T .." line. <how> could be something like REL_FF, REL_FFFF, 
-     ABS_F0FF. and symbol is the previous defined symbol it refers to
-
-   Thats all for now.
+     ABS_F0FF. symbol is the (previous) defined symbol it refers to
 */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <string.h>
 
 #include "xa_version.h"
 
@@ -48,7 +51,7 @@ void baseName(char *name, char*base) {
     last=strlen(name);
   }
 
-  printf ("baseName: %s %d %d\n", name, first, last);
+  fprintf (stderr, "baseName: %s %d %d\n", name, first, last);
   // fill the base with the baseName
   for (i=first; i<last; i++) {
     base[i-first]=name[i];
@@ -57,7 +60,7 @@ void baseName(char *name, char*base) {
 }
   
 void readModule(char *module) {
-  double thisVersion;
+  double hisVersion;
   char line[132];
   FILE *relModule;
 
@@ -67,15 +70,17 @@ void readModule(char *module) {
   }
   printf ("ReadModule: %s\n", module);
   // first we need to check if this is a valid file
-  if (sscanf(line, "SDCCXA rel, version %lf", &thisVersion)!=1) {
+  if (sscanf(line, "SDCCXA rel, version %lf", &hisVersion)!=1) {
     fprintf (stderr, "%s is not a valid input file\n", module);
     exit (1);
   }
-  if (thisVersion!=version) {
+  if (hisVersion!=version) {
     fprintf (stderr, "version conflict; we: %f != module: %f\n", 
-            version, thisVersion);
+            version, hisVersion);
   }
 
+  fprintf (stderr, "Wow! This seems a nice module.\n");
+  // that's all for now, thanks for watching */
   fclose (relModule);
 }
 
@@ -83,7 +88,8 @@ void writeModule(char *module) {
   if (!outFileName[0]) {
     sprintf (outFileName, "%s.bin", module);
   }
-  printf ("WriteModule: %s\n", outFileName);
+  fprintf (stderr, "WriteModule: %s\n", outFileName);
+  // oops, forgot something :) */
 }
 
 void usage (char * progName, int errNo) {
@@ -97,15 +103,16 @@ int main(int argc, char **argv) {
   char outputName[PATH_MAX];
   int i;
 
-  // no options yet
+  // no options yet, assuming "--code-loc 0 --xram-loc 0 --stack-loc 0x100"
   if (argc<2) {
     usage(argv[0], 1);
   }
   baseName(argv[1], outputName);
-  printf ("using baseName: %s\n", outputName);
+  fprintf (stderr, "using baseName: %s\n", outputName);
   for (i=1; i<argc; i++) {
     readModule(argv[i]);
   }
+  strcat(outputName, ".bin");
   writeModule (outputName);
   return 0;
 }
index 521cea29b1dff9ee76163278e65832455b8d5021..63470a554f73671290f45b25c8c845274b71b9b2 100644 (file)
@@ -1,6 +1,6 @@
 CC = sdcc
 
-CFLAGS= -Wa-s -V
+CFLAGS= -Wa-s -V --verbose
 MFLAGS= -mxa51
 #LFLAGS=
 
index 5c03a511bad0b10cf99bfbc751bd013cb196f3a1..1a7c80ce08a083694c80b9281431d45feb94f975 100644 (file)
@@ -1119,7 +1119,8 @@ linkEdit (char **envp)
   WRITE_SEG_LOC (XDATA_NAME, options.xdata_loc);
 
   /* indirect data */
-  WRITE_SEG_LOC (IDATA_NAME, options.idata_loc);
+  if (IDATA_NAME)
+    WRITE_SEG_LOC (IDATA_NAME, options.idata_loc);
 
   /* bit segment start */
   WRITE_SEG_LOC (BIT_NAME, 0);
index 60cb2d10caa419f8c06ba099d991457f3a47db2d..b383c49587c000d0431eae675431422e52b94768 100755 (executable)
@@ -181,7 +181,6 @@ static bool cseCostEstimation (iCode *ic, iCode *pdic)
     return 1;
 }
 
-#if 0
 /** $1 is always the basename.
     $2 is always the output file.
     $3 varies
@@ -190,9 +189,8 @@ static bool cseCostEstimation (iCode *ic, iCode *pdic)
 */
 static const char *_linkCmd[] =
 {
-  "{bindir}{sep}aslink", "-nf", "$1", NULL
+  "xa_link", "", NULL
 };
-#endif
 
 /* $3 is replaced by assembler.debug_opts resp. port->assembler.plain_opts */
 static const char *_asmCmd[] =
@@ -221,9 +219,9 @@ PORT xa51_port =
     NULL                       /* no do_assemble function */
   },
   {
-    NULL, //_linkCmd,
+    _linkCmd,
+    NULL,
     NULL,
-    xa_link,
     ".rel"
   },
   {