Qbasicnews.com
New Language without ASM - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html)
+--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html)
+--- Thread: New Language without ASM (/thread-10112.html)



New Language without ASM - LPG - 05-01-2008

Does anyone think it would be possible to write a programming language in QB that can compile to *.exe using no ASM?


Re: New Language without ASM - Dav - 05-03-2008

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.
http://www.qbasicnews.com/dav/projects.php

- Dav


Re: New Language without ASM - LPG - 05-03-2008

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
  • HOORAY
Does that count as a
(05-03-2008, 05:40 AM)Dav link Wrote:'real' compiler
?


Re: New Language without ASM - LPG - 05-03-2008

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?


Re: New Language without ASM - Dav - 05-06-2008

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.
http://www.petesqbsite.com/sections/express/express.shtml


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:
http://www.network54.com/Forum/190883/message/1207842314/BASIC+INTERPRETER+FOR+QB64

- Dav


Re: New Language without ASM - LPG - 05-07-2008

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.