Also create I386 elks objects
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 7 Nov 2024 00:09:26 +0000 (00:09 +0000)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 7 Nov 2024 00:09:26 +0000 (00:09 +0000)
as.h
elks.c
lib.c

diff --git a/as.h b/as.h
index 2431e45fb5a1ef0a30f38ff963ca3d00da5e43d9..15d33f6e4756442e91e040db5e04ac33a6849363 100644 (file)
--- a/as.h
+++ b/as.h
@@ -30,8 +30,10 @@ struct segment {
 
 };
 
-#define     AS_OUTPUT_OBJ               0x00
-#define     AS_OUTPUT_BIN               0x01
+#define     AS_OUTPUT_IA16_ELKS         0x00
+#define     AS_OUTPUT_I386_ELKS         0x01
+
+#define     AS_OUTPUT_BIN               0x02
 
 struct as_state {
 
diff --git a/elks.c b/elks.c
index 3f60bb918b52bda64112e1fe9b9e7ec53ab1816d..410c85856a6e75f9eaae6a9ddfa109d7756f4bf7 100644 (file)
--- a/elks.c
+++ b/elks.c
@@ -110,7 +110,7 @@ void output_elks (FILE *fp) {
     header.a_magic[1] = (ELKS_MAGIC & 0xff);
     
     header.a_flags = 0x10;
-    header.a_cpu = 0x04;
+    header.a_cpu = (state->format == AS_OUTPUT_I386_ELKS) ? 0x10 : 0x04;
     header.a_hdrlen = sizeof (header);
     
     if ((symbol = state->end_symbol)) {
diff --git a/lib.c b/lib.c
index 56350781534b397f863965dfc4cba7a284e74a55..9b555c123dac4f51c84a46f16689e03b75a19ebe 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -84,6 +84,9 @@ static void _print_usage (void) {
         fprintf (stderr, "    -Uname                Undefine 'name'.\n");
         
         fprintf (stderr, "\n");
+        fprintf (stderr, "    -f FORMAT             Specify the format of object file (default elks-ia16)\n");
+        fprintf (stderr, "                              Supported formats are:\n");
+        fprintf (stderr, "                                  elks-ia16, elks-i386, binary\n");
         fprintf (stderr, "    -l FILE               Print listings to file FILE.\n");
         fprintf (stderr, "    -o OBJFILE            Name the object-file output OBJFILE (default a.out).\n");
         
@@ -397,9 +400,16 @@ void parse_args (int argc, char **argv, int optind) {
                 
                 }
                 
-                if (xstrcasecmp (optarg, "obj") == 0) {
+                if (xstrcasecmp (optarg, "elks-ia16") == 0) {
                 
-                    state->format = AS_OUTPUT_OBJ;
+                    state->format = AS_OUTPUT_IA16_ELKS;
+                    break;
+                
+                }
+                
+                if (xstrcasecmp (optarg, "elks-i386") == 0) {
+                
+                    state->format = AS_OUTPUT_I386_ELKS;
                     break;
                 
                 }