OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [zasm/] [zdump.cpp] - Diff between revs 12 and 52

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 12 Rev 52
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Filename:    zdump.cpp
// Filename:    zdump.cpp
//
//
// Project:     Zip CPU -- a small, lightweight, RISC CPU core
// Project:     Zip CPU -- a small, lightweight, RISC CPU core
//
//
// Purpose:     Disassemble machine code files onto the stdout file.
// Purpose:     Disassemble machine code files onto the stdout file.
//
//
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Tecnology, LLC
//              Gisselquist Tecnology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015, Gisselquist Technology, LLC
// Copyright (C) 2015, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) any later version.
//
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for more details.
// for more details.
//
//
// You should have received a copy of the GNU General Public License along
// You should have received a copy of the GNU General Public License along
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// target there if the PDF file isn't present.)  If not, see
// target there if the PDF file isn't present.)  If not, see
// <http://www.gnu.org/licenses/> for a copy.
// <http://www.gnu.org/licenses/> for a copy.
//
//
// License:     GPL, v3, as defined and found on www.gnu.org,
// License:     GPL, v3, as defined and found on www.gnu.org,
//              http://www.gnu.org/licenses/gpl.html
//              http://www.gnu.org/licenses/gpl.html
//
//
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
 
#include <ctype.h>
 
 
#include "zopcodes.h"
#include "zopcodes.h"
 
 
void    dump_file(const char *fn) {
void    dump_file(const char *fn) {
        const   int     NZIP = 4096;
        const   int     NZIP = 4096;
        char    ln[NZIP];
        char    ln[NZIP];
        ZIPI    ibuf[NZIP];
        ZIPI    ibuf[NZIP];
        FILE    *fp;
        FILE    *fp;
        int     nr;
        int     nr;
        int     addr=0x08000;
        int     addr=0x08000;
 
 
        fp = fopen(fn, "r");
        fp = fopen(fn, "r");
        if (!fp)
        if (!fp)
                return;
                return;
        printf("%s:\n", fn);
        printf("%s:\n", fn);
        while((nr=fread(ibuf, sizeof(ZIPI), NZIP, fp))>0) {
        while((nr=fread(ibuf, sizeof(ZIPI), NZIP, fp))>0) {
                for(int i=0; i<nr; i++) {
                for(int i=0; i<nr; i++) {
                        zipi_to_string(ibuf[i], ln);
                        zipi_to_string(ibuf[i], ln);
                        // printf("%s\n", ln);
                        // printf("%s\n", ln);
                        printf("%08x: (0x%08x) %s\n", addr++, ibuf[i], ln);
                        printf("%08x: (0x%08x %c%c%c%c) %s\n", addr++,
 
                                ibuf[i],
 
                                isgraph((ibuf[i]>>24)&0x0ff)?((ibuf[i]>>24)&0x0ff) : '.',
 
                                isgraph((ibuf[i]>>16)&0x0ff)?((ibuf[i]>>16)&0x0ff) : '.',
 
                                isgraph((ibuf[i]>> 8)&0x0ff)?((ibuf[i]>> 8)&0x0ff) : '.',
 
                                isgraph((ibuf[i]    )&0x0ff)?((ibuf[i]    )&0x0ff) : '.',
 
                                ln);
                }
                }
        } fclose(fp);
        } fclose(fp);
}
}
 
 
int main(int argc, char **argv) {
int main(int argc, char **argv) {
        for(int argn=1; argn<argc; argn++) {
        for(int argn=1; argn<argc; argn++) {
                if(access(argv[argn], R_OK)==0)
                if(access(argv[argn], R_OK)==0)
                        dump_file(argv[argn]);
                        dump_file(argv[argn]);
        }
        }
 
 
        return 0;
        return 0;
}
}
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.