aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2024-07-14 09:16:39 -0700
committerChristian Cunningham <cc@localhost>2024-07-14 09:16:39 -0700
commit8caa5e7cafb686ac215eb4d1eb56f8a953ea11f4 (patch)
tree9ba811f89f0940988b7bb5e577a0a6463a45cee2
parent28fbc837eaff40b0f992233e583f8352f13dddfe (diff)
Whitespace Formatting
-rw-r--r--alloc.inc8
-rw-r--r--debug.inc5
-rw-r--r--file.inc20
-rw-r--r--lstring.inc9
-rw-r--r--monad.inc18
-rw-r--r--zstring.inc8
6 files changed, 34 insertions, 34 deletions
diff --git a/alloc.inc b/alloc.inc
index da27e1e..2412d08 100644
--- a/alloc.inc
+++ b/alloc.inc
@@ -4,21 +4,21 @@
%include "sys.inc"
%endif
-%macro alloc 1
- mov rax, SYS_MMAP
+%macro alloc 0-1 rax
xor rdi, rdi ; Let Kernel give Address
mov rsi, %1 ; Size to allocate
mov rdx, 3 ; PROT_READ | PROT_WRITE
mov r10, 0x1002 ; MAP_PRIVATE | MAP_ANONYMOUS
xor r8, r8 ; fd = -1, Not backed by a file
xor r9, r9 ; offset = 0
+ mov rax, SYS_MMAP
syscall
%endm
-%macro free 2
- mov rax, SYS_MUNMAP
+%macro free 1-2 rax
mov rdi, %1 ; Address to free
mov rsi, %2 ; Size allocated
+ mov rax, SYS_MUNMAP
syscall
%endm
diff --git a/debug.inc b/debug.inc
index e401c1f..52a1509 100644
--- a/debug.inc
+++ b/debug.inc
@@ -7,11 +7,12 @@
%include "dtos.inc"
%endif
- ;; TODO: Make print without newline
-%macro DEBUG_HERE 0-1 ""
+ ;; TODO: Make print without newlineg
+%macro DEBUG_HERE 0-1 ""
section .data
make_zstring %%head, "Log: ", __?FILE?__,":"
make_zstring %%text, %1,10
+
section .text
lea rax, [rel %%head]
call print_zstring
diff --git a/file.inc b/file.inc
index bfbf8e0..220dee5 100644
--- a/file.inc
+++ b/file.inc
@@ -1,6 +1,6 @@
%ifndef FILE_INC
%define FILE_INC
-%define FBUF_DEFAULT_SIZE 16
+%define FBUF_DEFAULT_SIZE 0
%define FBUF_ALLOC_SIZE 1024*32
%ifndef SYS_INC
%include "sys.inc"
@@ -12,27 +12,27 @@
%include "zstring.inc"
%endif
-struc FileData
+struc FileData
fname: resq 1
buffer: resq 1
size: resq 1
fd: resq 1
endstruc
-%macro make_fbuffer 3
+%macro make_fbuffer 3
;; %1 = File Name
;; %2 = Buffer Name
;; %3 = Buffer Size
section .data
%2_fname: db %1,0
%2_buffer: times %3 db 0
-%2_bufferLen: equ $ - %2_buffer
db 0
+%2_bufferLen: equ $ - %2_buffer
section .bss
%2_fd: resq 1
section .data
%2_filedata:
- istruc FileData
+ istruc FileData
at fname, dq %2_fname
at buffer, dq %2_buffer
at size, dq %2_bufferLen
@@ -40,7 +40,7 @@ endstruc
iend
%endm
-%macro fopen 1
+%macro fopen 1
mov rax, SYS_OPEN
lea rdi, [rel %1_fname]
xor rsi, rsi ; READ-ONLY
@@ -48,7 +48,7 @@ endstruc
mov [rel %1_fd], rax
%endm
-%macro flen 1
+%macro flen 1
mov rax, SYS_LSEEK
mov rdi, [rel %1_fd]
mov rsi, 0
@@ -56,7 +56,7 @@ endstruc
syscall
%endm
-%macro fbegin 1
+%macro fbegin 1
mov rax, SYS_LSEEK
mov rdi, [rel %1_fd]
mov rsi, 0
@@ -64,7 +64,7 @@ endstruc
syscall
%endm
-%macro fread 1
+%macro fread 1
mov rax, SYS_READ
mov rdi, [rel %1_fd]
lea rsi, [rel %1_buffer]
@@ -72,7 +72,7 @@ endstruc
syscall
%endm
-%macro fclose 1
+%macro fclose 1
mov rax, SYS_CLOSE
mov rdi, [rel %1_fd]
syscall
diff --git a/lstring.inc b/lstring.inc
index b7eed88..7b71140 100644
--- a/lstring.inc
+++ b/lstring.inc
@@ -4,15 +4,16 @@
%include "sys.inc"
%endif
-%macro make_lstring 2-*
-%1_len_b: dq %1_len
-%1: db %2
+%macro make_lstring 2-*
+ section .data
+%1_len: dq %1_leng
+%1: db %2
%rep %0-2
db %3
%rotate 1
%endrep
%rotate 2
-%1_len equ $-%1
+%1_leng equ $-%1
%endm
section .text
diff --git a/monad.inc b/monad.inc
index 6c5f676..18d8552 100644
--- a/monad.inc
+++ b/monad.inc
@@ -4,12 +4,12 @@
%include "alloc.inc"
%endif
-struc Monad
+struc Monad
just: resq 1
exist: resb 1
endstruc
-%macro m_make 1-3 0,0
+%macro m_make 1-3 0,0
;; %1 = Name
;; %2 = Address of Structure
;; %3 = Something > 0, Nothing = 0
@@ -20,7 +20,7 @@ m_%1:
iend
%endm
-%macro m_Just 1-3 0,0
+%macro m_Just 1-3 0,0
;; %1 = Name
;; %2 = New Structure Address
;; %3 = Something > 0, Nothing = 0
@@ -38,16 +38,16 @@ m_%1:
lea rax, [%1]
%endm
-%macro m_Nothing 1
+%macro m_Nothing 1
;; %1 = Name
m_Just %1
%endm
-%macro m_return 1-2 rax
+%macro m_return 1-2 rax
m_Just %1, %2, 1
%endm
-%macro m_bind 1-2 rax
+%macro m_bind 1-2 rax
;; %1 = Callable Function with Single Argument, the Unwrapped Monad
;; %2 = Monad
;; m a -> (a -> m b) -> m b
@@ -61,7 +61,7 @@ m_%1:
%%exit:
%endmacro
-%macro m_call 1-2 rax
+%macro m_call 1-2 rax
;; %1 = Callable Function with Single Argument, the Unwrapped Monad
;; %2 = Monad
;; m a -> (a -> !) -> !
@@ -75,11 +75,11 @@ m_%1:
%%exit:
%endmacro
-%macro alloc_m 0
+%macro alloc_m 0
alloc Monad_size
%endm
-%macro free_m 1
+%macro free_m 0-1 rax
free %1, Monad_size
%endm
diff --git a/zstring.inc b/zstring.inc
index 5c88c02..4516223 100644
--- a/zstring.inc
+++ b/zstring.inc
@@ -3,12 +3,10 @@
%ifndef SYS_INC
%include "sys.inc"
%endif
-%ifndef ALLOC_INC
-%include "alloc.inc"
-%endif
-%macro make_zstring 2-*
-%1: db %2
+%macro make_zstring 2-*
+ section .data
+%1: db %2
%rep %0-2
db %3
%rotate 1