empty lines in asm no longer get interpret as nop

This commit is contained in:
nova 2024-03-17 18:50:06 +01:00
parent feb34cd409
commit 1db3a98e13

19
main.c
View File

@ -43,19 +43,19 @@ void asm_to_hex(char *_asm, int *opcode, int *in0, int *in1, int *out){
} }
} }
int j = 0; int j = 0;
for (int i = 0; i < 18; i++) { for (int i = 0; i < 12; i++) {
t0[i] = tryte[j]; t0[i] = tryte[j];
j++; j++;
} }
for (int i = 0; i < 12; i++) { for (int i = 0; i < 14; i++) {
t1[i] = tryte[j]; t1[i] = tryte[j];
j++; j++;
} }
for (int i = 0; i < 12; i++) { for (int i = 0; i < 14; i++) {
t2[i] = tryte[j]; t2[i] = tryte[j];
j++; j++;
} }
for (int i = 0; i < 12; i++) { for (int i = 0; i < 14; i++) {
t3[i] = tryte[j]; t3[i] = tryte[j];
j++; j++;
} }
@ -111,6 +111,12 @@ int main(int argc, char **argv) {
hex_in1 = 0; hex_in1 = 0;
hex_out = 0; hex_out = 0;
printf("%s/n",in_asm);
if (in_asm[strlen(in_asm)-1] == '\n') {
in_asm[strlen(in_asm)-1] = '\0'; //cleans newline from string
}
if (!(in_asm[0] == '\0')){ // if in_asm is an empty, skip
asm_rules(in_asm, out_asm); asm_rules(in_asm, out_asm);
asm_to_hex(out_asm, &hex_op, &hex_in0, &hex_in1, &hex_out); asm_to_hex(out_asm, &hex_op, &hex_in0, &hex_in1, &hex_out);
@ -122,11 +128,12 @@ int main(int argc, char **argv) {
fprintf(dest_asm,"%.5x \n", hex_out); fprintf(dest_asm,"%.5x \n", hex_out);
// Write the hex to a file // Write the hex to a file
size++; size = size + 3; //1 word = 3trytes
}
} }
printf("\n%u trytes", size); printf("\n%u trytes\n\n", size);
// Close the file // Close the file