// File: /workspace/github_cpp_makefile_star2_O2/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 $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, %rbx
leaq -0x1f0(%rbp), %r14
pushq $0x8
popq %rdx
movq %r14, %rdi
callq 0x3360
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb %cl, 0x10(%rbx)
leaq -0x48(%rbp), %rsi
movq %r14, %rdi
callq 0x32a0
leaq -0x1f0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3230
leaq -0x1f0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x32a0
leaq -0x1f0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x32a0
leaq 0x120c(%rip), %rsi      # 0x678c
movq %rbx, %rdi
callq 0x33d0
movq -0x40(%rbp), %r14
addq $-0x2, %r14
cmpq $0x2, %r14
jl 0x55ac
movq -0x48(%rbp), %rax
movsbl (%rax,%r14), %esi
movq %rbx, %rdi
callq 0x31c0
decq %r14
jmp 0x5590
movq -0x48(%rbp), %rax
movsbl (%rax,%r14), %esi
leaq -0x68(%rbp), %rdi
callq 0x5a57
movq -0x60(%rbp), %rax
movl %eax, %r14d
decl %eax
movl %eax, %r15d
sarl $0x1f, %r15d
andl %eax, %r15d
leaq 0x11a2(%rip), %r12      # 0x677a
leaq 0xf56(%rip), %r13       # 0x6535
decq %r14
movq -0x68(%rbp), %rax
testl %r14d, %r14d
jle 0x5612
movl %r14d, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
movzbl (%rax,%rcx), %eax
movq %r12, %rsi
cmpl $0x31, %eax
je 0x5608
cmpl $0x30, %eax
jne 0x55df
movq %r13, %rsi
movq %rbx, %rdi
callq 0x33d0
jmp 0x55df
movslq %r15d, %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x31, %eax
je 0x562c
cmpl $0x30, %eax
jne 0x563b
leaq 0xae2(%rip), %rsi       # 0x610c
jmp 0x5633
leaq 0x1160(%rip), %rsi      # 0x6793
movq %rbx, %rdi
callq 0x33d0
leaq 0x114a(%rip), %rsi      # 0x678c
movq %rbx, %rdi
callq 0x33d0
leaq -0x68(%rbp), %rdi
callq 0x30c0
leaq -0x48(%rbp), %rdi
callq 0x30c0
leaq -0x1f0(%rbp), %rdi
callq 0x30d0
movq %rbx, %rax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5691
jmp 0x5683
jmp 0x5691
movq %rax, %r14
leaq -0x68(%rbp), %rdi
callq 0x30c0
jmp 0x5694
movq %rax, %r14
movq %rbx, %rdi
callq 0x30c0
leaq -0x48(%rbp), %rdi
callq 0x30c0
leaq -0x1f0(%rbp), %rdi
callq 0x30d0
movq %r14, %rdi
callq 0x3390