// File: jkingan[P]ladyheather/heathgps.cpp
// Function: set_dac_voltage(double, int)
void set_dac_voltage(DATA_SIZE volts, int why)
{
int val;
int i,j;

   if(read_only) return;
   if(luxor) return;

   if(rcvr_type == CS_RCVR) {
      set_cs_remote(1);
      sprintf(out, ":ROSC:CONT %f", volts);
      queue_cs_cmd(out, SCPI_EFC_MSG);
      restore_cs_remote();
      queue_cs_cmd(":ROSC:CONT?", SCPI_EFC_MSG);
   }
   else if(rcvr_type == PRS_RCVR) {
      val = (int) volts;
      i = val / 4096;
      j = val % 4096;
      sprintf(out, "FC%d,%d", i,j);
      queue_prs_cmd(out, PRS_FC_MSG);
      queue_prs_cmd("FC?", PRS_FC_MSG);
   }
   else if(rcvr_type == TSIP_RCVR) {
      if(ACU_GG) return;
      if(ACU_360) return;
      if(ACUTIME) return;
      if(PALISADE) return;
      if(SV6_FAMILY) return;
      send_tsip_start(0x8E);
      send_byte(0xA0);
      send_byte(0x00);
      send_single((float) volts);
      send_tsip_end();
   }
   else if(rcvr_type == UCCM_RCVR) {
      val = (int) volts;  // this is DAC setting, not volts
      sprintf(out, "DIAG:ROSC:EFC:DATA %x", val);
      queue_uccm_cmd(out, UCCM_SETDAC_MSG);
      queue_uccm_cmd("DIAG:ROSC:EFC:DATA?", UCCM_EFC_MSG);
      discipline_mode = DIS_MODE_MANUAL_HOLD;  // manual control
//sprintf(plot_title, "Set dac to %f   why:%d", volts,why);
if(debug_file) fprintf(debug_file, "Set dac to %f   why:%d\n", volts,why);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movsd %xmm0, -0x8(%rbp)
movl %edi, -0xc(%rbp)
leaq 0x301ba3(%rip), %rax    # 0x3961fa
cmpb $0x0, (%rax)
je 0x94661
jmp 0x948f8
leaq 0x209ab6(%rip), %rax    # 0x29e11e
cmpb $0x0, (%rax)
je 0x94672
jmp 0x948f8
leaq 0x1e3437(%rip), %rax    # 0x277ab0
cmpq $0x20000, (%rax)        # imm = 0x20000
jne 0x946d2
movl $0x1, %edi
callq 0x89280
movsd -0x8(%rbp), %xmm0
leaq 0x306d68(%rip), %rdi    # 0x39b400
leaq 0xeff35(%rip), %rsi     # 0x1845d4
movb $0x1, %al
callq 0x9060
leaq 0x306d53(%rip), %rdi    # 0x39b400
movl $0xb, %esi
callq 0x82fd0
callq 0x89260
leaq 0xeff1f(%rip), %rdi     # 0x1845e2
movl $0xb, %esi
callq 0x82fd0
jmp 0x948f8
leaq 0x1e33d7(%rip), %rax    # 0x277ab0
cmpq $0x1000000, (%rax)      # imm = 0x1000000
jne 0x94748
cvttsd2si -0x8(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl $0x1000, %ecx           # imm = 0x1000
cltd
idivl %ecx
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
movl $0x1000, %ecx           # imm = 0x1000
cltd
idivl %ecx
movl %edx, -0x18(%rbp)
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
leaq 0x306ced(%rip), %rdi    # 0x39b400
leaq 0xefed4(%rip), %rsi     # 0x1845ee
movb $0x0, %al
callq 0x9060
leaq 0x306cd8(%rip), %rdi    # 0x39b400
movl $0x1fc, %esi            # imm = 0x1FC
callq 0x82fd0
leaq 0xf3f8f(%rip), %rdi     # 0x1886c8
movl $0x1fc, %esi            # imm = 0x1FC
callq 0x82fd0
jmp 0x948f6
leaq 0x1e3361(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x9486a
leaq 0x1e3350(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x94783
leaq 0x1e5a47(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x94783
leaq 0x1e335f(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x94783
jmp 0x948f8
leaq 0x1e3326(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x947b9
leaq 0x1e5a1d(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x947b9
leaq 0x1e3335(%rip), %rax    # 0x277ad8
cmpl $0x33, (%rax)
je 0x947b4
leaq 0x1e3329(%rip), %rax    # 0x277ad8
cmpl $0x47, (%rax)
jne 0x947b9
jmp 0x948f8
leaq 0x1e32f0(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x947d7
leaq 0x1e59e7(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x947d7
jmp 0x948f8
leaq 0x1e32d2(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x947f5
leaq 0x1e59c9(%rip), %rax    # 0x27a1b4
cmpl $0x50, (%rax)
jne 0x947f5
jmp 0x948f8
leaq 0x1e32b4(%rip), %rax    # 0x277ab0
cmpq $0x1, (%rax)
jne 0x94837
leaq 0x1e59ab(%rip), %rax    # 0x27a1b4
cmpl $0x36, (%rax)
je 0x94832
leaq 0x1e599f(%rip), %rax    # 0x27a1b4
cmpl $0x33, (%rax)
je 0x94832
leaq 0x1e5993(%rip), %rax    # 0x27a1b4
cmpl $0x50, (%rax)
je 0x94832
leaq 0x1e5987(%rip), %rax    # 0x27a1b4
cmpl $0x41, (%rax)
jne 0x94837
jmp 0x948f8
movl $0x8e, %edi
callq 0x824f0
movl $0xa0, %edi
callq 0x7b210
xorl %edi, %edi
callq 0x7b210
movsd -0x8(%rbp), %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x7b600
callq 0x82590
jmp 0x948f4
leaq 0x1e323f(%rip), %rax    # 0x277ab0
cmpq $0x8, (%rax)
jne 0x948f2
cvttsd2si -0x8(%rbp), %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %edx
leaq 0x306b77(%rip), %rdi    # 0x39b400
leaq 0xefd66(%rip), %rsi     # 0x1845f6
movb $0x0, %al
callq 0x9060
leaq 0x306b62(%rip), %rdi    # 0x39b400
movl $0x68, %esi
callq 0x82fd0
leaq 0xefd5d(%rip), %rdi     # 0x18460c
movl $0x67, %esi
callq 0x82fd0
leaq 0x2d7db7(%rip), %rax    # 0x36c677
movb $0x3, (%rax)
leaq 0x208ca6(%rip), %rax    # 0x29d570
cmpq $0x0, (%rax)
je 0x948f0
leaq 0x208c99(%rip), %rax    # 0x29d570
movq (%rax), %rdi
movsd -0x8(%rbp), %xmm0
movl -0xc(%rbp), %edx
leaq 0xefd37(%rip), %rsi     # 0x184620
movb $0x1, %al
callq 0x9550
jmp 0x948f2
jmp 0x948f4
jmp 0x948f6
jmp 0x948f8
addq $0x20, %rsp
popq %rbp
retq
nop