RosettaCodeData/Task/Call-a-foreign-language-function/X86-64-Assembly/call-a-foreign-language-function-1.x86-64
2023-07-01 13:44:08 -04:00

30 lines
548 B
Text

option casemap:none
strdup proto :qword
printf proto :qword, :vararg
exit proto :dword
.data
bstr db "String 1",0
.data?
buff dq ?
.code
main proc
invoke printf, CSTR("Copying %s to buff with strdup using invoke....",10), addr bstr
invoke strdup, addr bstr
mov buff, rax
invoke printf, CSTR("buff now = %s",10), buff
invoke exit, 0
ret
main endp
end
;Now, we could target a specific ABI by assigning the call values to the registers like
;.code
;main proc
; lea rdi, bstr
; call strdup
; mov buff, rax
;main endp
;end