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: 73
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!

PS: This is an abandoned project.


Description: Latest version- fixed AddressOfEntryPoint
Download
Filename: Sambal_24042021.zip
Filesize: 19.92 KB
Downloaded: 44 Time(s)



Last edited by FlierMate on 01 Jun 2021, 07:16; edited 11 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: 1057
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: 73
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: 73
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
FlierMate



Joined: 21 Jan 2021
Posts: 73
FlierMate
I see quite a few talented people write compiler that self-compile. This project is far from that level, because it is meant to learn writing a compiler in simplest way.

Example source code in Sambal programming language:
(It shows message box displaying from number 1 to number 10)
Code:
let a = 1
msgbox a
a+=1
msgbox a
a+=1
msgbox a
a+=1
msgbox a
a+=1
msgbox a
a+=1
msgbox a
a+=1
msgbox a
a+=1
msgbox a
a+=1
msgbox a
a+=1
msgbox a
msgbox good bye    


I have reattached the zip file for download because it might be useful to one or two persons. Smile

PS: Previous version has wrong AddressOfEntryPoint, might crash on Windows 7. Now fixed. Sorry!
Post 20 Apr 2021, 19:17
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.