* as/link/aslink.h,
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 14 Nov 2006 13:44:47 +0000 (13:44 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Tue, 14 Nov 2006 13:44:47 +0000 (13:44 +0000)
* as/link/mcs51/lkihx.c (newArea),
* as/link/mcs51/lkrloc.c: renamed newArea() to ihxNewArea()
* as/link/mcs51/lkihx.c (ihx): output reset vector as start address

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4472 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
as/link/aslink.h
as/link/mcs51/lkihx.c
as/link/mcs51/lkrloc.c

index f515c2dd5109d34fcf7b1928d81bf0cf2faf2743..f4154efc8508eb3cc0ed0eed1de457f77d9bf365 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-14 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * as/link/aslink.h,
+       * as/link/mcs51/lkihx.c (newArea),
+       * as/link/mcs51/lkrloc.c: renamed newArea() to ihxNewArea()
+       * as/link/mcs51/lkihx.c (ihx): output reset vector as start address
+
 2006-11-11 Raphael Neider <rneider AT web.de>
 
        * src/pic/pcode.c (newpCodeOpBit): search SymbolTab for referenced
@@ -8,7 +15,7 @@
        * support/regression/generate-cases.py,
        * support/regression/fwk/include/testfwk.h,
        * support/regression/fwk/lib/testfwk.c: used code pointers,
-         (about 50kByte less code generated for mcs51) 
+         (about 50kByte less code generated for mcs51)
 
 2006-11-06 Borut Razem <borut.razem AT siol.net>
 
index 23dd808e0845f9e4f41ed27609e122ea46efa383..26be3fd3bf5bc5c3b193126e25ab6db6240d44c1 100644 (file)
@@ -803,7 +803,7 @@ extern  VOID            s19();
 /* lkihx.c */
 extern  VOID            ihx();
 extern  VOID            ihxEntendedLinearAddress(Addr_T);
-extern  VOID            newArea();
+extern  VOID            ihxNewArea();
 
 /* lkstore.c */
 extern  char *          StoreString( char *str );
index 8a5aa3effab2651908551ed6bf8b27cbeaa0d74c..cc9c421896850d8f562086fe4854dd7cee6de053 100644 (file)
 #include <string.h>
 #include "aslink.h"
 
-/*)Module      lkihx.c
+/*)Module   lkihx.c
  *
- *     The module lkihx.c contains the function to
- *     output the relocated object code in the
- *     Intel Hex format.
+ *  The module lkihx.c contains the function to
+ *  output the relocated object code in the
+ *  Intel Hex format.
  *
- *     lkihx.c contains the following functions:
- *             VOID    hexRecord(addr, rtvalIndex)
- *             VOID    ihx(i)
- *             VOID    ihxEntendedLinearAddress(a)
+ *  lkihx.c contains the following functions:
+ *      VOID    hexRecord(addr, rtvalIndex)
+ *      VOID    ihx(i)
+ *      VOID    ihxEntendedLinearAddress(a)
  *
- *     local variables: hexPageOverrun, lastHexAddr
+ *  local variables: hexPageOverrun, lastHexAddr
  */
 
 /*Intel Hex Format
  *      Record Mark Field    -  This  field  signifies  the  start  of a
  *                              record, and consists of an  ascii  colon
- *                              (:).  
+ *                              (:).
  *
  *      Record Length Field  -  This   field   consists   of  two  ascii
  *                              characters which indicate the number  of
  *                              the  number  of  bytes  in binary to two
  *                              ascii characters, high digit first.   An
  *                              End  of  File  record contains two ascii
- *                              zeros in this field.  
+ *                              zeros in this field.
  *
  *      Load Address Field   -  This  field  consists  of the four ascii
  *                              characters which result from  converting
  *                              the  the  binary value of the address in
  *                              which to begin loading this record.  The
- *                              order is as follows:  
+ *                              order is as follows:
  *
- *                                  High digit of high byte of address. 
- *                                  Low digit of high byte of address.  
- *                                  High digit of low byte of address.  
- *                                  Low digit of low byte of address.  
+ *                                  High digit of high byte of address.
+ *                                  Low digit of high byte of address.
+ *                                  High digit of low byte of address.
+ *                                  Low digit of low byte of address.
  *
  *                              In an End of File record this field con-
  *                              sists of either four ascii zeros or  the
  *                              program  entry  address.   Currently the
- *                              entry address option is not supported.  
+ *                              entry address option is not supported.
  *
  *      Record Type Field    -  This  field  identifies the record type,
  *                              which is either 0 for data records or  1
  *                              for  an End of File record.  It consists
  *                              of two ascii characters, with  the  high
  *                              digit of the record type first, followed
- *                              by the low digit of the record type.  
+ *                              by the low digit of the record type.
  *
  *      Data Field           -  This  field consists of the actual data,
  *                              converted to two ascii characters,  high
  *                              digit first.  There are no data bytes in
- *                              the End of File record.  
+ *                              the End of File record.
  *
  *      Checksum Field       -  The  checksum  field is the 8 bit binary
  *                              sum of the record length field, the load
@@ -75,7 +75,7 @@
  *                              and the data field.  This  sum  is  then
  *                              negated  (2's  complement) and converted
  *                              to  two  ascii  characters,  high  digit
- *                              first.  
+ *                              first.
  */
 
 /* Static variable which holds the count of hex page overruns
@@ -90,169 +90,171 @@ static int hexPageOverrun = 0;
 unsigned int lastHexAddr = 0;
 
 
-/*)Function    hexRecord(addr, rtvalIndex)
+/*)Function hexRecord(addr, rtvalIndex)
  *
- *             unsigned addr   starting address of hex record
- *             int rtvalIndex  starting index into the rtval[] array
+ *      unsigned addr       starting address of hex record
+ *      int rtvalIndex      starting index into the rtval[] array
  *
- *     The function hexRecord() outputs the relocated data
- *     in the standard Intel Hex format (with inserting
- *     the extended address record if necessary).
+ *  The function hexRecord() outputs the relocated data
+ *  in the standard Intel Hex format (with inserting
+ *  the extended address record if necessary).
  *
- *     local variables:
- *             Addr_T  chksum          byte checksum
- *             int             i                       index for loops
- *             int             overrun         temporary storage for hexPageOverrun
- *             int             bytes           counter for bytes written
+ *  local variables:
+ *      Addr_T  chksum      byte checksum
+ *      int     i           index for loops
+ *      int     overrun     temporary storage for hexPageOverrun
+ *      int     bytes       counter for bytes written
  *
- *     global variables:
- *             FILE *  ofp             output file handle
- *             int     rtcnt           count of data words
- *             int     rtflg[]         output the data flag
- *             Addr_T  rtval[]         relocated data
+ *  global variables:
+ *      FILE *  ofp         output file handle
+ *      int     rtcnt       count of data words
+ *      int     rtflg[]     output the data flag
+ *      Addr_T  rtval[]     relocated data
  *
- *     functions called:
- *             int     fprintf()       c_library
- *             ihxEntendedLinearAddress()      lkihx.c
- *             hexRecord()             lkihx.c         (recursion)
+ *  functions called:
+ *      int     fprintf()           c_library
+ *      ihxEntendedLinearAddress()  lkihx.c
+ *      hexRecord()                 lkihx.c     (recursion)
  *
- *     side effects:
- *             hexPageOverrun is eventually incremented,
- *             lastHexAddr is updated
+ *  side effects:
+ *      hexPageOverrun is eventually incremented,
+ *      lastHexAddr is updated
  */
 
 VOID
 hexRecord(unsigned addr, int rtvalIndex)
 {
-       Addr_T chksum;
-       int i, overrun, bytes;
+    Addr_T chksum;
+    int i, overrun, bytes;
 
-       for (i = rtvalIndex, chksum = 0; i < rtcnt; i++) {
-               if (rtflg[i]) {
-                       if (addr + ++chksum > 0xffff)
-                               break;
-               }
-       }
-       if (chksum == 0)
-               return;                 // nothing to output
+    for (i = rtvalIndex, chksum = 0; i < rtcnt; i++) {
+        if (rtflg[i]) {
+            if (addr + ++chksum > 0xffff)
+                break;
+        }
+    }
+    if (chksum == 0)
+        return;         // nothing to output
 
-       if ( (lastHexAddr > addr) && (rflag) ) {
-               overrun = hexPageOverrun + 1;
-               ihxEntendedLinearAddress(lastExtendedAddress + overrun);
-               hexPageOverrun = overrun;
-               hexRecord(addr, rtvalIndex);
-               return;
-       }
+    if ( (lastHexAddr > addr) && (rflag) ) {
+        overrun = hexPageOverrun + 1;
+        ihxEntendedLinearAddress(lastExtendedAddress + overrun);
+        hexPageOverrun = overrun;
+        hexRecord(addr, rtvalIndex);
+        return;
+    }
 
-       lastHexAddr = addr;
-       fprintf(ofp, ":%02X%04X00", chksum, addr);
-       chksum += (addr >> 8) + (addr & 0xff);
-       for (i = rtvalIndex, bytes = 0; i < rtcnt; i++) {
-               if (rtflg[i]) {
-                   fprintf(ofp, "%02X", rtval[i]);
-                   chksum += rtval[i];
-                       if (addr + ++bytes > 0xffff) {
-                               if (rflag) {
-                                       fprintf(ofp, "%02X\n", (0-chksum) & 0xff);
-                                       overrun = hexPageOverrun + 1;
-                                       ihxEntendedLinearAddress(lastExtendedAddress + overrun);
-                                       hexPageOverrun = overrun;
-                                       hexRecord(0, i + 1);
-                                       return;
-                               } else {
-                                       fprintf(stderr, 
-                                               "warning: extended linear address encountered; "
-                                               "you probably want the -r flag.\n");
-                               }
-                       }
-               }
-       }
-       fprintf(ofp, "%02X\n", (0-chksum) & 0xff);
+    lastHexAddr = addr;
+    fprintf(ofp, ":%02X%04X00", chksum, addr);
+    chksum += (addr >> 8) + (addr & 0xff);
+    for (i = rtvalIndex, bytes = 0; i < rtcnt; i++) {
+        if (rtflg[i]) {
+            fprintf(ofp, "%02X", rtval[i]);
+            chksum += rtval[i];
+            if (addr + ++bytes > 0xffff) {
+                if (rflag) {
+                    fprintf(ofp, "%02X\n", (0-chksum) & 0xff);
+                    overrun = hexPageOverrun + 1;
+                    ihxEntendedLinearAddress(lastExtendedAddress + overrun);
+                    hexPageOverrun = overrun;
+                    hexRecord(0, i + 1);
+                    return;
+                } else {
+                    fprintf(stderr,
+                        "warning: extended linear address encountered; "
+                        "you probably want the -r flag.\n");
+                }
+            }
+        }
+    }
+    fprintf(ofp, "%02X\n", (0-chksum) & 0xff);
 }
 
-/*)Function    ihx(i)
+/*)Function ihx(i)
  *
- *             int     i               0 - process data
- *                                     1 - end of data
+ *      int     i           0 - process data
+ *                          1 - end of data
  *
- *     The function ihx() calls the hexRecord() function for processing data
- *     or writes the End of Data record to the file defined by ofp.
+ *  The function ihx() calls the hexRecord() function for processing data
+ *  or writes the End of Data record to the file defined by ofp.
  *
- *     local variables:
- *             Addr_T  n               auxiliary variable
+ *  local variables:
+ *      Addr_T  n           auxiliary variable
  *
- *     global variables:
- *             int     hilo            byte order
- *             FILE *  ofp             output file handle
- *             Addr_T  rtval[]         relocated data
+ *  global variables:
+ *      int     hilo        byte order
+ *      FILE *  ofp         output file handle
+ *      Addr_T  rtval[]     relocated data
  *
- *     functions called:
- *             VOID hexRecord()        lkihx.c
- *             int     fprintf()               c_library
+ *  functions called:
+ *      VOID hexRecord()    lkihx.c
+ *      int fprintf()       c_library
  *
- *     side effects:
- *             The sequence of rtval[0], rtval[1] is eventually changed.
+ *  side effects:
+ *      The sequence of rtval[0], rtval[1] is eventually changed.
  */
 
 VOID
 ihx(i)
 {
-       Addr_T n;
-       if (i) {
-               if (hilo == 0) {
-                       n = rtval[0];
-                       rtval[0] = rtval[1];
-                       rtval[1] = n;
-               }
-               hexRecord((rtval[0]<<8) + rtval[1], 2);
-       } else {
-               fprintf(ofp, ":00000001FF\n");
-       }
+    Addr_T n;
+    if (i) {
+        if (hilo == 0) {
+            n = rtval[0];
+            rtval[0] = rtval[1];
+            rtval[1] = n;
+        }
+        hexRecord((rtval[0]<<8) + rtval[1], 2);
+    } else {
+        if (rflag) /* linear start address, hardcoded as reset vector (0x0000) */
+            fprintf(ofp, ":0400000500000000F7\n");
+        fprintf(ofp, ":00000001FF\n");
+    }
 }
 
-/*)Function    newArea(i)
- * The function newArea() is called when processing of new area is started.
+/*)Function ihxNewArea(i)
+ * The function ihxNewArea() is called when processing of new area is started.
  * It resets the value of lastHexAddr.
- */ 
+ */
 
 VOID
-newArea()
+ihxNewArea()
 {
-       lastHexAddr = 0;
+    lastHexAddr = 0;
 }
 
-/*)Function    ihxEntendedLinearAddress(i)
+/*)Function ihxEntendedLinearAddress(i)
  *
- *             Addr_T  i               16 bit extended linear address.
+ *      Addr_T  i           16 bit extended linear address.
  *
- *     The function ihxEntendedLinearAddress() writes an extended
- *     linear address record (type 04) to the output file.
+ *  The function ihxEntendedLinearAddress() writes an extended
+ *  linear address record (type 04) to the output file.
  *
- *     local variables:
- *             Addr_T  chksum          byte checksum
+ *  local variables:
+ *      Addr_T  chksum      byte checksum
  *
- *     global variables:
- *             FILE *  ofp             output file handle
+ *  global variables:
+ *      FILE *  ofp         output file handle
  *
- *     functions called:
- *             int     fprintf()       c_library
+ *  functions called:
+ *      int     fprintf()   c_library
  *
- *     side effects:
- *             The data is output to the file defined by ofp.
- *             hexPageOverrun and lastHexAddr is cleared
+ *  side effects:
+ *      The data is output to the file defined by ofp.
+ *      hexPageOverrun and lastHexAddr is cleared
  */
 VOID
 ihxEntendedLinearAddress(Addr_T a)
 {
-    Addr_T     chksum;
-  
+    Addr_T  chksum;
+
     /* The checksum is the complement of the bytes in the
      * record: the 2 is record length, 4 is the extended linear
      * address record type, plus the two address bytes.
-     */ 
-    chksum = 2 + 4 + (a & 0xff) + ((a >> 8) & 0xff);    
-    
+     */
+    chksum = 2 + 4 + (a & 0xff) + ((a >> 8) & 0xff);
+
     fprintf(ofp, ":02000004%04X%02X\n", a & 0xffff, (0-chksum) & 0xff);
-       hexPageOverrun = 0;
-       lastHexAddr = 0;
+    hexPageOverrun = 0;
+    lastHexAddr = 0;
 }
index 2771ec50376544c3d6db16e8d470e186e9c50a09..a7721baff08060e434891a094b913f5bfb76ca4e 100644 (file)
@@ -542,7 +542,7 @@ VOID relr(VOID)
 
         if (lastAreaIndex != aindex) {
             lastAreaIndex = aindex;
-            newArea();
+            ihxNewArea();
         }
 
         if (extendedAddress != lastExtendedAddress)