From 5bc355e4327dc3870d0616e44ef0d97767547f00 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 18 Dec 2022 12:23:15 -0500 Subject: [PATCH] Add fn/obj/sym macros to macros.inc Former-commit-id: 2c871bb5b90a6a8bc123443c445b30f34047a0f7 --- include/macros.inc | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/include/macros.inc b/include/macros.inc index be5ec9cd..bca05c7b 100644 --- a/include/macros.inc +++ b/include/macros.inc @@ -145,3 +145,54 @@ .set THRM1, 1020 .set THRM2, 1021 .set THRM3, 1022 + +# Defines a sized symbol with function type. +# Usage: +# .fn my_function, local +# /* asm here */ +# .endfn my_function +.macro .fn name, visibility=global +.\visibility "\name" +.type "\name", @function +"\name": +.endm + +.macro .endfn name +.size "\name", . - "\name" +.endm + +# Defines a sized symbol with object type. +# Usage: +# .obj my_object, local +# /* data here */ +# .endobj my_object +.macro .obj name, visibility=global +.\visibility "\name" +.type "\name", @object +"\name": +.endm + +.macro .endobj name +.size "\name", . - "\name" +.endm + +# Defines a sized symbol without a type. +# Usage: +# .sym my_sym, local +# /* anything here */ +# .endsym my_sym +.macro .sym name, visibility=global +.\visibility "\name" +"\name": +.endm + +.macro .endsym name +.size "\name", . - "\name" +.endm + +# Generates a relative relocation against a symbol. +# Usage: +# .rel my_function, .L_label +.macro .rel name, label +.4byte "\name" + ("\label" - "\name") +.endm