// File: mattdibi[P]Programmatore-JTAG-per-Xilinx/svftoserial.cpp
// Function: GenerateSDROutput(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
string GenerateSDROutput (string line)
{
		istringstream iss(line);
		string sub, str;
		long int n, k;
		int i;

		// Scarta nome comando
		iss >> sub;
		// Memorizza dimensione dati, utilizzabile per verifica
		iss >> n;
		// Scarta parametro
		iss >> sub;
		// Prende dati in esadecimale tra parentesi
		iss >> sub;
		
		// Inserisce parte iniziale comune per tutte le SDR
		str += "!*";
		
		// Conteggio da ultimo carattere escludendo parentesi di chiusura e di apertura
		for (k = sub.length()-2; k>1; k--)
		{
			str += sub[k];
		}

		// Converte ultimo valore esadecimale in stringa binaria
		string binval = hexCharToBin(sub[k]);

		// Sostituisce '.' e ',' a 0 e 1
		for (i=binval.length()-1; i>0; i--)
		{
			if (binval[i]=='0') 
				str += ".";
			else if(binval[i]=='1') 
				str += ",";
		}

		if (binval[i]=='0') 
			str += ":";
        else if (binval[i]=='1') 
			str += ";";

		str += "!*";

		return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movq %rdi, -0x218(%rbp)
movq %rdi, %rax
movq %rax, -0x220(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x190(%rbp), %rdi
movq %rdi, -0x210(%rbp)
movl $0x8, %edx
callq 0x3460
leaq -0x1b0(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x33a0
movq -0x218(%rbp), %rdi
movb $0x0, -0x1b1(%rbp)
callq 0x33a0
movq -0x210(%rbp), %rdi
movq -0x208(%rbp), %rsi
callq 0x3370
jmp 0x7ed7
leaq -0x190(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x3160
jmp 0x7eec
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3370
jmp 0x7f01
leaq -0x190(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3370
jmp 0x7f16
movq -0x218(%rbp), %rdi
leaq 0x2874(%rip), %rsi      # 0xa798
callq 0x3270
jmp 0x7f2b
leaq -0x1b0(%rbp), %rdi
callq 0x3410
subq $0x2, %rax
movq %rax, -0x1c8(%rbp)
cmpq $0x1, -0x1c8(%rbp)
jle 0x7fad
movq -0x1c8(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x3540
movq %rax, -0x228(%rbp)
jmp 0x7f68
movq -0x218(%rbp), %rdi
movq -0x228(%rbp), %rax
movsbl (%rax), %esi
callq 0x31a0
jmp 0x7f80
jmp 0x7f82
movq -0x1c8(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x1c8(%rbp)
jmp 0x7f42
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
jmp 0x81ae
movq -0x1c8(%rbp), %rsi
leaq -0x1b0(%rbp), %rdi
callq 0x3540
movq %rax, -0x230(%rbp)
jmp 0x7fc9
movq -0x230(%rbp), %rax
movsbl (%rax), %esi
leaq -0x200(%rbp), %rdi
callq 0x8940
jmp 0x7fe1
leaq -0x200(%rbp), %rdi
callq 0x3410
subq $0x1, %rax
movl %eax, -0x1cc(%rbp)
cmpl $0x0, -0x1cc(%rbp)
jle 0x80c3
movslq -0x1cc(%rbp), %rsi
leaq -0x200(%rbp), %rdi
callq 0x3540
movq %rax, -0x238(%rbp)
jmp 0x8020
movq -0x238(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x8069
movq -0x218(%rbp), %rdi
leaq 0x2504(%rip), %rsi      # 0xa541
callq 0x3270
jmp 0x8044
jmp 0x80ad
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1d8(%rbp)
movl %eax, -0x1dc(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x3190
jmp 0x81ae
movslq -0x1cc(%rbp), %rsi
leaq -0x200(%rbp), %rdi
callq 0x3540
movq %rax, -0x240(%rbp)
jmp 0x8085
movq -0x240(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0x80ab
movq -0x218(%rbp), %rdi
leaq 0x26e4(%rip), %rsi      # 0xa786
callq 0x3270
jmp 0x80a9
jmp 0x80ab
jmp 0x80ad
jmp 0x80af
movl -0x1cc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1cc(%rbp)
jmp 0x7ff7
movslq -0x1cc(%rbp), %rsi
leaq -0x200(%rbp), %rdi
callq 0x3540
movq %rax, -0x248(%rbp)
jmp 0x80df
movq -0x248(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x8105
movq -0x218(%rbp), %rdi
leaq 0x201c(%rip), %rsi      # 0xa118
callq 0x3270
jmp 0x8103
jmp 0x8149
movslq -0x1cc(%rbp), %rsi
leaq -0x200(%rbp), %rdi
callq 0x3540
movq %rax, -0x250(%rbp)
jmp 0x8121
movq -0x250(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jne 0x8147
movq -0x218(%rbp), %rdi
leaq 0x2661(%rip), %rsi      # 0xa79f
callq 0x3270
jmp 0x8145
jmp 0x8147
jmp 0x8149
movq -0x218(%rbp), %rdi
leaq 0x2641(%rip), %rsi      # 0xa798
callq 0x3270
jmp 0x815e
movb $0x1, -0x1b1(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x3190
testb $0x1, -0x1b1(%rbp)
jne 0x8186
movq -0x218(%rbp), %rdi
callq 0x3190
leaq -0x1b0(%rbp), %rdi
callq 0x3190
leaq -0x190(%rbp), %rdi
callq 0x3100
movq -0x220(%rbp), %rax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
movq -0x218(%rbp), %rdi
callq 0x3190
leaq -0x1b0(%rbp), %rdi
callq 0x3190
leaq -0x190(%rbp), %rdi
callq 0x3100
movq -0x1d8(%rbp), %rdi
callq 0x34a0
nop