flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
DSblizzard 11 Dec 2019, 10:05
Language currently have almost no advantages except clean design ( and compilation to fasm
![]() Features and limitations: Dynamic typing. Uniform prefix syntax. Example: Code: (def [compile_logic_op stmt_box fn_name] [ (= stmt (get_val stmt_box)) (if (== fn_name "not") [ (compile_arg (elt stmt 1)) (emit "mov rdi, [rax + IntValOffset]") (emit "btc rdi, 0") (emit_val_to_header "int") ] 1 [ (for arg_pos in (.. 1 (len stmt)) [ (compile_arg (elt stmt arg_pos)) ]) (emit (+ "mov r10, " (str (- (len stmt) 1)))) (emit_call (with_prefix fn_name)) ]) ]) String nesting with increasing length not as 2^n but as n*log(n). Example: C, level 0: "\"" Drive, level 0: '"""' or 0"""0 C, level 1: "\"\\\"\"" Drive, level 1: ''"'"""'"'' or 1"0"""0"1 C, level 2: "\"\\\"\\\\\\\"\\\"\"" Drive, level 2: '''"''"'"""'"''"''' or 2"1"0"""0"1"2 Instead of ' characters or numbers can be almost any sequences of symbols. Strings without escape symbols can be unconvenient sometimes, but there is (chr) function for getting special characters in Drive. Minimalistic uniform ways to modify lists and strings. There is (set_sub) instead of "insert", "delete" and "append". Currently (set_sub) is implemented only for lists. Code: (= l [1 2 3]) (set_sub l [4 5] 1 2) (print l) # [1 4 5 3] (set_sub l [] 0 2) (print l) # [5 3] Arguments are passed by reference. Therefore there will be no separate getters and setters with duplication of code, no boxing of ints. Main data structure is list implemented as dynamic array with unmovable header, pointing to expandable array of pointers to "joints" which in turn point to headers for actual elements. So there is many levels of indirection, but passing by reference with simple implementation and intuitive rules cannot be made simpler - I tried. Pretty weak handling of input errors and no exception catching, only throwing. Tracing garbage collector. (if) with multiple branches. No command line flags, input file is "in.dr.txt". This file and included should have new lines consisting of single character with ASCII code 10. Parser + interpreter + python to drive compiler + drive to fasm compiler were implemented in 2 months of free time. Performance of compiled programs is similar to performance of CPython programs. Drive compiles itself (3300 lines total) in 3.26 seconds and produces 124 kloc of assembly output. (Previous numbers were for version with debugging turned on). Drive is written in itself, first version was interpreted (source in Python).
Last edited by DSblizzard on 11 Dec 2019, 14:40; edited 6 times in total |
|||||||||||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.