// File: jkingan[P]ladyheather/heathgps.cpp
// Function: parse_brandy_f()
void parse_brandy_f()
{

   // frequency controller info

   log_packet_id("freq controller");

   if(get_msg_field()) {  // 2 -
      inst_phase = atof(msg_field);
      pps_offset = inst_phase;
      have_pps_offset = 456;
   }

   if(get_msg_field()) {  // 3 - documentation says this should be item 4!
      if(msg_field[0] == '%') { // value out of range
         avg_phase = atof(&msg_field[1]);
      }
      else {
         avg_phase = atof(msg_field);
      }
   }

   if(get_msg_field()) {  // 4 - always 0 on GPS-4  - documentation says this should be item 3!  
      phase_control_val = atof(msg_field);
   }

   if(get_msg_field()) {  // 5 -
      freq_control_val = atof(msg_field);
      dac_voltage = (DATA_SIZE) ((freq_control_val / 32767.0) * 100.0);
      have_dac = 44;
   }

   if(get_msg_field()) {  // 6 - last freq correction
      last_freq_corr = atof(msg_field);
      osc_offset = (last_freq_corr * 1.0E12);
      have_osc_offset = 44;
   }

   if(get_msg_field()) {  // 7 - frequency trend
      freq_trend = atof(msg_field);
   }

   if(get_msg_field()) {  // 8 - date of last correction
      msg_field[32] = 0;
      strcpy(last_correction, msg_field);
   }

   if(get_msg_field()) {  // 9 - temperature (not valid on GPS-4)
      temperature = (DATA_SIZE) atof(msg_field);
//    have_temperature = 1;  // temp reading not valid
   }

   if(get_msg_field()) {  // 10 -
      phase_status = atohex(msg_field);
      if(phase_status & 0xF8) minor_alarms |= MINOR_PLL;
      else                    minor_alarms &= (~MINOR_PLL);
      have_pll = 1;
   }

   if(get_msg_field()) {  // 11 -
      pll_constraint = atohex(msg_field);

      if(pll_constraint & 0x0C) time_flags |= TFLAGS_INVALID;
      else                      time_flags &= (~TFLAGS_INVALID);

      if(pll_constraint & 0x01) minor_alarms |= MINOR_OSC_CTRL;
      else                      minor_alarms &= (~MINOR_OSC_CTRL);

   }

   if(get_msg_field()) {  // 12 - osc type
      msg_field[16] = 0;
      strcpy(brandy_osc, msg_field);
      have_info |= (MANUF_PARAMS);
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0xc9bfe(%rip), %rdi     # 0x186a69
callq 0x7add0
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbceb4
leaq 0x2ddd9f(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x2de2fb(%rip), %rax    # 0x39b188
movsd %xmm0, (%rax)
leaq 0x2de2f0(%rip), %rax    # 0x39b188
movsd (%rax), %xmm0
leaq 0x2aeaf5(%rip), %rax    # 0x36b998
movsd %xmm0, (%rax)
leaq 0x2af56a(%rip), %rax    # 0x36c418
movl $0x1c8, (%rax)          # imm = 0x1C8
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbcf03
leaq 0x2ddd5b(%rip), %rax    # 0x39ac20
movsbl (%rax), %eax
cmpl $0x25, %eax
jne 0xbceea
leaq 0x2ddd4c(%rip), %rdi    # 0x39ac20
addq $0x1, %rdi
callq 0x9480
leaq 0x2de2b4(%rip), %rax    # 0x39b198
movsd %xmm0, (%rax)
jmp 0xbcf01
leaq 0x2ddd2f(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x2de29b(%rip), %rax    # 0x39b198
movsd %xmm0, (%rax)
jmp 0xbcf03
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbcf24
leaq 0x2ddd0c(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x2de270(%rip), %rax    # 0x39b190
movsd %xmm0, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbcf80
leaq 0x2ddceb(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x2de25f(%rip), %rax    # 0x39b1a0
movsd %xmm0, (%rax)
leaq 0x2de254(%rip), %rax    # 0x39b1a0
movsd (%rax), %xmm0
movsd 0xc60c0(%rip), %xmm1    # 0x183018
divsd %xmm1, %xmm0
movsd 0xb20ec(%rip), %xmm1    # 0x16f050
mulsd %xmm1, %xmm0
leaq 0x2aec71(%rip), %rax    # 0x36bbe0
movsd %xmm0, (%rax)
leaq 0x2af562(%rip), %rax    # 0x36c4dc
movl $0x2c, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbcfcc
leaq 0x2ddc8f(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x2de20b(%rip), %rax    # 0x39b1a8
movsd %xmm0, (%rax)
movsd 0xb21c7(%rip), %xmm0    # 0x16f170
leaq 0x2de1f8(%rip), %rax    # 0x39b1a8
mulsd (%rax), %xmm0
leaq 0x2ae9e5(%rip), %rax    # 0x36b9a0
movsd %xmm0, (%rax)
leaq 0x2af44e(%rip), %rax    # 0x36c414
movl $0x2c, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbcfed
leaq 0x2ddc43(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x2de1c7(%rip), %rax    # 0x39b1b0
movsd %xmm0, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbd015
leaq 0x2ddc22(%rip), %rax    # 0x39ac20
movb $0x0, 0x20(%rax)
leaq 0x2de1b7(%rip), %rdi    # 0x39b1c0
leaq 0x2ddc10(%rip), %rsi    # 0x39ac20
callq 0x9350
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbd036
leaq 0x2ddbfa(%rip), %rdi    # 0x39ac20
callq 0x9480
leaq 0x2aebc6(%rip), %rax    # 0x36bbf8
movsd %xmm0, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbd0a9
leaq 0x2ddbd9(%rip), %rdi    # 0x39ac20
callq 0x98d0
movl %eax, %ecx
leaq 0x2de18f(%rip), %rax    # 0x39b1e4
movl %ecx, (%rax)
leaq 0x2de186(%rip), %rax    # 0x39b1e4
movl (%rax), %eax
andl $0xf8, %eax
cmpl $0x0, %eax
je 0xbd084
leaq 0x2af347(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x2000000, %ecx        # imm = 0x2000000
leaq 0x2af338(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
jmp 0xbd09c
leaq 0x2af32d(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $0xfdffffff, %ecx       # imm = 0xFDFFFFFF
leaq 0x2af31e(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
leaq 0x2af321(%rip), %rax    # 0x36c3c4
movl $0x1, (%rax)
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbd14a
leaq 0x2ddb62(%rip), %rdi    # 0x39ac20
callq 0x98d0
movl %eax, %ecx
leaq 0x2de11c(%rip), %rax    # 0x39b1e8
movl %ecx, (%rax)
leaq 0x2de113(%rip), %rax    # 0x39b1e8
movl (%rax), %eax
andl $0xc, %eax
cmpl $0x0, %eax
je 0xbd0f6
leaq 0x2af59e(%rip), %rax    # 0x36c684
movl (%rax), %ecx
orl $0x4, %ecx
leaq 0x2af592(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
jmp 0xbd10b
leaq 0x2af587(%rip), %rax    # 0x36c684
movl (%rax), %ecx
andl $-0x5, %ecx
leaq 0x2af57b(%rip), %rax    # 0x36c684
movl %ecx, (%rax)
leaq 0x2de0d6(%rip), %rax    # 0x39b1e8
movl (%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0xbd133
leaq 0x2af295(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
orl $0x10, %ecx
leaq 0x2af289(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
jmp 0xbd148
leaq 0x2af27e(%rip), %rax    # 0x36c3b8
movl (%rax), %ecx
andl $-0x11, %ecx
leaq 0x2af272(%rip), %rax    # 0x36c3b8
movl %ecx, (%rax)
jmp 0xbd14a
callq 0xb0bd0
cmpl $0x0, %eax
je 0xbd187
leaq 0x2ddac5(%rip), %rax    # 0x39ac20
movb $0x0, 0x10(%rax)
leaq 0x2dde4a(%rip), %rdi    # 0x39afb0
leaq 0x2ddab3(%rip), %rsi    # 0x39ac20
callq 0x9350
leaq 0x2af9db(%rip), %rax    # 0x36cb54
movl (%rax), %ecx
orl $0x1, %ecx
leaq 0x2af9cf(%rip), %rax    # 0x36cb54
movl %ecx, (%rax)
popq %rbp
retq
nopl (%rax)