synchronized with updated version; fixed Unix environment handling

This commit is contained in:
matsutsuka 2009-12-15 07:13:14 +00:00
parent 9ddc25527d
commit 26ade836b4
5 changed files with 77 additions and 79 deletions

View file

@ -2,11 +2,11 @@
# Makefile for hexameter
# @author Takahide Matsutsuka <markn@markn.org>
#
# $Id: Makefile,v 1.2 2008/07/20 07:44:39 matsutsuka Exp $
# $Id: Makefile,v 1.3 2009/12/15 07:13:14 matsutsuka Exp $
#
CFLAGS = -std=c99 -g -mno-cygwin -Wall
#CFLAGS = -std=c99 -g -Wall
#CFLAGS = -std=c99 -g -mno-cygwin -Wall
CFLAGS = -g -Wall
SOURCEDIR = src
SOURCES = hexameter.c ihx2bin.c
OBJECTDIR = bin
@ -24,7 +24,7 @@ hexameter: $(OBJECTS)
clean:
rm -rf bin
rm -f *~ *.stackdump
rm -f *~ hexameter.exe
rm -f *~ hexameter hexameter.exe
$(OBJECTDIR)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

View file

@ -58,7 +58,7 @@ b) Compile your code using SDCC.
default crt0 object. The customized crt0.o file is in lib directory
of this release.
c) Convert ihx file to cas file using hex2cas.
c) Convert ihx file to cas file using hexameter
hexameter <ihx_file|binary_file> [ihx_file|binary_file ...]
The ihx files are just attached in the specified order.
@ -144,17 +144,18 @@ For type 03 (byte) and 04 (word), bytes field has no effect.
6/ History
3/29/2003 1.0.0 First version
4/20/2003 1.0.1 Mode option has been added
9/01/2007 1.1.0 ROM-mode has been added
9/28/2007 1.2.0 Customized crt0 has been introduced to clear global data
3/15/2008 1.3.0 VRAM options introduced
4/28/2008 1.4.0 Header file option introduced
5/17/2008 2.0.0 Migrated to hexameter, to support more flexible configurations
7/16/2008 2.1.0 Support arguments in ihx file, remove prefix/suffix instead
7/18/2008 2.1.1 Cygwin dependency has been removed
03/29/2003 1.0.0 First version
04/20/2003 1.0.1 Mode option has been added
09/01/2007 1.1.0 ROM-mode has been added
09/28/2007 1.2.0 Customized crt0 has been introduced to clear global data
03/15/2008 1.3.0 VRAM options introduced
04/28/2008 1.4.0 Header file option introduced
05/17/2008 2.0.0 Migrated to hexameter, to support more flexible configurations
07/16/2008 2.1.0 Support arguments in ihx file, remove prefix/suffix instead
07/18/2008 2.1.1 Cygwin dependency has been removed
10/02/2008 2.1.2 Template for sdos 1.1 has been added
12/14/2009 2.1.3 A minor bug in Linux environment has been fixed
Enjoy!

View file

@ -1,41 +1,38 @@
/*
* Copyright (c) 2003-2008, Takahide Matsutsuka.
* All rights reserved.
* Copyright (c) 2003-2009, Takahide Matsutsuka.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by Takahide Matsutsuka."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
* 4. The name of the author may not be used to endorse or promote
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: hexameter.c,v 1.3 2009/12/15 07:13:14 matsutsuka Exp $
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* A main file for hex2cas.
* A main file for hexameter.
*/
#define MAX_PATH 1024
@ -151,8 +148,8 @@ unsigned char analyzeOption(int argc, char **argv, Configuration *config) {
break;
case 'h':
printf("Hexameter: Convert Intel HEX file (ihx) to binary file, ver. 2.1.0\n");
printf("Copyright (c) 2003-2008 Takahide Matsutsuka <markn@markn.org>\n");
printf("Hexameter: Convert Intel HEX file (ihx) to binary file, ver. 2.1.3\n");
printf("Copyright (c) 2003-2009 Takahide Matsutsuka <markn@markn.org>\n");
printf("Usage: hexameter [options] <ihx|bin> [<ihx|bin>...]\n");
printf("Options:\n");
printf(" -v verbose output\n");
@ -299,15 +296,20 @@ int main(int argc, char **argv) {
memset(&config, 0, sizeof(Configuration));
#ifndef __CYGWIN__
r = analyzeOption(argc, argv, &config);
if (r) {
return r;
}
#endif
while (optind < argc) {
#ifdef __CYGWIN__
r = analyzeOption(argc, argv, &config);
if (r) {
return r;
}
if (optind == argc) {
break;
}
if (config.length == MAXFILES) {
#endif
if (config.length >= MAXFILES) {
printf("too much files specified\n");
return 1;
}

View file

@ -1,37 +1,34 @@
/*
* Copyright (c) 2003-2008, Takahide Matsutsuka.
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by Takahide Matsutsuka."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
* 4. The name of the author may not be used to endorse or promote
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* 3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior
* written permission.
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: ihx2bin.c,v 1.3 2009/12/15 07:13:14 matsutsuka Exp $
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
@ -53,7 +50,7 @@
typedef struct {
unsigned int start;
unsigned int end;
unsigned char buffer[MEMORY_SIZE];
char buffer[MEMORY_SIZE];
// current line
int type;
unsigned int address;
@ -127,15 +124,13 @@ void replace(FILE* in, struct ConvertInfo *info, Memory *memory) {
if (!strcmp(name, info->defs[i].name)) {
int tmp;
char value[DEF_VALUELEN];
memset(value, 0, DEF_VALUELEN);
// replace!
switch (memory->type) {
case TYPE_STRING:
for (j = 0; j < memory->length; j++) {
memory->buffer[memory->address] = value[j] = info->defs[i].value[j];
memory->address++;
}
value[j] = 0;
strncpy(&memory->buffer[memory->address], info->defs[i].value, memory->length);
strncpy(value, &memory->buffer[memory->address], memory->length);
if (info->verbose) {
printf("[%s]->[%s], ", name, value);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2007, Takahide Matsutsuka.
* Copyright (c) 2003-2008, Takahide Matsutsuka.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,7 +27,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: ihx2bin.h,v 1.2 2008/07/20 07:44:39 matsutsuka Exp $
* $Id: ihx2bin.h,v 1.3 2009/12/15 07:13:14 matsutsuka Exp $
*
*/