flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > An educational compiler project written in C# (discontinued)

Author
Thread Post new topic Reply to topic
FlierMate



Joined: 21 Jan 2021
Posts: 57
FlierMate
Sambal programming language:
Code:
LET b= 20
b /= 2
MSGBOX b
b +=30
b -=1
MSGBOX b
LET c=40
c*= 22
MSGBOX c    


Using the Sambal compiler(written in C#) will generate a Windows EXE.

This simple Win32 compiler is not using FASM as back-end compiler directly, but I reverse-engineer the PE file generated by FASM to study how to output the binary executable.

As such, the linker version is not the same with that of FASM, but dosHeader and importTable are kept intact as what have been produced by FASMW.

Admin and mods are welcome to move this topic of discussion to elsewhere if my toy programming language is irrelevant. Thanks!

EDIT: attachment removed. Please download from https://sambalcompiler.blogspot.com/
PS: This is an abandoned project.


Last edited by FlierMate on 13 Apr 2021, 16:26; edited 2 times in total
Post 04 Apr 2021, 15:04
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1027
Roman
And how compile example1.txt ?
Show example.

And what about floats nums ?
For example: a = 1.2*2+2.4
Post 05 Apr 2021, 06:03
View user's profile Send private message Reply with quote
FlierMate



Joined: 21 Jan 2021
Posts: 57
FlierMate
Roman wrote:
And how compile example1.txt ?
Show example.

And what about floats nums ?
For example: a = 1.2*2+2.4


Thanks for your interest. Just drag the source text file and drop it on icon of Sambal.exe or use command-line:
Code:
Sambal example1.txt    


Floating numbers is not supported as I am beginner to compiler scene and slow in improving the compiler. In future, iteration construct and conditional statement will be supported.

For my parser, you have to code it in something like this:
Code:
LET a=1
a *= 2
a+=3    


It is far from perfect.
Post 05 Apr 2021, 08:05
View user's profile Send private message Reply with quote
FlierMate



Joined: 21 Jan 2021
Posts: 57
FlierMate
I am having a hard time to parse code containing deeply nested conditional statement IF....THEN....ELSE. What method should I use? Binary tree? It will not be easy too to generate equivalent Assembly code with multiple jumps (especially in calculating the RVA).
Post 05 Apr 2021, 08:33
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.