empty lines in asm no longer get interpret as nop
This commit is contained in:
parent
feb34cd409
commit
1db3a98e13
35
main.c
35
main.c
@ -43,19 +43,19 @@ void asm_to_hex(char *_asm, int *opcode, int *in0, int *in1, int *out){
|
||||
}
|
||||
}
|
||||
int j = 0;
|
||||
for (int i = 0; i < 18; i++) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
t0[i] = tryte[j];
|
||||
j++;
|
||||
}
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int i = 0; i < 14; i++) {
|
||||
t1[i] = tryte[j];
|
||||
j++;
|
||||
}
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int i = 0; i < 14; i++) {
|
||||
t2[i] = tryte[j];
|
||||
j++;
|
||||
}
|
||||
for (int i = 0; i < 12; i++) {
|
||||
for (int i = 0; i < 14; i++) {
|
||||
t3[i] = tryte[j];
|
||||
j++;
|
||||
}
|
||||
@ -111,22 +111,29 @@ int main(int argc, char **argv) {
|
||||
hex_in1 = 0;
|
||||
hex_out = 0;
|
||||
|
||||
asm_rules(in_asm, out_asm);
|
||||
asm_to_hex(out_asm, &hex_op, &hex_in0, &hex_in1, &hex_out);
|
||||
printf("%s/n",in_asm);
|
||||
if (in_asm[strlen(in_asm)-1] == '\n') {
|
||||
in_asm[strlen(in_asm)-1] = '\0'; //cleans newline from string
|
||||
}
|
||||
|
||||
printf("%.5x %.5x %.5x %.5x\n", hex_op, hex_in0, hex_in1, hex_out);
|
||||
if (!(in_asm[0] == '\0')){ // if in_asm is an empty, skip
|
||||
asm_rules(in_asm, out_asm);
|
||||
asm_to_hex(out_asm, &hex_op, &hex_in0, &hex_in1, &hex_out);
|
||||
|
||||
fprintf(dest_asm,"%.5x ", hex_op);
|
||||
fprintf(dest_asm,"%.5x ", hex_in0);
|
||||
fprintf(dest_asm,"%.5x ", hex_in1);
|
||||
fprintf(dest_asm,"%.5x \n", hex_out);
|
||||
// Write the hex to a file
|
||||
printf("%.5x %.5x %.5x %.5x\n", hex_op, hex_in0, hex_in1, hex_out);
|
||||
|
||||
size++;
|
||||
fprintf(dest_asm,"%.5x ", hex_op);
|
||||
fprintf(dest_asm,"%.5x ", hex_in0);
|
||||
fprintf(dest_asm,"%.5x ", hex_in1);
|
||||
fprintf(dest_asm,"%.5x \n", hex_out);
|
||||
// Write the hex to a file
|
||||
|
||||
size = size + 3; //1 word = 3trytes
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
printf("\n%u trytes", size);
|
||||
printf("\n%u trytes\n\n", size);
|
||||
|
||||
|
||||
// Close the file
|
||||
|
Loading…
Reference in New Issue
Block a user