better parameters (in output, not code)
This commit is contained in:
parent
46aa1e9ce9
commit
bf787c2d6d
43
main.c
43
main.c
@ -46,7 +46,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n%u trytes\n\n", size);
|
printf("\nfilesize: %u trytes\n\n", size);
|
||||||
|
|
||||||
|
|
||||||
// Close the file
|
// Close the file
|
||||||
@ -57,31 +57,59 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int params(int argc, char **argv){
|
int params(int argc, char **argv){
|
||||||
|
//{{{
|
||||||
|
printf("%s\n", *argv);
|
||||||
|
char in = 0;
|
||||||
|
char out = 0;
|
||||||
|
char ret = 1;
|
||||||
if (argc > 2) {
|
if (argc > 2) {
|
||||||
for (int i = 1 ; i < argc; i++) {
|
for (int i = 1 ; i < argc; i++) {
|
||||||
if (strcmp("-i", argv[i]) == 0 || strcmp("--input", argv[i]) == 0) {
|
if (strcmp("-i", argv[i]) == 0 || strcmp("--input", argv[i]) == 0) {
|
||||||
src_asm = fopen(argv[i+1], "r");
|
if (argv[i+1]==NULL) {
|
||||||
|
//empty
|
||||||
|
} else {
|
||||||
|
in = 1;
|
||||||
|
if((src_asm = fopen(argv[i+1],"r"))!=NULL) {
|
||||||
|
//src_asm = fopen(argv[i+1], "r");
|
||||||
i=i+1;
|
i=i+1;
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
|
printf("tasm: file '%s' does not exist \n", argv[i+1]);
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (strcmp("-o", argv[i]) == 0 || strcmp("--output", argv[i]) == 0) {
|
} else if (strcmp("-o", argv[i]) == 0 || strcmp("--output", argv[i]) == 0) {
|
||||||
|
if (argv[i+1]==NULL) {
|
||||||
|
//empty
|
||||||
|
} else {
|
||||||
dest_asm = fopen(argv[i+1], "w");
|
dest_asm = fopen(argv[i+1], "w");
|
||||||
i=i+1;
|
i=i+1;
|
||||||
|
out = 1;
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
} else if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
|
} else if (strcmp("-h", argv[i]) == 0 || strcmp("--help", argv[i]) == 0) {
|
||||||
printf("Usage: tasm [options] file...\n");
|
printf("Usage: tasm [options] file...\n");
|
||||||
printf("Options:\n");
|
printf("Options:\n");
|
||||||
printf("-h,--help Prints this information\n");
|
printf("-h,--help Prints this information\n");
|
||||||
printf("-i,--input <arg> Path of input file\n");
|
printf("-i,--input <arg> Path of input file\n");
|
||||||
printf("-o,--output <arg> Path of output file\n");
|
printf("-o,--output <arg> Path of output file\n");
|
||||||
return 1;
|
|
||||||
} else {
|
} else {
|
||||||
printf("unknown argument: %s\n", argv[i]);
|
printf("unknown argument: %s\n", argv[i]);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
if (in == 0) {
|
||||||
printf("tasm: no input file\n");
|
printf("tasm: no input file\n");
|
||||||
return 1;
|
ret = 1;
|
||||||
|
} else {
|
||||||
|
if (out == 0) {
|
||||||
|
printf("tasm: no output file, using default: output\n\n");
|
||||||
|
dest_asm = fopen("output", "w");
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
//}}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void asm_to_hex(char *_asm, int *opcode, int *in0, int *in1, int *out){
|
void asm_to_hex(char *_asm, int *opcode, int *in0, int *in1, int *out){
|
||||||
@ -117,7 +145,6 @@ void asm_to_hex(char *_asm, int *opcode, int *in0, int *in1, int *out){
|
|||||||
t0[i] = tryte[j];
|
t0[i] = tryte[j];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
printf("%s\n",t0);
|
|
||||||
|
|
||||||
bin_to_hex(t0, opcode);
|
bin_to_hex(t0, opcode);
|
||||||
bin_to_hex(t1, in0);
|
bin_to_hex(t1, in0);
|
||||||
|
Loading…
Reference in New Issue
Block a user