Skip to content

Commit

Permalink
Refactor some macros to be vanilla assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Dec 19, 2024
1 parent 62c80d1 commit a0d4a5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/packet.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
; you can also push bytes into a packer buffer
; see packer.asm for that

%macro packet_packer_reset 0
packet_packer_reset:
mov dword [udp_payload_index], 0

mov byte [out_packet_header_flags], 0
mov byte [out_packet_header_num_chunks], 0
%endmacro
ret

%macro hexdump_outgoing_packet 0
hexdump_outgoing_packet:
push rax
push rdi

Expand All @@ -25,7 +25,7 @@

pop rdi
pop rax
%endmacro
ret

; packet_pack_raw [buffer] [buffer size]
%macro packet_pack_raw 2
Expand Down
22 changes: 4 additions & 18 deletions src/packet_packer.asm
Original file line number Diff line number Diff line change
Expand Up @@ -85,27 +85,13 @@ send_packet6:
mov edi, [udp_payload_index]
add rdi, PACKET6_HEADER_LEN

; ; dbg print
; push rax
; print_label s_sending_packet_with_size
; mov rax, rdi
; call println_uint32
; pop rax

push rax
; TODO: somehow we sent too much here
printlnf "size=%d", rdi
print "sending: "
mov rax, udp_send_buf
call print_hexdump
call print_newline
pop rax
call hexdump_outgoing_packet

call send_udp

; this is for convenience so we can just queue new chunks
; and never have to worry about which chunk is the first
packet_packer_reset
call packet_packer_reset

pop rdi
pop rax
Expand Down Expand Up @@ -161,7 +147,7 @@ send_packet7:

; this is for convenience so we can just queue new chunks
; and never have to worry about which chunk is the first
packet_packer_reset
call packet_packer_reset

pop rdi
pop rax
Expand Down Expand Up @@ -197,6 +183,6 @@ send_packet_with_payload:

; this is for convenience so we can just queue new chunks
; and never have to worry about which chunk is the first
packet_packer_reset
call packet_packer_reset

ret

0 comments on commit a0d4a5e

Please sign in to comment.