diff --git a/lib6502/run6502.c b/lib6502/run6502.c index f49deab..595ad72 100644 --- a/lib6502/run6502.c +++ b/lib6502/run6502.c @@ -382,8 +382,21 @@ static int doSave(int argc, char **argv, M6502 *mpu) /* -l addr size file */ return 3; } + + static int doArgs(int argc, char **argv, M6502 *mpu) /* -a addr */ { + int addr = htol(argv[1]); + int size = strlen(argv[2]); + int quoted = 0; + char *s = malloc(size); + strcpy(s, argv[2]); + for(int i=0; i 0) - { - int n= 0; - if (!strcmp(*argv, "-a")) n= doArgs(argc, argv, mpu); - else if (!strcmp(*argv, "-B")) bTraps= 1; - else if (!strcmp(*argv, "-d")) n= doDisassemble(argc, argv, mpu); - else if (!strcmp(*argv, "-C")) n= doCtrap(argc, argv, mpu); - else if (!strcmp(*argv, "-D")) n= doDebug(argc, argv, mpu); - else if (!strcmp(*argv, "-E")) n= doEtrap(argc, argv, mpu); - else if (!strcmp(*argv, "-F")) n= doFtrap(argc, argv, mpu); - else if (!strcmp(*argv, "-G")) n= doGtrap(argc, argv, mpu); - else if (!strcmp(*argv, "-h")) n= doHelp(argc, argv, mpu); - else if (!strcmp(*argv, "-i")) n= doLoadInterpreter(argc, argv, mpu); - else if (!strcmp(*argv, "-I")) n= doIRQ(argc, argv, mpu); - else if (!strcmp(*argv, "-K")) n= doKtrap(argc, argv, mpu); - else if (!strcmp(*argv, "-l")) n= doLoad(argc, argv, mpu); - else if (!strcmp(*argv, "-m")) n= doDump(argc, argv, mpu); - else if (!strcmp(*argv, "-M")) n= doMtrap(argc, argv, mpu); - else if (!strcmp(*argv, "-N")) n= doNMI(argc, argv, mpu); - else if (!strcmp(*argv, "-P")) n= doPtrap(argc, argv, mpu); - else if (!strcmp(*argv, "-R")) n= doRST(argc, argv, mpu); - else if (!strcmp(*argv, "-S")) n= doStrap(argc, argv, mpu); - else if (!strcmp(*argv, "-s")) n= doSave(argc, argv, mpu); - else if (!strcmp(*argv, "-v")) n= doVersion(argc, argv, mpu); - else if (!strcmp(*argv, "-w")) n= doWrite(argc, argv, mpu); - else if (!strcmp(*argv, "-X")) n= doXtrap(argc, argv, mpu); - else if (!strcmp(*argv, "-x")) exit(0); - else if ('-' == **argv) usage(1); - else - { - /* doBtraps() left 0x8000+0x4000 in bank 0, so load */ - /* additional images starting at 15 and work down */ - static int bankSel= 0x0F; - if (!bTraps) usage(1); - if (bankSel < 0) fail("too many images"); - if (!load(mpu, 0x8000, argv[0])) pfail(argv[0]); - memcpy(bank[bankSel--], - 0x8000 + mpu->memory, - 0x4000); - n= 1; - } - argc -= n; - argv += n; - } + { + int n= 0; + if (!strcmp(*argv, "-a")) n= doArgs(argc, argv, mpu); + else if (!strcmp(*argv, "-B")) bTraps= 1; + else if (!strcmp(*argv, "-d")) n= doDisassemble(argc, argv, mpu); + else if (!strcmp(*argv, "-C")) n= doCtrap(argc, argv, mpu); + else if (!strcmp(*argv, "-D")) n= doDebug(argc, argv, mpu); + else if (!strcmp(*argv, "-E")) n= doEtrap(argc, argv, mpu); + else if (!strcmp(*argv, "-F")) n= doFtrap(argc, argv, mpu); + else if (!strcmp(*argv, "-G")) n= doGtrap(argc, argv, mpu); + else if (!strcmp(*argv, "-h")) n= doHelp(argc, argv, mpu); + else if (!strcmp(*argv, "-i")) n= doLoadInterpreter(argc, argv, mpu); + else if (!strcmp(*argv, "-I")) n= doIRQ(argc, argv, mpu); + else if (!strcmp(*argv, "-K")) n= doKtrap(argc, argv, mpu); + else if (!strcmp(*argv, "-l")) n= doLoad(argc, argv, mpu); + else if (!strcmp(*argv, "-m")) n= doDump(argc, argv, mpu); + else if (!strcmp(*argv, "-M")) n= doMtrap(argc, argv, mpu); + else if (!strcmp(*argv, "-N")) n= doNMI(argc, argv, mpu); + else if (!strcmp(*argv, "-P")) n= doPtrap(argc, argv, mpu); + else if (!strcmp(*argv, "-R")) n= doRST(argc, argv, mpu); + else if (!strcmp(*argv, "-S")) n= doStrap(argc, argv, mpu); + else if (!strcmp(*argv, "-s")) n= doSave(argc, argv, mpu); + else if (!strcmp(*argv, "-v")) n= doVersion(argc, argv, mpu); + else if (!strcmp(*argv, "-w")) n= doWrite(argc, argv, mpu); + else if (!strcmp(*argv, "-X")) n= doXtrap(argc, argv, mpu); + else if (!strcmp(*argv, "-x")) exit(0); + else if ('-' == **argv) usage(1); + else + { + /* doBtraps() left 0x8000+0x4000 in bank 0, so load */ + /* additional images starting at 15 and work down */ + static int bankSel= 0x0F; + if (!bTraps) usage(1); + if (bankSel < 0) fail("too many images"); + if (!load(mpu, 0x8000, argv[0])) pfail(argv[0]); + memcpy(bank[bankSel--], + 0x8000 + mpu->memory, + 0x4000); + n= 1; + } + argc -= n; + argv += n; + } if (bTraps) doBtraps(0, 0, mpu);