From 6a2ccaf2b63e89e17e8de949137c3039e10e43d7 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