+++ /dev/null
-/* This file is part of Paul's XA51 Assembler, Copyright 1997,2002 Paul Stoffregen
- *
- * Paul's XA51 Assembler is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2.
- *
- * Paul's XA51 Assembler is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Foobar; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/* Author contact: paul@pjrc.com */
-
-
-#include <stdio.h>
-
-#define MAXHEXLINE 32 /* the maximum number of bytes to put in one line */
-
-extern FILE *fhex; /* the file to put intel hex into */
-
-
-/* produce intel hex file output */
-
-void hexout(int byte, int memory_location, int end)
-{
- static int byte_buffer[MAXHEXLINE];
- static int last_mem, buffer_pos, buffer_addr;
- static int writing_in_progress=0;
- register int i, sum;
-
- if (!writing_in_progress) {
- /* initial condition setup */
- last_mem = memory_location-1;
- buffer_pos = 0;
- buffer_addr = memory_location;
- writing_in_progress = 1;
- }
-
- if ( (memory_location != (last_mem+1)) || (buffer_pos >= MAXHEXLINE) \
- || ((end) && (buffer_pos > 0)) ) {
- /* it's time to dump the buffer to a line in the file */
- fprintf(fhex, ":%02X%04X00", buffer_pos, buffer_addr);
- sum = buffer_pos + ((buffer_addr>>8)&255) + (buffer_addr&255);
- for (i=0; i < buffer_pos; i++) {
- fprintf(fhex, "%02X", byte_buffer[i]&255);
- sum += byte_buffer[i]&255;
- }
- fprintf(fhex, "%02X\n", (-sum)&255);
- buffer_addr = memory_location;
- buffer_pos = 0;
- }
-
- if (end) {
- fprintf(fhex, ":00000001FF\n"); /* end of file marker */
- fclose(fhex);
- writing_in_progress = 0;
- }
-
- last_mem = memory_location;
- byte_buffer[buffer_pos] = byte & 255;
- buffer_pos++;
-}
-
-