Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Few problems

PrzemekG_PrzemekG_ Posts: 595Member
I want to make my own OS (with assembler and c using 386 instructions in pmode). I already learn many things but there are few things I still not understanding:
1. how to make it multitasking
2. how to get events
3. instancing
4. objects

1. Multi tasking
I know it is possible with a hardware interrupt but how ???

2. Events
It is simple if there is only one event target / program
eventloop:
mov eax, d_GetEvent
int 0x ; an interrupt
cmp eax, d_ExitQuery
je _ExitQuery
cmp eax, d_LostFocus
je _LostFocus
...
jmp eventloop
That structure can work in console mode, but what if I want to make a GUI where everythig is an object ?

3. Inctancing
When a program call a kernel function it's very nice :-) but what if it's an other program turn to execute and it calls the same kernel function before the kernel finish to execute the first program call, the kernel function will use the same variables and the system can crash

4. Objects
Objects are fun when created with c++ pascal or visual basic, but what if I use assembler? I have an idea of using:

an object is an area in memory (code+data) copyed from the prototype
a class is only the machine language+code between "class x {" and "}"

The theory is more than very simple but how to make it for real?
The only idea I have is to find an assembler who from an .asm file could output only the machine code and a map telling me where which procedure starts and how long is code+data


Please help me by answering one to of my problems, or by telling me where can I find a tutorial on it (and please don't tell me to read small existing os'es becose I already doing it but it sucs, but if you know a small, nice and well documented os then tell me where can I find it)

P.S. Thanks for all of you who already helped me

Comments

  • marianbvmarianbv Posts: 3Member
    : I want to make my own OS (with assembler and c using 386 instructions in pmode). I already learn many things but there are few things I still not understanding:
    : 1. how to make it multitasking
    : 2. how to get events
    : 3. instancing
    : 4. objects
    :
    : 1. Multi tasking
    : I know it is possible with a hardware interrupt but how ???
    :
    : 2. Events
    : It is simple if there is only one event target / program
    : eventloop:
    : mov eax, d_GetEvent
    : int 0x ; an interrupt
    : cmp eax, d_ExitQuery
    : je _ExitQuery
    : cmp eax, d_LostFocus
    : je _LostFocus
    : ...
    : jmp eventloop
    : That structure can work in console mode, but what if I want to make a GUI where everythig is an object ?
    :
    : 3. Inctancing
    : When a program call a kernel function it's very nice :-) but what if it's an other program turn to execute and it calls the same kernel function before the kernel finish to execute the first program call, the kernel function will use the same variables and the system can crash
    :
    : 4. Objects
    : Objects are fun when created with c++ pascal or visual basic, but what if I use assembler? I have an idea of using:
    :
    : an object is an area in memory (code+data) copyed from the prototype
    : a class is only the machine language+code between "class x {" and "}"
    :
    : The theory is more than very simple but how to make it for real?
    : The only idea I have is to find an assembler who from an .asm file could output only the machine code and a map telling me where which procedure starts and how long is code+data
    :
    :
    : Please help me by answering one to of my problems, or by telling me where can I find a tutorial on it (and please don't tell me to read small existing os'es becose I already doing it but it sucs, but if you know a small, nice and well documented os then tell me where can I find it)
    :
    : P.S. Thanks for all of you who already helped me
    :


    Hi!

    Since you are here (on programmersheaven.com) I think you could check nasm. Give it a try, and you should find an assembler with an almost object-oriented syntax. They consider indeed the model of an object being a memory context, they use named memory context, and they call functions defined in a memory context using a syntax like mem_ctx.fn_name. I think that the ideea could be further developped but I don't feel like being in the best position to lend some help -- I still have lots to learn for myself before that...
  • eikedehlingeikedehling Posts: 123Member
    : : I want to make my own OS (with assembler and c using 386 instructions in pmode). I already learn many things but there are few things I still not understanding:
    : : 1. how to make it multitasking
    : : 2. how to get events
    : : 3. instancing
    : : 4. objects
    : :
    : : 1. Multi tasking
    : : I know it is possible with a hardware interrupt but how ???
    : :
    : : 2. Events
    : : It is simple if there is only one event target / program
    : : eventloop:
    : : mov eax, d_GetEvent
    : : int 0x ; an interrupt
    : : cmp eax, d_ExitQuery
    : : je _ExitQuery
    : : cmp eax, d_LostFocus
    : : je _LostFocus
    : : ...
    : : jmp eventloop
    : : That structure can work in console mode, but what if I want to make a GUI where everythig is an object ?
    : :
    : : 3. Inctancing
    : : When a program call a kernel function it's very nice :-) but what if it's an other program turn to execute and it calls the same kernel function before the kernel finish to execute the first program call, the kernel function will use the same variables and the system can crash
    : :
    : : 4. Objects
    : : Objects are fun when created with c++ pascal or visual basic, but what if I use assembler? I have an idea of using:
    : :
    : : an object is an area in memory (code+data) copyed from the prototype
    : : a class is only the machine language+code between "class x {" and "}"
    : :
    : : The theory is more than very simple but how to make it for real?
    : : The only idea I have is to find an assembler who from an .asm file could output only the machine code and a map telling me where which procedure starts and how long is code+data
    : :
    : :
    : : Please help me by answering one to of my problems, or by telling me where can I find a tutorial on it (and please don't tell me to read small existing os'es becose I already doing it but it sucs, but if you know a small, nice and well documented os then tell me where can I find it)
    : :
    : : P.S. Thanks for all of you who already helped me
    : :
    :
    :
    : Hi!
    :
    : Since you are here (on programmersheaven.com) I think you could check nasm. Give it a try, and you should find an assembler with an almost object-oriented syntax. They consider indeed the model of an object being a memory context, they use named memory context, and they call functions defined in a memory context using a syntax like mem_ctx.fn_name. I think that the ideea could be further developped but I don't feel like being in the best position to lend some help -- I still have lots to learn for myself before that...
    :

    The multitasking is not quite easy, but if you made it to enter PM, you can easily do that as well ...
    All you need is making an TSS (task state segment, area of memory which saves the tasks processor state in case the task is not running) for each task you are running and then have an intelligent algorithm (the scheduler) select which tasks to run. The scheduler can easiest be called by timer interrrupt, so tasks are switched on a regular time basis. just check the intel docs about how a TSS looks like (basically a 103 byte block of memory...), and about the descriptor(s)(system descriptor of type 9(inactive)/11(active)) you need to make for it. To activate a task, just do a far jump to any offset within the TSS (not the tasks code segment !!) It is quite usefull to look at freeware code of some OSses, to get idea how this works. Before actually starting to switch, you need to load an initial value for the task register 'ltr', so the CPU knows where to store info about the current task you run. (kernel task probably).

    Hope this doesn't confuse you to much ... i really advise reading the intel docs about system programming on their processors. They are quite chaotic, info is spread around quite a bit, but they are really, really usefull! (the hardcopy books are actually better: not as chaotic ;-)

    Eike.

    SUSE LINUX 7.3 PRO - The world starts behind windows

Sign In or Register to comment.