// File: /workspace/github_cpp_makefile_star2_O3/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 %r14
pushq %rbx
movl $0xa, %edi
callq 0xb9ad
movl $0xa, %edi
testl %eax, %eax
je 0x933cc
callq 0x1ea0b
callq 0x584bd
movl %eax, %ebx
cmpl $0x3, %eax
jne 0x933d5
leaq 0x187c40(%rip), %rax    # 0x21afe8
cmpl $0x4f, (%rax)
jne 0x933d5
leaq 0x187c44(%rip), %rax    # 0x21aff8
cmpl $0x0, (%rax)
je 0x93489
movl $0x1, 0x2d8a05(%rip)    # 0x36bdcc
jmp 0x93489
popq %rbx
popq %r14
popq %rbp
jmp 0x1e66a
leaq 0x27af04(%rip), %rax    # 0x30e2e0
cmpb $0x0, 0x17a12(%rax)
je 0x933ec
movb $0x0, 0x17a12(%rax)
leaq 0x2a4e63(%rip), %r14    # 0x338256
movzwl (%r14), %eax
cmpl $0x3, %eax
je 0x9346a
cmpl $0x1, %eax
je 0x93433
testl %eax, %eax
jne 0x93479
leaq 0x2a4e46(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
leaq 0x2a4e3c(%rip), %rax    # 0x338254
movw %cx, (%rax)
cmpb $0xa, %bl
je 0x93489
movzbl %bl, %eax
cmpl $0xd, %eax
je 0x93489
movw $0x1, (%r14)
callq 0x58672
cmpb $0xa, %bl
je 0x9346a
movzbl %bl, %eax
cmpl $0xd, %eax
je 0x93489
leaq 0x2a4e0b(%rip), %rcx    # 0x338252
movzwl (%rcx), %eax
cmpq $0xffe, %rax            # imm = 0xFFE
ja 0x9348e
leaq 0x1(%rax), %rdx
movw %dx, (%rcx)
leaq 0x2a3df0(%rip), %rcx    # 0x337250
movb %bl, (%rcx,%rax)
movb $0x0, 0x1(%rcx,%rax)
jmp 0x93489
callq 0x92be0
movl $0x1, 0x2d881b(%rip)    # 0x36bc94
leaq 0x2a4dd2(%rip), %rax    # 0x338252
xorl %ecx, %ecx
movw %cx, (%rax)
movw %cx, (%r14)
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1abadb(%rip), %rax    # 0x23ef70
orb $-0x80, 0x1(%rax)
jmp 0x93479