Page 1 of 1

ini iles parsing

Posted: Tue Jul 24, 2007 7:28 am
by bsunisol
hi,
does anybody know where i can get an instruction of parsing ini-files in assembler :?:
and please not with any api. im still doing this in real mode :!:

thanks
Uni_Sol

Posted: Tue Jul 24, 2007 7:45 am
by os64dev
uh.... ehmm... one assembler instruction for parsing ini-files :? . You do know what programming is right? Because even the smallest program for parsing ini files surely will consist of several hundred (maybe thousand) instructions. I guess you have to do some reading and accuire a bit more domain knowledge.

edit: eh an instruction as in tutorial? my bad :roll:

Re: ini iles parsing

Posted: Tue Jul 24, 2007 7:49 am
by AndrewAPrice
bsunisol wrote:hi,
does anybody know where i can get an instruction of parsing ini-files in assembler :?:
and please not with any api. im still doing this in real mode :!:

thanks
Uni_Sol
Do you have file opening/closing routines? If you know basic string manipulation, then you could through the .ini line by line. An .ini only consists of too parts:
- A category (search for [ at the beginning and ] at the end of the line to know when you're entering a new catagory).
- A variable (search the = sign, the variable name is on the left, and the value is on the right).

Then if you want to find a variable under a category, loop through until you find the category, then loop through until you find the variable, and return the value! Simple!

Posted: Tue Jul 24, 2007 7:52 am
by bsunisol
no, i just have a buffer with max 512byte sized ini file.
and no i don't want to search - i want to parse.

Posted: Tue Jul 24, 2007 8:11 am
by AJ
What are you actually trying to do?

If you are trying to convert an ini file in to a format your software recognises (parsing), you will still have to do as MessiahAndrw states.

Go through the file looking for [ and ]. Anything between these is a category. If you have some kind of state engine, you can enter the state for that category.

Next, any values in a category have the format lvalue=rvalue. I guess you already have a target data format in mind. You now need to act on rvalue as appropriate for the current state.

Cheers,
Adam

Posted: Wed Jul 25, 2007 1:20 am
by bsunisol
os64dev wrote:Because even the smallest program for parsing ini files surely will consist of several hundred (maybe thousand) instructions
Yes thats right. i wrote an interpreter for Prefix notation in c. and yes it was quite big.
so i asked for help to do that with asm for my osloader.
it is not realy necessary to do that in real mode. the file is loaded.
so i dont need the bios any more to load somethin from fdd.

Posted: Wed Jul 25, 2007 3:37 am
by XCHG
My OASML library will help you do this of course if you know how to use a simple library. It has functions for opening/closing/reading from/writing to files and etc. It works in Real Mode and has been compiled in TASM. You can simply port it to NASM and other assemblers with just a few modifications.