From a0d4a5ebb7ba9716b9fcff391fbaba4743b7a64a Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Thu, 19 Dec 2024 12:29:17 +0800 Subject: [PATCH] Refactor some macros to be vanilla assembly --- src/packet.asm | 8 ++++---- src/packet_packer.asm | 22 ++++------------------ 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/packet.asm b/src/packet.asm index ea8afe4..90d530e 100644 --- a/src/packet.asm +++ b/src/packet.asm @@ -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 @@ -25,7 +25,7 @@ pop rdi pop rax -%endmacro + ret ; packet_pack_raw [buffer] [buffer size] %macro packet_pack_raw 2 diff --git a/src/packet_packer.asm b/src/packet_packer.asm index 995aab1..514e676 100644 --- a/src/packet_packer.asm +++ b/src/packet_packer.asm @@ -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 @@ -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 @@ -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