From 7e9043d484c30d018a012f835dda5eae9fa17860 Mon Sep 17 00:00:00 2001 From: Arslaan Pathan Date: Wed, 30 Sep 2026 12:37:06 +1300 Subject: idk whats even in this commit --- curl_test.asm | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 curl_test.asm (limited to 'curl_test.asm') diff --git a/curl_test.asm b/curl_test.asm new file mode 100644 index 0000000..159a520 --- /dev/null +++ b/curl_test.asm @@ -0,0 +1,45 @@ +global main + +extern curl_easy_init +extern curl_easy_cleanup +extern curl_easy_setopt +extern curl_easy_perform + +section .data + url db "https://httpbin.org/get", 0 + +section .text + +main: + sub rsp, 8 + ; curl = curl_easy_init() + call curl_easy_init wrt ..plt ; puts cURL handle in rax + test rax, rax ; if rax == 0 (handle is NULL) it failed + jz .failed + + mov [rsp], rax + + ; curl_easy_setopt(curl, CURLOPT_URL, url) + mov rdi, [rsp] ; cURL handle (arg 1) + mov rsi, 10002 ; CURLOPT_URL + lea rdx, [rel url] ; put address of url in rdx + call curl_easy_setopt wrt ..plt ; set option CURLOPT_URL to url + + ; curl_easy_perform() + mov rdi, [rsp] ; cURL handle + call curl_easy_perform wrt ..plt ; perform cURL + + ; curl_easy_cleanup() + mov rdi, [rsp] ; RDI = first function argument, set first argument to rsp (cURL handle) + call curl_easy_cleanup wrt ..plt ; call curl_easy_cleanup with argument rdi (cURL handle) + + ; return 0 + mov eax, 0 ; eax for return code + mov qword [rsp], 0 ; zero the cURL pointer just in case because why not + add rsp, 8 + ret + +.failed: + mov eax, 1 ; eax for return code + add rsp, 8 + ret -- cgit v1.2.3