## Encode a VNC PointerEvent. See also pointerevent.c, file ## `yeso-vnc.md` in pavnotes2, and file ## `binary-serialization.md` in pavnotes2. .intel_syntax noprefix .globl encode_pointer_event encode_pointer_event: mov rax, [rdi] # load buffer pointer from buffer struct lea rax, [rax + 6] # add 6 bytes to buffer pointer cmp rax, [rdi + 8] # compare to buffer end pointer jae 1f # jump to buffer reallocation code if necessary mov byte ptr [rax - 6], 5 # store type byte into buffer mov rcx, [rsi] # load button mask field from in-memory struct mov [rax - 5], cl # store buttons byte into buffer mov rcx, [rsi + 8] # load x position from in-memory struct mov [rax - 4], ch # store bytes in big-endian order mov [rax - 3], cl # (there’s probably a better way to byteswap) mov rcx, [rsi + 16] # load y position from in-memory struct mov [rax - 2], ch mov [rax - 1], cl mov [rdi], rax # update buffer pointer ret ## buffer reallocation code would follow 1: