Full Version: New Language without ASM
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does anyone think it would be possible to write a programming language in QB that can compile to *.exe using no ASM?
Well, not a 'real' compiler, I don't think so (but if that can be proved wrong I would be happy about it). Perhaps sombody else can chime in on this cause I'm not a compiler expert.

There have been several assemblers made in Qbasic - which take .ASM code and spit out real honest-to-goodness COM executables.

The QB64 compiler was originally made in QB (now it's self compiled) but it's really a BAS to C++ translator that calls the C++ compiler after translating.

There also have been a few byte-code compilers made in QB which do produce .EXE programs. The best one I saw was called "Super Easy Basic". It was made in QB and made .EXE programs.  Such "compilers" are glorified Interpreters that have the source coded put into the EXE program somewhere and interpreted from there (instead of a seperate BAS file). But QB is so resource limited that those kind of "compilers" end up more as a novelty than a useful language. For example, there's such a compiler on the page below - made in QB and compiles small .BAS code into EXE programs.

- Dav
I thought you could do it without ASM by:
  • Making a QB program that takes the code of a new language and runs it
  • Make it get the code to run through variables inside itself
  • Compile it to *.exe
  • read the EXE code into another program using open for binary
when compiling for your new language:
  • Go through the saved EXE replacing null variables with code ( I have read a tutorial on this - it is possible
  • write the saved and edited EXE to a file
Does that count as a
(05-03-2008, 05:40 AM)Dav link Wrote:'real' compiler
The only thing I can't work out is how to write the interpreter ( is that what you call the part the run's code ).
I should really call this a project and ask someone to help me.
Could someone please help me write the interpreter please?
What commands should it have?
There are a few good tutorials in the QB Express about making an interpreter or scripting engine for games. Check out this page and do a page search for 'interpreter' and 'scripting'. That should get you started.

You could also do a search for interpreters made in Qbasic and see how they handle certain things. There's one recently posted here, which is made for QB64, should work in Qbasic:

- Dav
Thanks Dav. I am thinking the language will be something like HTML. whatever you write you see but you also get tags for things like input, let, for...next and do...loop.