BOOTLOADER!!!

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
hazelnoot

BOOTLOADER!!!

Post by hazelnoot »

HI!!

i have a big problem: i have written some code:
Code:

Code: Select all

 
[BITS 16]
[ORG 0x7C00]

KERNEL_SIZE equ 76
KERNEL_SEGMENT equ 0x1000
KERNEL_START equ 1

%define   LOOPS_1       bp-2
%define   CYLINDER   bp-4
%define   offs      bp-6
%define   SECTORZ     bp-8
%define   LOGICAL    bp-10
%define seg      bp-12

SUB sp, 12

CLI                     
XOR ax, ax
MOV ss, ax
MOV sp, 0x7C00
MOV ds, ax
STI   

MOV ax, KERNEL_SEGMENT
MOV es, ax
MOV [seg], ax
MOV bx, 0
MOV [offs], bx

MOV cx, KERNEL_SIZE
MOV [LOOPS_1], cx

MOV ax, 2           ;start at sector2
MOV [LOGICAL], ax
MOV [SECTORZ], ax
MOV ax, 0
MOV [CYLINDER], ax

main_loop:
    MOV [LOOPS_1], cx       ;take the loopvar to the logical sector number

    ;MOV ax, [LOGICAL]   ;Cylinder
    ;MOV bx, 36
    ;MOV dx, 0
    ;DIV bx
    ;MOV [CYLINDER], ax

    MOV dx, 18        ;set TRACK 0 if TRACK is 18
    CMP dx, [SECTORZ]
    JE  set_null

fail:
    
    ;read the sector
    MOV ax, [seg]
    MOV bx, [offs]
    MOV ah, 2
    MOV al, 1
    MOV ch, [CYLINDER]
    MOV cl, [SECTORZ]
    MOV dx, 0
    INT 0x13
    JC  fail

    MOV cx, [LOOPS_1]
    MOV al, 1 
    ADD [LOGICAL], al
    ADD [SECTORZ], al
    MOV al, 32
    ADD [seg], al
    MOV ax, 512
    ADD [offs], al

    LOOP main_loop;

JMP KERNEL_SEGMENT:0x0000

set_null
    mov ah, 0x0e
    mov al, '.'
   mov bx, 0x0004
   int 0x10
    MOV dx, 1
    MOV [SECTORZ], dx
    ADD [CYLINDER], dx
JMP fail


but it didnt word i have used bochs for testing bochs didnt gave me an error message he puts the dots('.') and then he did nothing... please help me... THANK YOU!!!

ps: i have assembled it with nasm boot.asm -o boot -f bin
my prog what copies the bootloader on the floppy adds the boot signature!!
Pyr0Mathic

Re:BOOTLOADER!!!

Post by Pyr0Mathic »

hazelnoot wrote:
SUB sp, 12

CLI
XOR ax, ax
MOV ss, ax
MOV sp, 0x7C00
MOV ds, ax
STI

Dont know if this is the problem, but it could atleast be a small bug...

It seems to be that you first set a stack frame, the (SUB SP,12) but then you set SP whit 0x7c00.... and you forget to write anything to BP, and still you use BP to alloc var's....

so set BP whit something, so you atleast know to what adress your program is writing the local var's.


Regards.
PyroMathic
hazelnoot

Re:BOOTLOADER!!!

Post by hazelnoot »

hi
thanks for your answer but it didn't work :-(

have somebody a working bootloader what loads sectors and execute it?

please please post it!!

thanks hazelnoot!!
User avatar
gaf
Member
Member
Posts: 349
Joined: Thu Oct 21, 2004 11:00 pm
Location: Munich, Germany

Re:BOOTLOADER!!!

Post by gaf »

Hello,
if you already have to post the same problem in multiple fora you should at least include a link to the other threads. Otherwise people here just waste their time explaining stuff that you were already told in some other board. Also note that a lot of users - like me for example - actually frequent several of the os development boards..

osdcom
osdev

regards,
gaf
Post Reply