flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
fasm9 20 Oct 2003, 12:10
lisp compiler written in fasm,
is this possible? -- ![]() -- PS: on the contrary, someone try assembler on lisp ;^) http://lasm.sourceforge.net/ (look cvs) |
|||
![]() |
|
mr_luc 29 Jun 2005, 02:37
I am seriously considering this as a laid-back kind of personal project to help me get at ease in assembler, and more at ease with the underpinnings of Lisp. (Obviously, not CL. Dynamic scope and the basic operations).
I think it would be interesting to combine my interest in the highest-level language with my interest in the lowest-level language in this way. |
|||
![]() |
|
wbk 29 Jun 2005, 17:39
the vast majority of lisp compilers and interpreters written in the 60s-80s were written in assembly.
|
|||
![]() |
|
mr_luc 29 Jun 2005, 22:45
wbk wrote: the vast majority of lisp compilers and interpreters written in the 60s-80s were written in assembly. Absolutely. Hell, two of lisp's basic operators, car and cdr, mean something like "Contents of Address Register" and "Contents of Decrement Register". My ignorance about how to accomplish most simple tasks in fasm is really my limiter here. I know for a fact that a naive, ugly lisp <1.5 implementation could potentially be quite simple, even in assembler. I need to play around with it more. To give you an idea -- I am stumped on how I would go about creating new procedures at runtime. That sort of thing must be done all of the time, but I don't know how. However, I want to keep this a simple, NAIVE project, so I don't want to go back to The Dragon Book and essentially copy the way other people have done it. I think it would be a really interesting project to see how much a true novice like me could do on a problem of this nature, with a BARE minimum of knowledge. Does the fasm community have an irc channel where I can ask simple (but hopefully not stupid) questions? The biggest question I have is: "How might I make a procedure at runtime, and then call it?" The answer to that question will determine what my next question will be. ![]() |
|||
![]() |
|
Kain 30 Jun 2005, 01:35
If you look in the "High Level Languages" forum, you'll find some other ongoing projects involving fasm, particularily Forth compilers which may help you in your own project.
|
|||
![]() |
|
THEWizardGenius 01 Jul 2005, 18:32
LISP seems like an old and weird language. However, AFAIK, it has always been an interpreted language. Some languages just can't be compiled very well, such as Perl, Forth, and LISP.
|
|||
![]() |
|
ronware 01 Jul 2005, 18:49
Forth is both an interpreted and a compiled language. It compiles quite well, thank you.
|
|||
![]() |
|
crc 01 Jul 2005, 20:32
Lisp can be (and these days often is) compiled. Take a look at sbcl for an example of this.
|
|||
![]() |
|
crc 01 Jul 2005, 22:21
I must say that I'm quite curious to know why you consider Forth to be a language that can't be compiled very well.
|
|||
![]() |
|
ezanahka 10 Jul 2005, 15:15
fasm9 wrote:
Actually having an assembler in Lisp was just an early milestone in the project plan. The project is dead btw... All the developers left the project :p The aim was to provide a framework for generating assembly programs in Common Lisp. I think that they would have been better off using FASM as a backend instead of generating raw binary. |
|||
![]() |
|
tom tobias 10 Jul 2005, 18:56
At the time of this topic's first appearance, the FASM board did not include, as it does today, a section for High Level Languages. I believe that any questions about Lisp, Forth, etc, should be consigned to the pertinant sector of the forum which addresses those aspects of programming, since these issues are fundamentally unrelated to problems with, or limitations/features of FASM, topics pertinant to MAIN.
![]() |
|||
![]() |
|
THEWizardGenius 11 Jul 2005, 19:19
FORTH can be compiled, I suppose, but it seems like it's easier to interpret it. Some languages I prefer to be interpreted, FORTH is one of them. You know, BASIC used to be interpreted but Micro$oft QuickBasic and a newer one, FreeBasic (which is 32-bit), among others, are compilers. However, I don't think LISP could be compiled very easily.
BTW, I am kind of interested in LISP but I've never been able to find any information about it. Does anyone know of a good tutorial or something online? |
|||
![]() |
|
ronware 11 Jul 2005, 20:31
Actually, Forth is both interpreted and compiled. Download Reva and play with it, and go through the tutorial provided.
The words are all compiled. What you type in or what you "include" is interpreted - but any new words you created are compiled. |
|||
![]() |
|
jvff 11 Jul 2005, 23:33
Quote:
The only way I see this is possible is to allocate memory for that procedure, just in time compile it and jump to the procedure. Not an easy job. Hope this helps, JVFF |
|||
![]() |
|
ezanahka 14 Oct 2005, 10:56
ezanahka wrote: The aim was to provide a framework for generating assembly programs in Common Lisp. I think that they would have been better off using FASM as a backend instead of generating raw binary. I whipped this one up this morning in half an hour because I couldn't figure out how to do something with FASM macros. I'm more comfortable with doing things like this with Common Lisp. So this essentially just extends CL with a function and a macro character so that I can mix asm and Lisp together and uses FASM as a backend for assembling. Code: ;;;; carrot.lisp (don't ask me why this name... the file just needed any name) ;;;; Using CommonLisp as a macro preprocessor for an assembler ;;;; Written for and used with CLISP (version 2.34 or newer) ;; check command line argument count (unless (= (length ext:*args*) 1) (format t "clisp carrot.lisp <LASM>.lasm ; processes Lisp-Assembly file and produces an .asm file.~%") (ext:bye)) ;; check that the LASM file exists (unless (probe-file (first ext:*args*)) (format t "Specified LASM file does not exist.~%")) ;; compute the name of the output file (defvar *output-file* (concatenate 'string (subseq (first ext:*args*) 0 (position #\. (first ext:*args*) :from-end t)) ".asm")) ;; a list of generated lines of code (defvar *asm* ()) (defun asm (&rest s) (setf *asm* (append *asm* (list (apply #'concatenate (cons 'string (mapcar #'princ-to-string s))))))) ;; syntax extensions: ;; % mov eax, edx % ; generates the specified block of assembly code ;; \\ ; generates a newline (only usable inside a block of assembly code) (set-macro-character #\% #'(lambda (s c) (let ((str "") char) (loop until (char= #\% (setf char (read-char s))) do (if (char= #\# char) (setf str (concatenate 'string str (princ-to-string (eval (read-preserving-whitespace s))) " ")) (setf str (concatenate 'string str (string char))))) (read-char s) `(setf *asm* (append *asm* ',(regexp:regexp-split "\\\\\\\\" str)))))) ;; processes the LASM file (load (first ext:*args*)) ;; write the generated code into the output file (with-open-file (s *output-file* :direction :output :if-exists :supersede) (dolist (i *asm*) (princ i s) (terpri s))) ;; attempt assembling the file (ext:execute "/usr/bin/fasm" *output-file*) Implementing a one way linked list dictionary for a Forth was pretty easy with this. Yeah I know its easy with FASM macros too but I needed an extra feature which I couldn't pull off. With this: Code: (defvar *_prev* 0) (defun _entry (name body) (let ((here (gensym))) (asm here ":") (asm "dd " *_prev*) (asm "dd " name) (asm "db 0") (asm "cstr '" name "'") (setf *_prev* here) (asm name ":") (asm body))) This code: Code: %use32% (_entry "foo" "mov eax, esi xor esi, esi") (_entry "foo2" "mov eax, esi xor esi, esi") Generated the following output: Code: G4091: dd 0 dd foo db 0 cstr 'foo' foo: mov eax, esi xor esi, esi G4092: dd G4091 dd foo2 db 0 cstr 'foo2' foo2: mov eax, esi xor esi, esi This is not a big system but it pretty much does what that LASM project at Sourceforge was supposed to achieve. |
|||
![]() |
|
james 15 Oct 2005, 05:01
Im writing a LISP implementation in FASM right now.
Seriously, I am. |
|||
![]() |
|
Tommy 15 Oct 2005, 08:25
james: looking forward to see the result
|
|||
![]() |
|
james 15 Oct 2005, 22:10
Keep an eye on mylisp.com !
I put it up today so that people could see what I was doing and get involved. If you cant see the site right now, then its flowing through the dns. Rgs, James. |
|||
![]() |
|
eiforall 07 Nov 2005, 16:55
It seems like mylisp.com does have only one forum message...
thoughts on list complier: because lisp is high level the compiled code will look more or less like: call CreateList push 2 call AddToList ... so on lost of push's and call's to higher level functions because your lisp compiler would already make this kind of code structures it would not be too complex to include the compiler in the program image to just-in-time compile newly defined functions because you will not be dealing with all the hundreds of instructions of the x80 just the push's and call's. Other thing it would be wise to have both compiler(for final) and interpriter (for debugging) because remember in order for people to use your lisp it needs to be easy to use and debuger is a must. Again interpriter is just a compiler that compiles and runs one line at a time and with a jit compiler that is easy to do. Why not reread the The Dragon Book? It will help. |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.