Add fn/obj/sym macros to macros.inc

This commit is contained in:
Luke Street 2022-12-18 12:23:15 -05:00
parent 7a4e74e0e0
commit 2c871bb5b9
1 changed files with 51 additions and 0 deletions

View File

@ -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