// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: get_taip_message()
void get_taip_message()
{
u08 c;

   // This routine buffers up an incoming TAIP message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_nmea_msg()

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

   c = get_com_char();
   if(com[RCVR_PORT].rcv_error) {      // parity/framing/overrun errors
      com[RCVR_PORT].rcv_error = 0;
//!!!!!qqqq    goto rst_msg;
   }

   if(tsip_sync == 0) {    // syncing to start of message, search for a '$'
      if(c == '>') {
         tsip_sync = 1;
         get_sync_time();
      }
      tsip_wptr = 0;
      tsip_rptr = 0;
      nmea_msg_cksum = 0;  // the checksum in the message
      nmea_vfy_cksum = 0;  // the calculated message checksum
      nmea_vfy_cksum ^= c;
      return;
   }
   else if(tsip_sync == 1) { // '>' has been seen, now build the message
      if((c == '<') || (c == 0x0D) || (c == 0x0A)) goto taip_end;  // message has no checksum

      if(c == '*') {
         nmea_vfy_cksum ^= c;
         tsip_sync = 2;  // message checksum follows
      }
      else if(tsip_wptr < MAX_TSIP) {   // add char to the message buffer
         nmea_vfy_cksum ^= c;
         tsip_buf[tsip_wptr++] = c;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
   }
   else if(tsip_sync == 2) {  // getting message checksum chars
      if((c == '<') || (c == 0x0D) || (c == 0x0A)) goto taip_end;

      if     ((c >= '0') && (c <= '9')) nmea_msg_cksum = (nmea_msg_cksum << 4) | (c-'0');
      else if((c >= 'A') && (c <= 'F')) nmea_msg_cksum = (nmea_msg_cksum << 4) | ((c-'A')+10);
      else goto rst_msg;
   }
   else if(tsip_sync == 3) {  // end of message
      taip_end:
      if((tsip_sync == 2) && (nmea_vfy_cksum != nmea_msg_cksum)) { // checksum error
         tsip_error |= CKSUM_ERROR;
         goto rst_msg;
      }
      decode_taip_msg(); // message checksum matches, process the message
      packet_end = 1;
      tsip_wptr = 0;     // prepare for next message
      tsip_sync = 0;
      venus_nmea = 0;
   }
   else {     // should never happen, prepare for next message
      rst_msg:
      tsip_wptr = 0;
      tsip_sync = 0;
      nmea_vfy_cksum = nmea_msg_cksum = 0; // init received message checksum
      venus_nmea = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl $0xa, %edi
callq 0xb9c3
movl $0xa, %edi
testl %eax, %eax
je 0xa4105
callq 0x1ea2c
callq 0x584d5
movl %eax, %ebx
leaq 0x26a248(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0xa40a8
movb $0x0, 0x17a12(%rax)
leaq 0x2941a7(%rip), %r14    # 0x338256
movzwl (%r14), %eax
cmpq $0x3, %rax
ja 0xa41e8
leaq 0x7b978(%rip), %rcx     # 0x11fa3c
movslq (%rcx,%rax,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
cmpl $0x3e, %ebx
jne 0xa40dd
movw $0x1, (%r14)
callq 0x58682
leaq 0x29416e(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x294164(%rip), %rax    # 0x338254
movw %cx, (%rax)
movb $0x0, 0x2c89bb(%rip)    # 0x36cab5
movb %bl, 0x2c89b4(%rip)     # 0x36cab4
jmp 0xa420e
popq %rbx
popq %r14
popq %rbp
jmp 0x1e6a0
cmpl $0x29, %ebx
jg 0xa415a
cmpl $0xa, %ebx
je 0xa4176
cmpl $0xd, %ebx
je 0xa4176
jmp 0xa41b0
cmpl $0x3c, %ebx
ja 0xa4139
movl %ebx, %ecx
movabsq $0x1000000000002400, %rdx # imm = 0x1000000000002400
btq %rcx, %rdx
jb 0xa4176
leal -0x30(%rbx), %eax
cmpl $0x9, %eax
ja 0xa4213
movzbl 0x2c8969(%rip), %eax    # 0x36cab5
shll $0x4, %eax
addl $0xd0, %ebx
jmp 0xa422b
cmpl $0x3c, %ebx
je 0xa4176
cmpl $0x2a, %ebx
jne 0xa41b0
xorb $0x2a, 0x2c8949(%rip)   # 0x36cab4
movw $0x2, (%r14)
jmp 0xa420e
cmpw $0x2, %ax
jne 0xa418f
movb 0x2c8932(%rip), %al     # 0x36cab4
movl $0x4000, %edx           # imm = 0x4000
cmpb 0x2c8928(%rip), %al     # 0x36cab5
jne 0xa41df
callq 0xa3f5c
movl $0x1, 0x2c7af6(%rip)    # 0x36bc94
leaq 0x2940ad(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%r14)
jmp 0xa4204
leaq 0x29409b(%rip), %rcx    # 0x338252
movzwl (%rcx), %eax
movl $0x8000, %edx           # imm = 0x8000
cmpq $0xfff, %rax            # imm = 0xFFF
ja 0xa41df
xorb %bl, 0x2c88e7(%rip)     # 0x36cab4
leal 0x1(%rax), %edx
movw %dx, (%rcx)
leaq 0x293076(%rip), %rcx    # 0x337250
movb %bl, (%rcx,%rax)
jmp 0xa420e
leaq 0x19ad8a(%rip), %rax    # 0x23ef70
orl %edx, (%rax)
leaq 0x294063(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%r14)
movb %cl, 0x2c88b7(%rip)     # 0x36cab5
movb %cl, 0x2c88b0(%rip)     # 0x36cab4
movl $0x0, 0x2c88d6(%rip)    # 0x36cae4
popq %rbx
popq %r14
popq %rbp
retq
leal -0x41(%rbx), %eax
cmpl $0x5, %eax
ja 0xa41e8
movzbl 0x2c8893(%rip), %eax    # 0x36cab5
shll $0x4, %eax
addl $0xc9, %ebx
orl %eax, %ebx
movb %bl, 0x2c8882(%rip)     # 0x36cab5
jmp 0xa420e