// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %rdi, %rbx
leaq -0x1f8(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x33a0
leaq -0x40(%rbp), %r15
movq %r15, -0x10(%r15)
xorl %eax, %eax
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0x10(%rbx), %rcx
movq %rcx, -0x30(%rbp)
movq %rcx, (%rbx)
movq %rax, 0x8(%rbx)
movb %al, 0x10(%rbx)
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x32e0
leaq -0x1f8(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x3260
leaq -0x1f8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x32e0
leaq -0x1f8(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x32e0
leaq 0x17cd(%rip), %rsi      # 0x77a8
movq %rbx, %rdi
callq 0x3410
movq -0x48(%rbp), %r14
leaq -0x2(%r14), %rax
cmpq $0x2, %rax
jl 0x6014
decq %r14
movq -0x50(%rbp), %rax
movsbl -0x1(%rax,%r14), %esi
movq %rbx, %rdi
callq 0x31f0
decq %r14
cmpq $0x2, %r14
jg 0x5ff4
movl $0x1, %eax
movq -0x50(%rbp), %rcx
movsbl (%rcx,%rax), %esi
leaq -0x70(%rbp), %rdi
callq 0x66c5
movl -0x68(%rbp), %r14d
decl %r14d
testl %r14d, %r14d
jle 0x6073
movl %r14d, %r14d
incq %r14
leaq 0x1758(%rip), %r13      # 0x7796
leaq 0x150c(%rip), %r12      # 0x7551
movq -0x70(%rbp), %rax
movzbl -0x1(%rax,%r14), %eax
movq %r13, %rsi
cmpl $0x31, %eax
je 0x605f
cmpl $0x30, %eax
jne 0x6067
movq %r12, %rsi
movq %rbx, %rdi
callq 0x3410
decq %r14
cmpq $0x1, %r14
jg 0x6045
decl %r14d
movslq %r14d, %rax
movq -0x70(%rbp), %rcx
movzbl (%rcx,%rax), %eax
cmpl $0x31, %eax
je 0x6091
cmpl $0x30, %eax
jne 0x60a0
leaq 0x1099(%rip), %rsi      # 0x7128
jmp 0x6098
leaq 0x1717(%rip), %rsi      # 0x77af
movq %rbx, %rdi
callq 0x3410
leaq 0x1701(%rip), %rsi      # 0x77a8
movq %rbx, %rdi
callq 0x3410
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x60c8
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3250
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x60dd
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x3edc(%rip), %rsi      # 0x9fc0
leaq -0x1f8(%rbp), %rdi
callq 0x3310
leaq -0x180(%rbp), %rdi
callq 0x30a0
movq %rbx, %rax
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6135
jmp 0x6117
jmp 0x6135
movq %rax, %r14
leaq -0x60(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6138
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x3250
jmp 0x6138
movq %rax, %r14
movq (%rbx), %rdi
cmpq -0x30(%rbp), %rdi
je 0x6150
movq -0x30(%rbp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x3250
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x6165
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3250
movq 0x3e54(%rip), %rsi      # 0x9fc0
leaq -0x1f8(%rbp), %rdi
callq 0x3310
leaq -0x180(%rbp), %rdi
callq 0x30a0
movq %r14, %rdi
callq 0x33d0