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

   // This routine buffers up an incoming STAR4 message.  When the end of the
   // message is seen, the message is parsed and decoded with decode_star_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(star_type == OSA_TYPE) {
      if(c == 0x03) {  // ETX
         if(star_line) saw_star_etx = 1;
         return;
      }
   }
   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
      tsip_wptr = 0;
      tsip_rptr = 0;
      if((c == 0x0A) || (c == 0x0D)) return;

      tsip_sync = 1;
      get_sync_time();
      goto star_msg;
   }
   else if(tsip_sync == 1) { // '$' has been seen, now build the message
      star_msg:
//    if((c == 0x0D) || (c == 0x0A)) goto star_end;  // message has no checksum
      if(c == 0x0D) return; // message has no checksum
      if(c == 0x0A) goto star_end;  // message has no checksum

      if(tsip_wptr < (MAX_TSIP-1)) {   // add char to the message buffer
         tsip_buf[tsip_wptr++] = c;
         tsip_buf[tsip_wptr] = 0;
      }
      else {
         tsip_error |= OVFL_ERROR;
         goto rst_msg;
      }
   }
   else if(tsip_sync == 3) {  // end of message
      star_end:
      decode_star_msg(); // process the message
      packet_end = 1;
      tsip_wptr = 0;     // prepare for next message
      tsip_sync = 0;
   }
   else {     // should never happen, prepare for next message
      rst_msg:
      tsip_wptr = 0;
      tsip_sync = 0;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
pushq $0xa
popq %rdi
callq 0xb771
pushq $0xa
popq %rdi
testl %eax, %eax
je 0x86412
callq 0x1d93f
callq 0x51891
movl %eax, %ebx
cmpl $0x3, %eax
jne 0x86421
leaq 0x17ebfa(%rip), %rax    # 0x204fe8
cmpl $0x4f, (%rax)
jne 0x86421
leaq 0x17ebfe(%rip), %rax    # 0x204ff8
cmpl $0x0, (%rax)
je 0x864f1
movl $0x1, 0x2cf9bf(%rip)    # 0x355dcc
jmp 0x864f1
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1d61b
leaq 0x271eb8(%rip), %rax    # 0x2f82e0
cmpb $0x0, 0x17a12(%rax)
je 0x86438
movb $0x0, 0x17a12(%rax)
leaq 0x29be17(%rip), %r14    # 0x322256
movzwl (%r14), %eax
cmpl $0x3, %eax
je 0x864ba
movzbl %bl, %r15d
cmpl $0x1, %eax
je 0x86485
testl %eax, %eax
jne 0x864e1
leaq 0x29bdf2(%rip), %rax    # 0x322252
andw $0x0, (%rax)
leaq 0x29bde9(%rip), %rax    # 0x322254
andw $0x0, (%rax)
cmpb $0xa, %bl
je 0x864f1
cmpl $0xd, %r15d
je 0x864f1
movw $0x1, (%r14)
callq 0x51a2f
cmpb $0xa, %bl
je 0x864ba
cmpl $0xd, %r15d
je 0x864f1
leaq 0x29bdbb(%rip), %rcx    # 0x322252
movzwl (%rcx), %eax
cmpq $0xffe, %rax            # imm = 0xFFE
ja 0x864d6
leaq 0x1(%rax), %rdx
movw %dx, (%rcx)
leaq 0x29ada0(%rip), %rcx    # 0x321250
movb %bl, (%rcx,%rax)
movb $0x0, 0x1(%rcx,%rax)
jmp 0x864f1
callq 0x85c96
leaq 0x29bd8c(%rip), %rax    # 0x322252
andw $0x0, (%rax)
movl $0x1, 0x2cf7c0(%rip)    # 0x355c94
jmp 0x864ec
leaq 0x1a2a93(%rip), %rax    # 0x228f70
orb $-0x80, 0x1(%rax)
leaq 0x29bd6a(%rip), %rax    # 0x322252
andw $0x0, (%rax)
andw $0x0, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq