Author Topic: Is there a tutorial or posting for writing an assembler or compiler with steps??  (Read 345 times)

lord_raven

  • Regular Member
  • *
  • Posts: 3
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!!!

jj2007

  • Member
  • *****
  • Posts: 11768
  • Assembler is fun ;-)
    • MasmBasic
Hi Raven,

Welcome to the Forum :thup:

Here is some material to get started. The Masm32 SDK is already kind of a compiler:
Code: [Select]
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. Let us know what exactly you want to achieve, and what your current background and state of knowledge are.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8733
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

fearless

  • Member
  • ****
  • Posts: 539
    • Github
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
fearless

Lian Li PC-O11DW Case, ASUS Crosshair VIII Hero, AMD Ryzen 9 5950X, 32GB DDR4, MSI RX 5700XT, NZXT Kraken Z73, Seasonic 1000W PSU

My Github  Twitter  My Gitbook

lord_raven

  • Regular Member
  • *
  • Posts: 3
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.

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 8733
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

lord_raven

  • Regular Member
  • *
  • Posts: 3
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

Actually looks pretty interesting, the website!!! Ill check it out