// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: send_byte(unsigned char)
void send_byte(u08 val)
{
   // send a byte to the receiver and update the message checksum
   // NEW_RCVR
   if(log_file && (log_stream & LOG_PACKET_START)) {
      if(superpacket) fprintf(log_file, "Superpacket:    %02X\n", val);
   }
   if(log_file && (log_stream & LOG_SENT_DATA) && sts) fprintf(log_file, "{%02X} ", val);

   superpacket = 0;

   sendout(RCVR_PORT, val, eom_flag);  
   ++tsip_send_count;

   nmea_tx_cksum ^= val;  // we always update these since we may need to send
   moto_tx_cksum ^= val;  // ... messaages in these formats to wake up other receivers
   venus_tx_cksum ^= val;
   sirf_tx_cksum += val;
   ss_tx_cksum += val;
   rt17_tx_cksum += val;

   if(rcvr_type == TSIP_RCVR) {
      if(val == DLE) {  // we are sending a TSIP message
         sendout(RCVR_PORT, DLE, eom_flag);  // DLE character must be sent twice
         ++tsip_send_count;
      }
   }
   else if(rcvr_type == NVS_RCVR) {
      nvs_tx_crc = calc_nvs_crc(nvs_tx_crc, val);
      if(val == DLE) {  // we are sending a TSIP message
         nvs_tx_crc = calc_nvs_crc(nvs_tx_crc, DLE);
         sendout(RCVR_PORT, DLE, eom_flag);  // DLE character must be sent twice
         ++tsip_send_count;
      }
   }
   else if(rcvr_type == UBX_RCVR) { // sending ublox ubx message
      ubx_txa += val;    // add byte to message checksums
      ubx_txb += ubx_txa;
   }
   else if(rcvr_type == ZODIAC_RCVR) {
      if(zodiac_tx_cnt & 1) zodiac_tx_cksum += ( (((u16) val) * 256) + zodiac_low_byte );
      else zodiac_low_byte = (u16) val;
      ++zodiac_tx_cnt;
   }

   eom_flag = ADD_CHAR;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
leaq 0x1e519e(%rip), %r15    # 0x23e360
movq (%r15), %rdi
movzbl %bl, %r14d
testq %rdi, %rdi
je 0x591f4
leaq 0x1e523b(%rip), %rax    # 0x23e410
testb $0x4, (%rax)
je 0x591f4
cmpb $0x0, 0x316e2f(%rip)    # 0x370010
je 0x591f4
leaq 0xc6f7a(%rip), %rsi     # 0x120164
movl %r14d, %edx
xorl %eax, %eax
callq 0x9560
movq (%r15), %rdi
testq %rdi, %rdi
je 0x59222
leaq 0x1e520d(%rip), %rax    # 0x23e410
testb $0x10, (%rax)
je 0x59222
cmpl $0x0, 0x316e05(%rip)    # 0x370014
je 0x59222
leaq 0xc6f62(%rip), %rsi     # 0x12017a
movl %r14d, %edx
xorl %eax, %eax
callq 0x9560
movb $0x0, 0x316de7(%rip)    # 0x370010
movl 0x312be1(%rip), %edx    # 0x36be10
movl $0xa, %edi
movl %r14d, %esi
callq 0xbcc0
incl 0x312bd6(%rip)          # 0x36be18
xorb %r14b, 0x31386d(%rip)   # 0x36cab6
xorb %r14b, 0x313873(%rip)   # 0x36cac3
xorb %r14b, 0x31387c(%rip)   # 0x36cad3
addw %r14w, 0x313895(%rip)   # 0x36caf4
addw %r14w, 0x313855(%rip)   # 0x36cabc
addb %r14b, 0x313852(%rip)   # 0x36cac0
leaq 0x1bf65b(%rip), %rax    # 0x2188d0
movq (%rax), %rax
cmpq $0xff, %rax
jg 0x592a7
cmpq $0x1, %rax
je 0x59302
cmpq $0x4, %rax
jne 0x59357
addb 0x3137e2(%rip), %bl     # 0x36ca78
movb %bl, 0x3137dc(%rip)     # 0x36ca78
addb %bl, 0x3137d7(%rip)     # 0x36ca79
jmp 0x59357
cmpq $0x100, %rax            # imm = 0x100
je 0x59324
cmpq $0x800, %rax            # imm = 0x800
jne 0x59357
movzwl 0x313842(%rip), %edx    # 0x36cb04
movl %edx, %eax
shrl $0x8, %eax
movzwl %r14w, %ecx
xorl %eax, %ecx
shll $0x8, %edx
leaq 0x1110a9(%rip), %rax    # 0x16a380
movzwl (%rax,%rcx,2), %ecx
xorl %ecx, %edx
movw %dx, 0x313820(%rip)     # 0x36cb04
cmpb $0x10, %bl
jne 0x59357
movzwl %dx, %edx
shrl $0x8, %edx
xorl $0x10, %edx
shll $0x8, %ecx
xorw (%rax,%rdx,2), %cx
movw %cx, 0x313804(%rip)     # 0x36cb04
jmp 0x59307
cmpb $0x10, %bl
jne 0x59357
movl 0x312b03(%rip), %edx    # 0x36be10
movl $0xa, %edi
movl $0x10, %esi
callq 0xbcc0
incl 0x312af6(%rip)          # 0x36be18
jmp 0x59357
movzwl 0x3137ed(%rip), %eax    # 0x36cb18
testb $0x1, %al
jne 0x59339
movw %r14w, 0x3137fd(%rip)   # 0x36cb34
jmp 0x5934e
movzwl %r14w, %ecx
shll $0x8, %ecx
addw 0x3137ed(%rip), %cx     # 0x36cb34
addw %cx, 0x3137cc(%rip)     # 0x36cb1a
incl %eax
movw %ax, 0x3137c1(%rip)     # 0x36cb18
movl $0x0, 0x312aaf(%rip)    # 0x36be10
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq