aboutsummaryrefslogtreecommitdiff
path: root/lstring.inc
diff options
context:
space:
mode:
Diffstat (limited to 'lstring.inc')
-rw-r--r--lstring.inc35
1 files changed, 35 insertions, 0 deletions
diff --git a/lstring.inc b/lstring.inc
new file mode 100644
index 0000000..b7eed88
--- /dev/null
+++ b/lstring.inc
@@ -0,0 +1,35 @@
+%ifndef LSTRING_INC
+%define LSTRING_INC
+%ifndef SYS_INC
+%include "sys.inc"
+%endif
+
+%macro make_lstring 2-*
+%1_len_b: dq %1_len
+%1: db %2
+ %rep %0-2
+ db %3
+ %rotate 1
+ %endrep
+ %rotate 2
+%1_len equ $-%1
+%endm
+
+ section .text
+print_lstring:
+ ;; rax = lstring address
+ push rbp
+ mov rbp, rsp
+ ;;
+ push rax
+ mov rdx, [rax]
+ mov rsi, rax
+ add rsi, 8
+ mov rax, SYS_WRITE
+ mov rdi, 1
+ syscall
+ ;;
+ mov rsp, rbp
+ pop rbp
+ ret
+%endif