summaryrefslogtreecommitdiff
path: root/tnslc/compile/isa_x86.tnsl
diff options
context:
space:
mode:
Diffstat (limited to 'tnslc/compile/isa_x86.tnsl')
-rw-r--r--tnslc/compile/isa_x86.tnsl182
1 files changed, 0 insertions, 182 deletions
diff --git a/tnslc/compile/isa_x86.tnsl b/tnslc/compile/isa_x86.tnsl
deleted file mode 100644
index 1cb09ab..0000000
--- a/tnslc/compile/isa_x86.tnsl
+++ /dev/null
@@ -1,182 +0,0 @@
-/##
- Copyright 2021-2022 Kyle Gunger
-
- This file is licensed under the CDDL 1.0 (the License)
- and may only be used in accordance with the License.
- You should have received a copy of the License with this
- software/source code. If you did not, a copy can be found
- at the following URL:
-
- https://opensource.org/licenses/CDDL-1.0
-
- THIS SOFTWARE/SOURCE CODE IS PROVIDED "AS IS" WITH NO
- WARRANTY, GUARANTEE, OR CLAIM OF FITNESS FOR ANY PURPOSE
- EXPRESS OR IMPLIED
-#/
-
-/; construct_statement({}uint8 base, {}{}uint8 args) [{}uint8]
- /; loop (int i = 0; i < len args) [i++]
- ;add_strings(~base, ~(args{i}))
- /; if (i < len args - 1)
- ;base.append(',')
- ;base.append(' ')
- ;/
- ;/
- ;base.append('\n')
- ;return base
-;/
-
-/; literal_num ({}uint8 num) [{}uint8]
- ;{}uint8 out = "$"
- ;add_strings(~out, ~num)
- ;return out
-;/
-
-/; add_asm ({}uint8 from, to) [{}uint8]
- ;return construct_statement("\tadd ", {from, to})
-;/
-
-/; sub_asm({}uint8 from, to) [{}uint8]
- ;return construct_statement("\tsub ", {from, to})
-;/
-
-/; push_asm ({}uint8 reg) [{}uint8]
- ;return construct_statement("\tpush ", {reg})
-;/
-
-/; pop_asm ({}uint8 reg) [{}uint8]
- ;return construct_statement("\tpop ", {reg})
-;/
-
-/; cmp_asm ({}uint8 a, b) [{}uint8]
- ;return construct_statement("\tcmp ", {a, b})
-;/
-
-/; mov_asm ({}uint8 a, b) [{}uint8]
- ;return construct_statement("\tmov ", {a, b})
-;/
-
-/; jmp_asm ({}uint8 pos) [{}uint8]
- ;return construct_statement("\tjmp ", {pos})
-;/
-
-/; call_asm ({}uint8 pos) [{}uint8]
- ;return construct_statement("\tcall ", {pos})
-;/
-
-/; cjmp_asm ({}uint8 suffix, pos) [{}uint8]
- ;{}uint8 p = "\tj"
- ;add_strings(~p, ~suffix)
- ;p.append(' ')
- ;return construct_statement(p, {pos})
-;/
-
-/; mem_offset ({}uint8 pos, offset, scale) [{}uint8]
- ;{}uint8 tmp = construct_statement("(", {pos, offset, scale})
- ;tmp{len tmp - 1} = ')'
- ;return tmp
-;/
-
-/; header_guard (~{}uint8 csec) [{}uint8]
- ;{}uint8 out = "", tmp = ""
- ;tmp = push_asm("%r8")
- ;add_strings(~out, ~tmp)
- ;tmp = push_asm("%r9")
- ;add_strings(~out, ~tmp)
- ;tmp = push_asm("%r10")
- ;add_strings(~out, ~tmp)
- ;tmp = push_asm("%r11")
- ;add_strings(~out, ~tmp)
- ;tmp = push_asm("%r12")
- ;add_strings(~out, ~tmp)
- ;tmp = push_asm("%r13")
- ;add_strings(~out, ~tmp)
- ;tmp = push_asm("%r14")
- ;add_strings(~out, ~tmp)
- ;tmp = push_asm("%r15")
- ;add_strings(~out, ~tmp)
- ;add_strings(csec, ~out)
-;/
-
-/; tail_guard (~{}uint8 csec) [{}uint8]
- ;{}uint8 out = "", tmp = ""
- ;tmp = pop_asm("%r15")
- ;add_strings(~out, ~tmp)
- ;tmp = pop_asm("%r14")
- ;add_strings(~out, ~tmp)
- ;tmp = pop_asm("%r13")
- ;add_strings(~out, ~tmp)
- ;tmp = pop_asm("%r12")
- ;add_strings(~out, ~tmp)
- ;tmp = pop_asm("%r11")
- ;add_strings(~out, ~tmp)
- ;tmp = pop_asm("%r10")
- ;add_strings(~out, ~tmp)
- ;tmp = pop_asm("%r9")
- ;add_strings(~out, ~tmp)
- ;tmp = pop_asm("%r8")
- ;add_strings(~out, ~tmp)
- ;add_strings(csec, ~out)
-;/
-
-/; is_common_reg ({}uint8 n) [bool]
- ;return string_equate(n, "ax") || string_equate(n, "bx") || string_equate(n, "cx") || string_equate(n, "dx")
- || string_equate(n, "sp") || string_equate(n, "bp") || string_equate(n, "si") || string_equate(n, "di")
- || string_equate(n, "8") || string_equate(n, "9") || string_equate(n, "10") || string_equate(n, "11")
- || string_equate(n, "12") || string_equate(n, "13") || string_equate(n, "14") || string_equate(n, "15")
-;/
-
-/# Accepted common names:
-# - ax
-# - bx
-# - cx
-# - dx
-# - si
-# - di
-# - bp
-# - sp
-# - 8-15
-#/
-/; get_reg (uint size, {}uint8 common) [{}uint8]
- ;{}uint8 out = "%"
-
- /; if (common{0} !< 'a')
-
- /; if (size == 1)
- /; if(common{1} == 'x')
- ;common{1} = 'l'
- ;; else
- ;common.append('l')
- ;/
- ;; else if (size == 4)
- ;out.append('e')
- ;; else if (size == 8)
- ;out.append('r')
- ;/
-
- ;add_strings(~out, ~common)
-
- ;; else
-
- ;out.append('r')
- ;add_strings(~out, ~common)
- /; if (size == 1)
- ;out.append('b')
- ;; else if (size == 2)
- ;out.append('w')
- ;; else if (size == 4)
- ;out.append('d')
- ;/
- ;return out
- ;/
-
- ;return out
-;/
-
-/; make_label ({}uint8 func_name, func_place, ~{}uint8 csec)
- ;func_name.append("_")
- ;add_strings(~func_name, ~func_place)
- ;func_name.append(':')
- ;func_name.append('\n')
- ;add_strings(csec, ~func_name)
-;/