Just Getting Started memory problems

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Deoblo1

Just Getting Started memory problems

Post by Deoblo1 »

Ok I have started with the boot strap off of a floppy disk. I have done all the A20 gate stuff. (and yes i checked to see if i was in protected mode and the bios calls did not work any more). I have loaded the second stage or what will be the second stage off of the rest of the floppy disk. My big question is. how and the heck is the memory arranged. I know i am either starting out at 07c0:0000 or 0000:07c0 depending on the type of bios. But I see most of the examples setting up the stack like this.

MOV AX,9000H
MOV SS,AX
MOV SP,8000H
then the coments say something about 98000h linear. I guess my question is, if I want to place the idt slots and the gdt slots at 0000:0000 all the way up to say 1800h bytes. then say i wanted to place my stack with another 6000h bytes how would i set my stack up? the memory defaulting to 0000:9000h after i set the stack up or is it 9000h:0000? it's just the whole memory thing that is confusing me. the wonderful teachers these days dont going into that detail, it's all link it with c++ and windows.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Just Getting Started memory problems

Post by distantvoices »

Ha!

the memory thing as you call it is real mode adressing.

And don't ya dare putting idt&gdt to adress region 0x0000:0000! At the very beginning of physical memory the Bios Interrupt Vector Table is located. If you overwrite it, all the nifty int commands are gone.

As the stack is something that grows *down* I recommend you set it up this way: ss=0x8000, sp = 0xffff. This should give you plenty of stack space, hm? It would be linear 0x8ffff - out of the way of bios memory area. Hope it helps a bit. I couldn't get a clue about your whole question, only this part. Check quik-linkz for some tutorials and links, or go to www.osdever.net. May be it would help us giving advice if you reword your question?

as for the teachers: don't blame them, they canna tell you all and everything. you have to do quite a bit by yourself too for gaining knowledge above the basics.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
Tim

Re:Just Getting Started memory problems

Post by Tim »

A stack not only grows down, but it also wraps around the bottom of its segment. SP should also be word-aligned. Therefore don't use 0xffff, but use 0x0000. The first PUSH will cause SP to wrap around the bottom of the segment and the pushed value will go at the top of the segment.
Deoblo1

Re:Just Getting Started memory problems

Post by Deoblo1 »

beyond infinity -
I was going to put the idt and gdt at address 0 after I enabled the a20 gate since the int calls would be useless. OR maybe I just misunderstood you or the whole thing behind the a20 gate. Who know's i could of. as for the stack ill go with what most everyone else has done, and take it one step at a time. I am sure I will stumble appon the problem or the info. This is mostly a learning process for me. To both of you thank you and I will try both of the things you said and just play around.
bkilgore

Re:Just Getting Started memory problems

Post by bkilgore »

Deoblo1 wrote: I was going to put the idt and gdt at address 0 after I enabled the a20 gate since the int calls would be useless.
The a20 line has nothing to do with the real-mode interrupts. What you're probably thinking of is switching to protected mode.

the a20 line refers to enabling access to high memory above 1mb.

Switching to protected mode prevents you from calling real-mode interrupts (although you can still do this using v86 or by switching back to real-mode temporarily).

Either way, since you're enabling the a20 line, you have a lot of memoy to work with, so it doesn't really make sense to stick it somewhere you know its going to be writing over other information.
Deoblo1

Re:Just Getting Started memory problems

Post by Deoblo1 »

Yeah but if i am in pmode and i can not use the int calls would't I just be waisting memory if i did not use that space? Unless I switch out of pmode for a bit and then need to use an interupt call but I dont see too many reasons at this stage to do something like that.
bkilgore

Re:Just Getting Started memory problems

Post by bkilgore »

Sure, if your OS is in pmose and you don't plan on using the real-mode interrupts, you can reuse that memory.

I was just pointing out that enabling the A20 line is not the same thing as switching to pmode, and enabling the A20 line by itself does not infer that the real-mode interrupt table is no longer usable.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Just Getting Started memory problems

Post by Pype.Clicker »

you'll see the reason when you'll be adding VBE support and that you'll discover you need to call BIOS interrupt on some hardware ... leaving the lowest 64Kb of memory untouched will not cost you a lot (that's hardly 1% of your total memory space) and will save you from headaches later, imho.
Post Reply