// File: /workspace/github_cpp_makefile_star2_O3/jkingan[P]ladyheather/heathgps.cpp
// Function: get_dac_message(unsigned int)
void get_dac_message(unsigned port)
{
u08 c;
static u08 last_c = 0;

   // This routine buffers up an incoming ADC message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_dac_msg()
   // Messages can end with 0x0D, 0x0A, or both.

   if(SERIAL_DATA_AVAILABLE(port) == 0) {
      check_com_timer(port);
      return;
   }
   else {
      reset_com_timer(port);
   }

   if(port == RCVR_PORT) {  // ADC is main input decice
      c = get_com_char();
      if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
         com[RCVR_PORT].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }
   else {  // ADC is auxiliary input device (/et=)
      c = get_dac_char();  // aaattt
      if(com[DAC_PORT].rcv_error) {      // parity/framing/overrun errors
         com[DAC_PORT].rcv_error = 0;
         //!!!!!qqqq    goto rst_msg;
      }
   }

   last_c = c;

   if(dac_sync == 0) {    // syncing to start of message, search for a line feed
      if((c == 0x0D) || (c == 0x0A)) {
         dac_sync = 1;
         get_sync_time();
      }
      dac_wptr = 0;
      dac_rptr = 0;
      return;
   }
   else if(dac_sync == 1) { // 0x0A has been seen, now build the message
      if((c == 0x0D) || (c == 0x0A)) {
         if(dac_wptr == 0) return; // end-of-line with no data in the message buffer
         goto dac_end;  // end of message
      }

      if(dac_wptr < MAX_TSIP) {   // add char to the message buffer
         dac_buf[dac_wptr++] = c;
      }
      else {  // buffer overflow, ignore the message
//         dac_error |= 0x8000;  // aaattt
         goto rst_msg;
      }
   }
   else {  // end of message
      dac_end:
      if(dac_wptr) {           // we have a message
         decode_dac_msg(port); // process the message
         packet_end = 1;
      }

      rst_msg:
      dac_wptr = 0;     // prepare for next message
      dac_rptr = 0;
      if((c == 0x0D) || (c == 0x0A)) dac_sync = 1;
      else dac_sync = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %r14d
callq 0xb9ad
testl %eax, %eax
je 0xaccbc
movl %r14d, %edi
callq 0x1ea0b
cmpl $0xa, %r14d
jne 0xaccce
callq 0x584bd
movl %eax, %ebx
leaq 0x261635(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0xaccf4
addq $0x17a12, %rax          # imm = 0x17A12
jmp 0xaccf1
movl %r14d, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1e66a
movl $0x10, %edi
callq 0xbafb
movzbl %al, %ebx
leaq 0x2615fe(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x24852(%rax)
je 0xaccf4
addq $0x24852, %rax          # imm = 0x24852
movb $0x0, (%rax)
leaq 0x28e591(%rip), %r15    # 0x33b28c
movl (%r15), %eax
cmpl $0x1, %eax
je 0xacd39
testl %eax, %eax
jne 0xacd54
cmpb $0xd, %bl
je 0xacd14
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0xacd20
movl $0x1, (%r15)
callq 0x58672
leaq 0x28e55d(%rip), %rax    # 0x33b284
xorl %ecx, %ecx
movl %ecx, (%rax)
leaq 0x28e556(%rip), %rax    # 0x33b288
movl %ecx, (%rax)
jmp 0xacdc6
cmpb $0xd, %bl
je 0xacd46
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0xacda5
leaq 0x28e537(%rip), %rax    # 0x33b284
cmpl $0x0, (%rax)
jne 0xacd60
jmp 0xacdc6
leaq 0x28e529(%rip), %rax    # 0x33b284
cmpl $0x0, (%rax)
je 0xacd72
movl %r14d, %edi
callq 0xacbaf
movl $0x1, 0x2bef22(%rip)    # 0x36bc94
leaq 0x28e50b(%rip), %rax    # 0x33b284
xorl %ecx, %ecx
movl %ecx, (%rax)
leaq 0x28e504(%rip), %rax    # 0x33b288
movl %ecx, (%rax)
cmpb $0xd, %bl
je 0xacd93
movzbl %bl, %eax
cmpl $0xa, %eax
jne 0xacd9c
movl $0x1, (%r15)
jmp 0xacdc6
movl $0x0, (%r15)
jmp 0xacdc6
leaq 0x28e4d8(%rip), %rcx    # 0x33b284
movslq (%rcx), %rax
cmpq $0xfff, %rax            # imm = 0xFFF
jg 0xacd72
leal 0x1(%rax), %edx
movl %edx, (%rcx)
leaq 0x28d4bd(%rip), %rcx    # 0x33a280
movb %bl, (%rcx,%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq