flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Starting with some complex stuff, Memory Segmentation in RM?

Author
Thread Post new topic Reply to topic
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
Been playing around with MikeOS,
MikeOS has a 64K segment to do stuff. But the thing is I
want 128K.
I know sounds noobish (is that a word?)
Alright some details :
I discovered mikeos loads at 2000H in RAM.
And it sets up ss (stack segment) to 0, and sp to fffh,
Then it makes all the other seg regs to line up with the kernel
Load point,
And the memory structure is like
Small mikeos 64K segment.
Kernel 24K
Disk buffer 8K
Free space in that segment : 32K
Now just after this segment I want to have another 64K segment,
So that equals 128K of RAM.
How would I start about? Would that be tough? Or its simple?
Help would be appreciated...[/list]

_________________
"Those who can make you believe in absurdities can make you commit atrocities" -- Voltaire https://github.com/Benderx2/R3X
XD
Post 22 Oct 2013, 12:33
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
In 16bit your are always limited to a 64K segment in cs/ds/es/ss:xx and so cannot cross a 64k boundary. However, you can split accesses across multiple segments and address up to 1MB by changing the segment register e.g. from my boot sector disk driver:
Code:
        ...
        mov dx,es ; save the segment to a temporary
        add bx,DISK_SIZE_SECTOR ; increase the offset
        jnc @f ; if it didn't wrap to 0, don't increment the segment...

        add dx,0x1000 ; ...otherwise increment the segment

    @@:

        mov es,dx ; restore the temporary
        ...    
The only thing I don't know, is whether this is a valid assumption for MikeOS that there is nothing important in the next segments (my guess is there isn't).
Post 22 Oct 2013, 18:03
View user's profile Send private message Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 238
Location: the-ideom
Mike Gonta
MikeOS32 has 4 Gb segments.

_________________
Mike Gonta
the-ideom - now you know how to compile

https://mikegonta.com
Post 22 Oct 2013, 20:28
View user's profile Send private message Visit poster's website Reply with quote
sid123



Joined: 30 Jul 2013
Posts: 340
Location: Asia, Singapore
sid123
@cod3b453 I see you allocated a 64K segment through ES and DX.
Now is this segment ready to use? MikeOS programs load at 32K, Since a segment has been created, is it possible to load stuff at 64K, and this segment would last till 128K. Right?
@mikegonta Lol, but the thing is I want to learn OSDeving step by step, like assembly, first learn dos programming 16 bit, then Win32, and then Win64.
I want to get the most out of real mode before shifting to protected mode, so I think messing with segment registers may help in the learning part....
Post 23 Oct 2013, 08:40
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
In my example the segment at es:0 is preallocated and so big enough for the disk data. I have no idea how MikeOS works or how it allocates memory so I can't help you but you can always address 64k. If MikeOS provides a memory allocation function you should probably use that to find a safe location to use for the size you've asked for.

To be honest there's very little in 16bit you should focus on: VGA/VESA for basic screen stuff, basic read-only disk driver(s), BIOS E820, A20 and switching to protected mode.
Post 23 Oct 2013, 17:55
View user's profile Send private message Reply with quote
c.j.gowett



Joined: 31 Dec 2013
Posts: 12
c.j.gowett
Like cod3b453 said, I'm sure you can split access between segments, but I haven't tested it myself. If you want more space, try 32-bit protected mode. you'll have 0xFFFFFFFF amount of space, or 4294967296 bytes (4 GB) of space. Some of the space is used for stuff like video memory, BIOS Data Area, and other device memory. Also, in 32-bit protected mode, you won't have interrupts, so you'll have to use i/o ports to write back to the hard disk or use other interrupts.
Post 16 Jan 2014, 20:31
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.