summary refs log tree commit diff stats
path: root/border.asm
diff options
context:
space:
mode:
Diffstat (limited to 'border.asm')
-rw-r--r--border.asm64
1 files changed, 64 insertions, 0 deletions
diff --git a/border.asm b/border.asm
new file mode 100644
index 0000000..12774b6
--- /dev/null
+++ b/border.asm
@@ -0,0 +1,64 @@
+section .text
+    extern height
+    extern width
+    extern write_byte
+    global draw_border
+
+draw_upper_lower_line:
+    push rbx
+
+    mov rax, '+'
+    call write_byte
+
+    mov bl, byte [width]
+_01:mov rax, '-'
+    call write_byte
+    dec bl
+    cmp bl, 0
+    jnz _01
+
+    mov rax, '+'
+    call write_byte
+
+    mov rax, 10 ;newline
+    call write_byte
+
+    pop rbx
+    ret
+
+draw_left_right_lines:
+    push rbx
+
+    mov rax, '|'
+    call write_byte
+
+    mov bl, byte [width]
+_02:mov rax, 32 ;space
+    call write_byte
+    dec bl
+    cmp bl, 0
+    jnz _02
+
+    mov rax, '|'
+    call write_byte
+
+    mov rax, 10 ;newline
+    call write_byte
+     
+    pop rbx
+    ret
+
+draw_border:
+    push rbx
+
+    call draw_upper_lower_line
+    mov bl, byte [height]
+_03:call draw_left_right_lines
+    dec bl
+    cmp bl, 0
+    jnz _03
+
+    call draw_upper_lower_line
+
+    pop rbx
+    ret