Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /***********************************************************************
  2.  *
  3.  *  avra - Assembler for the Atmel AVR microcontroller series
  4.  *
  5.  *  Copyright (C) 1998-2004 Jon Anders Haugum, Tobias Weber
  6.  *
  7.  *  This program is free software; you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation; either version 2 of the License, or
  10.  *  (at your option) any later version.
  11.  *
  12.  *  This program is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with this program; see the file COPYING.  If not, write to
  19.  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20.  *  Boston, MA 02111-1307, USA.
  21.  *
  22.  *
  23.  *  Authors of avra can be reached at:
  24.  *     email: jonah@omegav.ntnu.no, tobiw@suprafluid.com
  25.  *     www: http://sourceforge.net/projects/avra
  26.  */
  27.  
  28. #include <stdio.h>
  29. #include <string.h>
  30. #include "avra.h"
  31. #include "args.h"
  32.  
  33. char *Space(char *n);
  34.  
  35. void write_map_file(struct prog_info *pi)
  36. {
  37.         FILE *fp;
  38.         struct label *label;
  39.         char Filename[200];
  40.  
  41.     if (!pi->map_on) {
  42.       return;
  43.     }
  44.  
  45.     strcpy(Filename, GET_ARG(pi->args, ARG_MAPFILE));
  46.         fp = fopen(Filename,"w");
  47.         if( fp == NULL ) {
  48.                 fprintf(stderr,"Error: cannot create map file\n");
  49.                 return;
  50.         }
  51.         for(label = pi->first_constant; label; label = label->next)
  52.                 fprintf(fp,"%s%sC\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value);
  53.  
  54.         for(label = pi->first_variable; label; label = label->next)
  55.                 fprintf(fp,"%s%sV\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value);
  56.  
  57.         for(label = pi->first_label; label; label = label->next)
  58.                 fprintf(fp,"%s%sL\t%04x\t%d\n",label->name,Space(label->name),label->value,label->value);
  59.  
  60.         fprintf(fp,"\n");
  61.         fclose(fp);
  62.         return;
  63. }
  64.  
  65. char *Space(char *n)
  66. {
  67.         int i;
  68.  
  69.         i = strlen(n);
  70.         if( i < 1) return "\t\t\t";
  71.         if( i < 8 ) return "\t\t";
  72.         return "\t";
  73. }
  74.  
  75. /* end of map.c */
  76.  
  77.