Problems with loading from disk to memory
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Problems with loading from disk to memory

Hybrid View

  1. #1
    Join Date
    Jul 2011
    Posts
    1

    Exclamation Problems with loading from disk to memory

    Hi ! I`m trying to write an OS, but I already have some problems with the bootloader. I`m trying to load some assembly code from hard disk, that will set protected mode and load kernel, but i don`t think it loads what it should load. After it calls the int 13h and jumps to the address specified it does nothing and doesn`t even return.
    I am using vmware virtual machine. Can anyone give me some advice how i can verify what it loads into the memory? I also posted some code. Maybe there is some problem with the coding.
    I compiled the asm file with: nasm -f aout -o x.bin x.asm ;gcc -c -o c.o c.c ; ld -T link.ld -o pmk.com x.o c.o ; and wrote it to the third sector (x00000002-x000) with Runtime`s DiskExplorer.

    Here`s the code that should load it:

    [BITS 16]
    [ORG 0]

    jmp start

    ............

    start:
    mov ax, 0x7C0
    mov ds, ax

    mov [bootdrv], dl

    ............

    read:
    mov ax, 0x1000
    mov es, ax
    xor bx, bx

    mov ax, 0x0201
    mov ch, 0
    mov cl, 3
    mov dh, 0
    mov dl, bootdrv
    int 13h

    jc read

    jmp 1000h:0000h

    .............

  2. #2
    Join Date
    Jul 2007
    Location
    somwhere nearby
    Posts
    150

    Re: Problems with loading from disk to memory

    Quote Originally Posted by BlackJackk View Post
    Hi ! I`m trying to write an OS, but I already have some problems with the bootloader. I`m trying to load some assembly code from hard disk, that will set protected mode and load kernel, but i don`t think it loads what it should load. After it calls the int 13h and jumps to the address specified it does nothing and doesn`t even return.
    I am using vmware virtual machine. Can anyone give me some advice how i can verify what it loads into the memory? I also posted some code. Maybe there is some problem with the coding.
    I compiled the asm file with
    nasm -f aout -o x.bin x.asm ;
    gcc -c -o c.o c.c ;
    ld -T link.ld -o pmk.com x.o c.o ;
    and wrote it to the third sector (x00000002-x000) with Runtime`s DiskExplorer.

    Here`s the code that should load it:

    [BITS 16]
    [ORG 0]

    jmp start

    ............

    start:
    mov ax, 0x7C0
    mov ds, ax

    mov [bootdrv], dl

    ............

    read:
    mov ax, 0x1000
    mov es, ax
    xor bx, bx

    mov ax, 0x0201
    mov ch, 0
    mov cl, 3
    mov dh, 0
    mov dl, bootdrv
    int 13h

    jc read

    jmp 1000h:0000h

    .............
    i didnt code much in nasm, but try this and see if it works :
    Code:
            mov AX, 0x1000
            push    AX     
            Mov    BX,0x0000
            push    BX
            retf
    does your bootloader works fine?
    is it your problem that the control is not transferred to your kernel or second stage bootloader?
    if you want to know what you have in the specified address(buffer), do not jump , after reading from that specified location from hard disk , when you are done reading from hdd, try reading the contents of your buffer ( 1000:0000) if you get what you expected , then the reading was successful and the problem is somewhere else(probably in the way you are trying to transfer control to the kernel, though it is unlikely! )).
    try these and tell us what happens

    and by the way check these sites too:
    http://www.viralpatel.net/taj/home.php
    http://wiki.osdev.org/Main_Page
    and their forum ( i strongly recommend you to give it a look )
    http://forum.osdev.org/

    good luck
    Last edited by Master.; July 14th, 2011 at 02:12 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center