The MASM Forum

General => The Campus => Topic started by: lord_raven on October 03, 2021, 03:10:00 PM

Title: Is there a tutorial or posting for writing an assembler or compiler with steps??
Post by: lord_raven on October 03, 2021, 03:10:00 PM
Hi, My name is raven.  I am interested in making a assembler/compiler in masm and wonder if anyone knows where to find the good material. I have done a lot of looking on google and it seems masm tutorials are far and few. I have seen there is a posting area for this topic further down but it doesn't look like there are any good references yet!!!
Title: Re: Is there a tutorial or posting for writing an assembler or compiler with steps??
Post by: jj2007 on October 03, 2021, 07:48:39 PM
Hi Raven,

Welcome to the Forum :thup:

Here is some material to get started (https://www.jj2007.eu/Masm32_Tips_Tricks_and_Traps.htm). The Masm32 SDK is already kind of a compiler:
include \masm32\include\masm32rt.inc ; plain Masm32 for the fans of pure assembler
.code
start:
.if rv(MessageBox, 0, "Is this a compiler?", "Masm32 SDK:", MB_YESNO)==IDYES
print "Yes, it is"
.else
print "No, it isn't"
.endif
inkey "- hit any key"
exit
end start


More sophisticated stuff is possible (http://www.jj2007.eu/MasmBasicQuickReference.htm). Let us know what exactly you want to achieve, and what your current background and state of knowledge are.
Title: Re: Is there a tutorial or posting for writing an assembler or compiler with steps??
Post by: hutch-- on October 03, 2021, 07:49:10 PM
Starting from scratch, I think you are in trouble. To use MASM as a tool to design an assembler or compiler means years of experience and then more years of experience in compiler/assembler design. I would suggest you look at some of the C options as from memory years ago, the Linux guys has a basic package to start a C compiler. You will have to search Google to see if you can find it.
Title: Re: Is there a tutorial or posting for writing an assembler or compiler with steps??
Post by: fearless on October 04, 2021, 06:24:00 AM
Might be useful:

Developing a C Compiler from scratch: https://www.twitch.tv/therealnibblebits

Also worth looking for a book called Compilers : principles, techniques, and tools (Alfred V.  Aho, Monica S. Lam, Ravi  Sethi, Jeffrey D. Ullman) - also known as the Dragon book
Title: Re: Is there a tutorial or posting for writing an assembler or compiler with steps??
Post by: lord_raven on October 04, 2021, 09:08:45 AM
I actually have about 80% of a compiler written in c, for a language i am building. I asking more about some good masm tutorials on different subjects. google pulls up a lot of 404, lol. I have used nasm for awhile so I am kind of familiar with the process in asm, but just started really trying to work in masm. Doing things the window or vs way. Id like to start connecting my ast into masm instead of the gas i am currently using.
Title: Re: Is there a tutorial or posting for writing an assembler or compiler with steps??
Post by: hutch-- on October 04, 2021, 09:20:22 AM
If you are that far along with the task, learning MASM should be no big deal, it uses traditional Intel notation and has a powerful but treacherous preprocessor that does take a lot of practice. You should be able to use MASM with a C compiler, as long as they both use the same object module format, with M$ VC and MASM, they both use Microsoft COFF format.
Title: Re: Is there a tutorial or posting for writing an assembler or compiler with steps??
Post by: lord_raven on October 04, 2021, 11:18:29 AM
Quote from: fearless on October 04, 2021, 06:24:00 AM
Might be useful:

Developing a C Compiler from scratch: https://www.twitch.tv/therealnibblebits

Also worth looking for a book called Compilers : principles, techniques, and tools (Alfred V.  Aho, Monica S. Lam, Ravi  Sethi, Jeffrey D. Ullman) - also known as the Dragon book

Quote from: lord_raven on October 04, 2021, 09:08:45 AM
Actually looks pretty interesting, the website!!! Ill check it out