ini iles parsing

Programming, for all ages and all languages.
Post Reply
User avatar
bsunisol
Member
Member
Posts: 40
Joined: Fri Apr 06, 2007 3:00 pm
Location: Germany, Berlin and near Hamburg

ini iles parsing

Post 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
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post 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:
Last edited by os64dev on Tue Jul 24, 2007 7:52 am, edited 2 times in total.
Author of COBOS
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: ini iles parsing

Post 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!
My OS is Perception.
User avatar
bsunisol
Member
Member
Posts: 40
Joined: Fri Apr 06, 2007 3:00 pm
Location: Germany, Berlin and near Hamburg

Post 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.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
bsunisol
Member
Member
Posts: 40
Joined: Fri Apr 06, 2007 3:00 pm
Location: Germany, Berlin and near Hamburg

Post 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.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post 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.
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
Post Reply