For learning sake, im trying to make a program that will parse a file. Like an assembly file is parsed. Now my problem is that the only way i can think to do this is with a bunch of cmps and jmps. There has to be a better way. Are there any tuorials on how to do this?
Posted on 2001-09-01 21:08:04 by ChimpFace9000
I don't advise doing file parsing in assembly unless you develope a high level approach. Even a simple command line can be quite tedious and bugs creep in very easily. If the syntax changes then you'll be rewriting the whole thing unless your design is very flexible.

I'm working on a parsing macro, which will generate the code for you. You only have to feed it the BNF and syntax rule macros. It's going to be nice to see how this compares to NaN's/Thomas' object version.

It's good to know how to read BNF syntax if your going to be designing parsers. (Serach the web, or look at the links page on my web site.) You could also look at other code generators. The Perl language is used for parsing files quite a bit.
Posted on 2001-09-01 21:26:47 by bitRAKE
Its nothing major. Rather simple actually. Perfect for assembly language. I just wanted to know some better ways of doing it.
Posted on 2001-09-01 21:53:09 by ChimpFace9000
Well, what is it then? Jibz has a command line lib on Iczelion's web site, with source code. That could be a good start for a small project.
Posted on 2001-09-01 23:38:32 by bitRAKE
Well, im learning to code in hex (eventually id like to make my own assembler in asm too!), and i got tired of having to type in the hex codes each time i found an error in a small hex app. So im writing something that will turn my file that has hex codes in it, into a com file. Not extremly hard, but good for learning.
Posted on 2001-09-01 23:53:21 by ChimpFace9000
That's cool. You could start with hex and then just add instructions until you have a full blown assembler. :) Should be pretty easy to do. Grab the source to a small editor and add the option to 'Save as COM'. The conversion could just be stripping out all the non-hex characters (you could error on characters of your choice as well). Then convert the hex to binary, and save the buffer. I'm sure there are many DOS solutions already coded. You can use hutch--'s QEditor for this, too. :) Or did you want to code this solution in hex, too? I'd be a very small DOS program if you restrict the input.

My first assembler was debug.exe - I piped a text file to it for assembly and then saved the COM file. You could do the same thing for this. :)
Posted on 2001-09-02 00:01:24 by bitRAKE
Just a side note.. but the object set that Thomas and myself are working on has a File class, which was designed for easy parsing, and it utilizes hutches string search algorithm as well.

There is a prototype post on the board a while ago... hmmm, you can get a Beta type version from this link Here...

Its a post i did a while ago basically giving the forum a sneak peek at what were up to. But there is an early verion of CFile in there that will do all the grunt work of file parsing for you. (As well you can tear thu the methods to learn how to do if you dont already). The idea however is to simpify design time coding with ASM already been coded.

The example posted l8r in the thread shows how I parse the first line from two separate files to make one messagebox. Pretty dumb really, but it gets the point accross.

Anywho, use it if u think you can.

Posted on 2001-09-02 00:27:04 by NaN