flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Booting from floppydisk.

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
TDCNL



Joined: 25 Jan 2006
Posts: 56
TDCNL
Dex4u wrote:
@TDCNL, You say you made a bootably floppy image using winimage, but what boot code did you use ?, as DOSBox is only a Dos emulator and so expects a dos layout, as in int 13h for floppy access, also as Dex4u can be run from dos.
The only thing differant in the Dex4u dos box image is the floppy driver users int 13h and not the normal pmode floppy driver.
Also if i remember right, you may need to change the image file ext ??.


Extension was no problem Dex4u, I just have made some mistake in my kernel.

The problem had to do with segment stuff, anyway I still don't 100% understand segment stuff, let me ask you the following:

If you want to access the text buffer 0B800h, then do you need to reference to it as 0:B800 (through a segment) or maybe 20:B800 ? I dont have any clue about when to use which segment.

But I do have some idea about the multiply stuff which divides segment / offset so that it's possible to have more segment:offset references that point to the same memory location.

Anyhow, could you (or someone else) explain a little of this stuff? Sorry if it's a bit offtopic but it's somewhat important Wink

_________________
:: The Dutch Cracker ::
Post 19 Apr 2006, 19:45
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Please do not make me remember this stuff, most of us want to avoid it Wink
Segments and offsets are just a method of specifying a location in memory.
EG: 3CE5:502A
^^^^ ^^^^
SEG OFS
Okay, here's the specs:
An OFFSET = SEGMENT X 16
A SEGMENT = OFFSET / 16
Some segment registers are:
CS, DS, ES, SS and FS, GF - Note: The last 2 are 386+ registers.
Some offset registers are:
BX, DI, SI, BP, SP, IP - Note: When in protected mode, you can use any
general purpose register as an offset
register - EXCEPT IP.
Some common segments and offsets are:
CS:IP - Addres of the currently executing code.
SS:SP - Address of the current stack position.
So when we refer to segments and offsets, we do so in the form:
SEGMENT:OFFSET
A good example would be:
A000:0000 - which actually corresponds to the top left of the VGA screen in
320x200x256 color mode.
Best to read up on it, there loads of tuts.
Post 19 Apr 2006, 21:53
View user's profile Send private message Reply with quote
TDCNL



Joined: 25 Jan 2006
Posts: 56
TDCNL
So if I get it correctly, in 32-bit you could also use [0xA0000] as the VGA memory pointer, and in real mode there are limits of usage with registers as pointers Question

_________________
:: The Dutch Cracker ::
Post 22 Apr 2006, 13:30
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
TDCNL wrote:
So if I get it correctly, in 32-bit you could also use [0xA0000] as the VGA memory pointer, and in real mode there are limits of usage with registers as pointers Question

it's also important to remember that you can use segments even in 32-bit mode. so, yes, you could use 0x0000:0xA0000 for VGA, just as you could use any other combination Smile
Post 22 Apr 2006, 13:37
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
To help you, take a look here: http://board.flatassembler.net/topic.php?t=5043&start=0
The first demo code is for Dos and then i have converted it to run on Dex4u OS ( which is 32bit pmode).
Post 22 Apr 2006, 14:30
View user's profile Send private message Reply with quote
TDCNL



Joined: 25 Jan 2006
Posts: 56
TDCNL
Dex4u wrote:
To help you, take a look here: http://board.flatassembler.net/topic.php?t=5043&start=0
The first demo code is for Dos and then i have converted it to run on Dex4u OS ( which is 32bit pmode).


Thanks Very Happy

_________________
:: The Dutch Cracker ::
Post 22 Apr 2006, 16:44
View user's profile Send private message Reply with quote
anton



Joined: 08 Apr 2004
Posts: 17
Location: Moscow, Russia
anton
Nyrre wrote:
Hi, I'm new to these forums Smile.

And my problem is, that I have a bootloader, but I don't know how to write it to a floppydisk so when I boot it, the bootloader would start.

Any advice?

I really recommend/advice you use Flash USB Drive for this purpose (If you have one). It works like Hard Drive (if you have modern motherboard).
I really do not recommend/advice you use floppy disks (for many reasons).
Post 05 Jun 2006, 03:37
View user's profile Send private message Reply with quote
anton



Joined: 08 Apr 2004
Posts: 17
Location: Moscow, Russia
anton
Nyrre wrote:
Thank you for your advice.
I wrote this bootloader (It's Dex4u's) to floppy:
Code:
org 0x7C00

use16   

start:
        xor   ax, ax
        mov   ds, ax
        mov   es, ax
        mov   ss, ax
        mov   sp, 0x7C00

        cli
        lgdt  [gdtr]

        mov   eax, cr0
        or    al, 0x1
        mov   cr0, eax

        jmp   0x10: protected

use32   

protected:
        mov   ax, 0x8
        mov   ds, ax
        mov   es, ax
        mov   ss, ax
        mov   esp, 0x7C00

        mov   dx, 3F2h
        mov   al, 0
        out   dx, al

        mov byte [es:0xB8000], 'P'

        jmp   $

gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000
sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CF
sys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CF
gdt_end:

gdtr:       dw gdt_end - gdt - 1
            dd gdt

times 510- ($-start)  db 0
dw 0xaa55
    

But when I booted, my computer just halted and "_"-character blinked in the lower left corner. What went wrong?


Add this before cli instruction(or somewhere else before setting PE flag in CR0)
; disable NMI
in al, 70h
or al, 80h
out 70h, al
It disables NMI - nonmaskable interrupt.
Post 05 Jun 2006, 03:45
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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 YouTube, Twitter.

Website powered by rwasa.