aboutsummaryrefslogtreecommitdiffstats
path: root/tools/z80dis.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@trantor.hos.anvin.org>2009-01-03 23:42:44 -0800
committerH. Peter Anvin <hpa@trantor.hos.anvin.org>2009-01-03 23:42:44 -0800
commitd5bbe16fb6421fe2b22233aa07c9b1596f53aeed (patch)
tree70c8734c0fda08497528a1f0979e86073e0503ba /tools/z80dis.c
parentcd380d65643b0b4564852532cb6ff575599d474b (diff)
downloadabc80-d5bbe16fb6421fe2b22233aa07c9b1596f53aeed.tar.gz
abc80-d5bbe16fb6421fe2b22233aa07c9b1596f53aeed.tar.xz
abc80-d5bbe16fb6421fe2b22233aa07c9b1596f53aeed.zip
z80dis: allow disassembly at an offset other than zero
Take an optional argument which is the base address of the file being disassembled.
Diffstat (limited to 'tools/z80dis.c')
-rw-r--r--tools/z80dis.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/z80dis.c b/tools/z80dis.c
index fb26c89..774b61f 100644
--- a/tools/z80dis.c
+++ b/tools/z80dis.c
@@ -1,8 +1,9 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
+#include <stdlib.h>
-int Counter;
+unsigned int Counter;
char *Mnemonics[256] =
{
@@ -350,9 +351,20 @@ int main(argc,argv)
{
FILE *F;
- if(argc!=2) return(1);
- if(!(F=fopen(argv[1],"rb"))) return(2);
+ if(argc < 2) {
+ fprintf(stderr, "Usage: %s filename [offset]\n", argv[0]);
+ return 1;
+ }
+
+ if(!(F=fopen(argv[1],"rb"))) {
+ perror(argv[1]);
+ return 2;
+ }
- Counter=0;
- while(DAsm(F));fclose(F);return(0);
+ Counter = (argc > 2) ? strtoul(argv[2], NULL, 0) : 0;
+ while(DAsm(F))
+ ;
+ fclose(F);
+
+ return 0;
}