From 6cccbf0a18341f4e3b70258c504d8508ef361721 Mon Sep 17 00:00:00 2001 From: ergz Date: Wed, 23 Nov 2022 00:02:57 -0800 Subject: [PATCH] adds example for calling external C func from masm --- src/1_4.asm | 4 +++- src/1_5.asm | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/1_5.asm diff --git a/src/1_4.asm b/src/1_4.asm index 6dcc777..5f599d0 100644 --- a/src/1_4.asm +++ b/src/1_4.asm @@ -10,4 +10,6 @@ main proc ; the main procedure call asm_proc ; call our proc ret main endp - end \ No newline at end of file + end + + diff --git a/src/1_5.asm b/src/1_5.asm new file mode 100644 index 0000000..b42aa3a --- /dev/null +++ b/src/1_5.asm @@ -0,0 +1,21 @@ + option casemap:none + + .data + +fmt_str byte 'Hello World!', 10, 0 ; here 10 is the newline feed + + .code + + externdef printf:proc + + public asm_func + +asm_func proc + sub rsp, 56 + lea rcx, fmt_str ; load the format string into the RCX register to be used by the printf + call printf + add rsp, 56 + ret +asm_func endp + + end \ No newline at end of file