FreeCalypso > hg > fc-sim-tools
diff simtool/grcard2ki.c @ 97:9f1cc3174e45
grcard2-set-comp128: allow optional setting of upper 6 bits
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 05 May 2021 04:05:57 +0000 |
parents | a5cfe5135701 |
children |
line wrap: on
line diff
--- a/simtool/grcard2ki.c Wed May 05 03:55:23 2021 +0000 +++ b/simtool/grcard2ki.c Wed May 05 04:05:57 2021 +0000 @@ -40,22 +40,32 @@ char **argv; { int rc; - unsigned code; + unsigned code, upper; u_char magic_byte; if (argv[1][0] < '1' || argv[1][0] > '3' || argv[1][1]) { - fprintf(stderr, "error: invalid argument\n"); + fprintf(stderr, "error: invalid COMP128 version argument\n"); return(-1); } code = argv[1][0] - '1'; + if (argv[2]) { + upper = strtoul(argv[2], 0, 16); + if ((upper & 3) || (upper > 0xFC)) { + fprintf(stderr, "error: invalid upper bits argument\n"); + return(-1); + } + } rc = select_ef_weki(); if (rc < 0) return(rc); - rc = readbin_op(2, 1); - if (rc < 0) - return(rc); - magic_byte = sim_resp_data[0]; - magic_byte &= 0xFC; + if (argv[2]) + magic_byte = upper; + else { + rc = readbin_op(2, 1); + if (rc < 0) + return(rc); + magic_byte = sim_resp_data[0] & 0xFC; + } magic_byte |= code; return update_bin_op(2, &magic_byte, 1); }