From 9e1e777a5a1f823115e15f97d91ee78eb31a8186 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Fri, 24 Dec 2021 13:24:54 +0200 Subject: [PATCH] chap-05: Add io.mac dependency file for assembly source code Signed-off-by: Razvan Deaconescu --- curs/chap-05-ihs/io.mac | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 curs/chap-05-ihs/io.mac diff --git a/curs/chap-05-ihs/io.mac b/curs/chap-05-ihs/io.mac new file mode 100644 index 00000000..61a930ed --- /dev/null +++ b/curs/chap-05-ihs/io.mac @@ -0,0 +1,22 @@ +;;; macro to use printf with 32bit parameters: +;;; - 1st parameter MUST be an immediate in backquotes `EAX=%d ECX=%x \n\x0` +;;; escape \n and \x0 only work with backquotes +;;; - rest of parameters MUST be 32bit +;;; - gen purpose and flags are preserved +;;; - stack is cleaned +%macro PRINTF32 1-* + pushf + pushad + jmp %%endstr +%%str: db %1 +%%endstr: +%rep %0 - 1 +%rotate -1 + push dword %1 +%endrep + push %%str + call printf + add esp, 4*%0 + popad + popf +%endmacro