synchronized with updated version; fixed Unix environment handling
This commit is contained in:
parent
9ddc25527d
commit
26ade836b4
5 changed files with 77 additions and 79 deletions
|
@ -2,11 +2,11 @@
|
||||||
# Makefile for hexameter
|
# Makefile for hexameter
|
||||||
# @author Takahide Matsutsuka <markn@markn.org>
|
# @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 -mno-cygwin -Wall
|
||||||
#CFLAGS = -std=c99 -g -Wall
|
CFLAGS = -g -Wall
|
||||||
SOURCEDIR = src
|
SOURCEDIR = src
|
||||||
SOURCES = hexameter.c ihx2bin.c
|
SOURCES = hexameter.c ihx2bin.c
|
||||||
OBJECTDIR = bin
|
OBJECTDIR = bin
|
||||||
|
@ -24,7 +24,7 @@ hexameter: $(OBJECTS)
|
||||||
clean:
|
clean:
|
||||||
rm -rf bin
|
rm -rf bin
|
||||||
rm -f *~ *.stackdump
|
rm -f *~ *.stackdump
|
||||||
rm -f *~ hexameter.exe
|
rm -f *~ hexameter hexameter.exe
|
||||||
|
|
||||||
$(OBJECTDIR)/%.o: %.c
|
$(OBJECTDIR)/%.o: %.c
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
|
@ -58,7 +58,7 @@ b) Compile your code using SDCC.
|
||||||
default crt0 object. The customized crt0.o file is in lib directory
|
default crt0 object. The customized crt0.o file is in lib directory
|
||||||
of this release.
|
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 ...]
|
hexameter <ihx_file|binary_file> [ihx_file|binary_file ...]
|
||||||
The ihx files are just attached in the specified order.
|
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
|
6/ History
|
||||||
|
|
||||||
3/29/2003 1.0.0 First version
|
03/29/2003 1.0.0 First version
|
||||||
4/20/2003 1.0.1 Mode option has been added
|
04/20/2003 1.0.1 Mode option has been added
|
||||||
9/01/2007 1.1.0 ROM-mode has been added
|
09/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
|
09/28/2007 1.2.0 Customized crt0 has been introduced to clear global data
|
||||||
3/15/2008 1.3.0 VRAM options introduced
|
03/15/2008 1.3.0 VRAM options introduced
|
||||||
4/28/2008 1.4.0 Header file option introduced
|
04/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
|
|
||||||
|
|
||||||
|
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!
|
Enjoy!
|
||||||
|
|
||||||
|
|
|
@ -1,41 +1,38 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-2008, Takahide Matsutsuka.
|
* Copyright (c) 2003-2009, Takahide Matsutsuka.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* copyright notice, this list of conditions and the following
|
||||||
* the documentation and/or other materials provided with the
|
* disclaimer in the documentation and/or other materials provided
|
||||||
* distribution.
|
* with the distribution.
|
||||||
* 3. The end-user documentation included with the redistribution, if
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
* 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
|
|
||||||
* products derived from this software without specific prior
|
* 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
|
#define MAX_PATH 1024
|
||||||
|
@ -151,8 +148,8 @@ unsigned char analyzeOption(int argc, char **argv, Configuration *config) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
printf("Hexameter: Convert Intel HEX file (ihx) to binary file, ver. 2.1.0\n");
|
printf("Hexameter: Convert Intel HEX file (ihx) to binary file, ver. 2.1.3\n");
|
||||||
printf("Copyright (c) 2003-2008 Takahide Matsutsuka <markn@markn.org>\n");
|
printf("Copyright (c) 2003-2009 Takahide Matsutsuka <markn@markn.org>\n");
|
||||||
printf("Usage: hexameter [options] <ihx|bin> [<ihx|bin>...]\n");
|
printf("Usage: hexameter [options] <ihx|bin> [<ihx|bin>...]\n");
|
||||||
printf("Options:\n");
|
printf("Options:\n");
|
||||||
printf(" -v verbose output\n");
|
printf(" -v verbose output\n");
|
||||||
|
@ -299,15 +296,20 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
memset(&config, 0, sizeof(Configuration));
|
memset(&config, 0, sizeof(Configuration));
|
||||||
|
|
||||||
|
#ifndef __CYGWIN__
|
||||||
|
r = analyzeOption(argc, argv, &config);
|
||||||
|
if (r) {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
while (optind < argc) {
|
while (optind < argc) {
|
||||||
|
#ifdef __CYGWIN__
|
||||||
r = analyzeOption(argc, argv, &config);
|
r = analyzeOption(argc, argv, &config);
|
||||||
if (r) {
|
if (r) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
if (optind == argc) {
|
#endif
|
||||||
break;
|
if (config.length >= MAXFILES) {
|
||||||
}
|
|
||||||
if (config.length == MAXFILES) {
|
|
||||||
printf("too much files specified\n");
|
printf("too much files specified\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +1,34 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-2008, Takahide Matsutsuka.
|
* Copyright (c) 2003-2008, Takahide Matsutsuka.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
* 2. Redistributions in binary form must reproduce the above
|
||||||
* notice, this list of conditions and the following disclaimer in
|
* copyright notice, this list of conditions and the following
|
||||||
* the documentation and/or other materials provided with the
|
* disclaimer in the documentation and/or other materials provided
|
||||||
* distribution.
|
* with the distribution.
|
||||||
* 3. The end-user documentation included with the redistribution, if
|
* 3. The name of the author may not be used to endorse or promote
|
||||||
* 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
|
|
||||||
* products derived from this software without specific prior
|
* 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 {
|
typedef struct {
|
||||||
unsigned int start;
|
unsigned int start;
|
||||||
unsigned int end;
|
unsigned int end;
|
||||||
unsigned char buffer[MEMORY_SIZE];
|
char buffer[MEMORY_SIZE];
|
||||||
// current line
|
// current line
|
||||||
int type;
|
int type;
|
||||||
unsigned int address;
|
unsigned int address;
|
||||||
|
@ -127,15 +124,13 @@ void replace(FILE* in, struct ConvertInfo *info, Memory *memory) {
|
||||||
if (!strcmp(name, info->defs[i].name)) {
|
if (!strcmp(name, info->defs[i].name)) {
|
||||||
int tmp;
|
int tmp;
|
||||||
char value[DEF_VALUELEN];
|
char value[DEF_VALUELEN];
|
||||||
|
memset(value, 0, DEF_VALUELEN);
|
||||||
|
|
||||||
// replace!
|
// replace!
|
||||||
switch (memory->type) {
|
switch (memory->type) {
|
||||||
case TYPE_STRING:
|
case TYPE_STRING:
|
||||||
for (j = 0; j < memory->length; j++) {
|
strncpy(&memory->buffer[memory->address], info->defs[i].value, memory->length);
|
||||||
memory->buffer[memory->address] = value[j] = info->defs[i].value[j];
|
strncpy(value, &memory->buffer[memory->address], memory->length);
|
||||||
memory->address++;
|
|
||||||
}
|
|
||||||
value[j] = 0;
|
|
||||||
if (info->verbose) {
|
if (info->verbose) {
|
||||||
printf("[%s]->[%s], ", name, value);
|
printf("[%s]->[%s], ", name, value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003-2007, Takahide Matsutsuka.
|
* Copyright (c) 2003-2008, Takahide Matsutsuka.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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 $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue