summaryrefslogtreecommitdiff
path: root/curl_test.asm
diff options
context:
space:
mode:
authorArslaan Pathan <[email protected]>2026-09-30 12:37:06 +1300
committerArslaan Pathan <[email protected]>2026-09-30 12:39:55 +1300
commit7e9043d484c30d018a012f835dda5eae9fa17860 (patch)
treed44842c091e6cfa48d16062cfc96bf31bdb2d760 /curl_test.asm
parent2bb4f7e34806054fa15174b2586241c2b82e040c (diff)
downloadx86-asm-7e9043d484c30d018a012f835dda5eae9fa17860.tar.xz
x86-asm-7e9043d484c30d018a012f835dda5eae9fa17860.zip
idk whats even in this commit
Diffstat (limited to 'curl_test.asm')
-rw-r--r--curl_test.asm45
1 files changed, 45 insertions, 0 deletions
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