flat assembler
Message board for the users of flat assembler.

Index > Windows > The Problem

Author
Thread Post new topic Reply to topic
Imagist



Joined: 13 Jun 2004
Posts: 114
Location: Pennsylvania (USA)
Imagist 27 Jul 2004, 03:44
There's a thing at my school where we have to sign up to do a project over the summer. The project can be almost anything, but it has to be well thought out and described on paper, or it won't be accepted. I signed up to learn ASM (knowing nothing about it at the time) and as a demonstration of having learned it, I decided that I would create a basic HLL using ASM.

Now, I've chosen an assembler and begun to learn it, and have hit a brick wall. I am nowhere near being able to create a compiler for an HLL. All I need is one that can create loops and if statements, and do output and input easily, but I can't even do that. The deadline is at the end of August.

I do have one advantage. The board I have to present the project to will be made up of people who know nothing about programming, so I can talk over their heads. I just have to show them I did something with FASM in the process.

Does anyone have any tutorials or source code or anything that I could look at to figure out how to make a compiler for an HLL? I'd like to learn FASM as a whole in the future, but for now I only need to know how to create compilers.

_________________
Many things are possible. Few things are likely.
Post 27 Jul 2004, 03:44
View user's profile Send private message Visit poster's website Reply with quote
Imagist



Joined: 13 Jun 2004
Posts: 114
Location: Pennsylvania (USA)
Imagist 27 Jul 2004, 03:52
Here's what I would like to do, if I can (I may have to completely abandon this). The features:

-Compile directly from a .txt (so you can code in notepad or whatever).
-Compile directly to a .exe, with the option of compiling into a .asm source file (FASM syntax, of course).
-Allow inline FASM.
-Have functions for input and output.
-Have control structures (if statements, while, do-while loops).
-Variable creation and manipulation.

Basically, that's all I need. I could probably get away with doing even less.

_________________
Many things are possible. Few things are likely.
Post 27 Jul 2004, 03:52
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 27 Jul 2004, 04:04
You have half of the work done with hll macros shipped on standard win32 fasm package. Decide which syntax you want and start from there.

Use fasm as the compiler and your txt will show the language you create.
Writing a parser is somehow more complex and time consumming. Deadline is imminent so doing it with macros will permit you to concentrate on the language and not on bugfixing.

Post your macros as you develop them and you will find here people that could help you in the process.
Post 27 Jul 2004, 04:04
View user's profile Send private message Yahoo Messenger Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
S.T.A.S. 27 Jul 2004, 05:08
I have to agree with pelaillo, writting a parser is too complex to be finished in one month.
AFAIK, the best "tutorial" is Dragon Book - Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools. Addison-Wesley, Reading, MA, USA, 1986

And again pelaillo is right, FASM has very strong macro capabilities, so it's easier to write some "envelope" macro for each statement of your HLL.
E.g. it's possible to write C-like "printf" macro, which will call in turn wvsprintf, GetStdHandle & WriteFile to write something to concole.
Though I have no ideas haw to implement "A=B+C" stuff Sad
Post 27 Jul 2004, 05:08
View user's profile Send private message Reply with quote
Imagist



Joined: 13 Jun 2004
Posts: 114
Location: Pennsylvania (USA)
Imagist 27 Jul 2004, 15:46
Thank you for your help. I will probably need a lot of help, since I am new to this, and ASM is very different from the previous languages I have learned.
Post 27 Jul 2004, 15:46
View user's profile Send private message Visit poster's website Reply with quote
Imagist



Joined: 13 Jun 2004
Posts: 114
Location: Pennsylvania (USA)
Imagist 29 Jul 2004, 11:24
Wait, I'm a bit confused. Are you saying that I should modify the FASM compiler to allow HLL-type macros?
Post 29 Jul 2004, 11:24
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 29 Jul 2004, 11:37
Given the timetable involved, I'd say just write HLL macros in FASM and use 'include' to include them with your programs. It'd be similar to the way C is built up from a small core set of functions. In this case, FASM would be the core, and your macros+library would replace LIBC. Smile
Post 29 Jul 2004, 11:37
View user's profile Send private message Visit poster's website Reply with quote
Imagist



Joined: 13 Jun 2004
Posts: 114
Location: Pennsylvania (USA)
Imagist 29 Jul 2004, 14:40
Oh, I see.

In the last three days I wrote a sort of "precompiler" in Java that takes code written in the Spoon Language (the language I created) and "compiles" it into FASM source code. I still plan to write a compiler in FASM, but if all else fails, I can hand in the piece of junk I created in Java.

When I'm done tweaking the Java code, I might toss it up here. Even though it is written in Java (and therefore is unbearably slow) it does cut down on some of the more tedious coding, and could be a really helpful coding tool if rewritten in FASM.
Post 29 Jul 2004, 14:40
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.