aboutsummaryrefslogtreecommitdiff
path: root/examples/greet
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-02-07 04:26:07 -0800
committerFuwn <[email protected]>2025-06-09 00:46:03 -0700
commitbfa483c6aa5db5c9825faded62176904d516faf7 (patch)
tree043b73bdd939f955f2b4d1e6309c8b697d6e0544 /examples/greet
downloadarchived-divina-bfa483c6aa5db5c9825faded62176904d516faf7.tar.xz
archived-divina-bfa483c6aa5db5c9825faded62176904d516faf7.zip
feat(divina): pre-release :star:
Diffstat (limited to 'examples/greet')
-rw-r--r--examples/greet/Divina.lua33
-rw-r--r--examples/greet/Main.asm17
2 files changed, 50 insertions, 0 deletions
diff --git a/examples/greet/Divina.lua b/examples/greet/Divina.lua
new file mode 100644
index 0000000..30649ea
--- /dev/null
+++ b/examples/greet/Divina.lua
@@ -0,0 +1,33 @@
+-- This variable is `local`, meaning Divina cannot see it.
+--
+--- @type string
+local name = "greet-" .. tostring(os.time())
+
+-- This variable is **not** `local`, Divina can see it.
+--
+--- @class Package
+--- @field public name string
+--- @field public version string
+--- @field public description string
+--- @field public compile_options string[]
+--- @field public minimum_divina_version string
+--- @field public sources string[]
+Package = {
+ name = name,
+ version = "0.1.0",
+ description = "Greet me!",
+ compile_options = {},
+ -- The `Divina` table is a special table that you can access anywhere from
+ -- the `Divina.lua` script. It contains all sorts of important information.
+ --
+ -- Here we are setting our `minimum_divina_version` to `Divina.version`.
+ minimum_divina_version = Divina.version,
+ sources = {
+ "Main.asm",
+ },
+ type = Divina.Type.Bin,
+ arch = Divina.Arch.x64,
+}
+
+-- http://lua-users.org/wiki/ModulesTutorial
+return Package
diff --git a/examples/greet/Main.asm b/examples/greet/Main.asm
new file mode 100644
index 0000000..ae425ec
--- /dev/null
+++ b/examples/greet/Main.asm
@@ -0,0 +1,17 @@
+global main
+extern printf
+
+section .rodata
+msg: db "Hello World!", 13, 10, 0
+
+section .text
+main:
+ sub rsp, 8
+ sub rsp, 32
+ mov rcx, qword msg
+ call printf
+ add rsp, 32
+
+ xor eax, eax
+ add rsp, 8
+ ret