Page 1 of 1

probelm loading kernel

Posted: Fri Dec 12, 2003 7:50 am
by shahzad
in the following code i'm trying to read 4 tracks from floppy and load them at address 0000:1000.This code works well for 3 tracks.But when i add lines 1 to 9 to read 4th track,system just hangs and nothig happens.if i print something before line 1 it is printed and if i print something after line 9,nothing is printed.
It means problem is in those lines from 1 to 9.
Please help me to sort out that problem.

Code: Select all

[bits 16]
[ORG 0x7c00]

jmp 0000:main
main:

        mov ax,0x0000      
        mov es,ax
        mov bx,0x1000

  mov ah,2
  mov al,18
  mov ch,1
  mov cl,1
  mov dh,0
  mov dl,0
  int 13h
  jc error

 add bx,0x2400

  mov ah,2
  mov al,18
  mov ch,2
  mov cl,1
  mov dh,0
  mov dl,0
  int 13h
  jc error

 add bx,0x2400

  mov ah,2
  mov al,18
  mov ch,3
  mov cl,1
  mov dh,0
  mov dl,0
  int 13h
  jc error

1:    add bx,0x2400

2:    mov ah,2
3:    mov al,18
4:    mov ch,4
5:    mov cl,1
6:    mov dh,0
7:    mov dl,0
8:    int 13h
9:    jc error


 jmp 0x0000:0x1000
 error:
        mov ah,0eh
        mov al,'R'
        int 10h
hang:
jmp hang
times 510- ($-$$) db 0
dw 0AA55h

Re:probelm loading kernel

Posted: Fri Dec 12, 2003 11:25 am
by df
the reason its not working.. your code is running at 0x7c00
and your loading at 0x1000, + 0x2400 + 0x2400 + 0x2400 = 0x7C00.

you overwrite your own code.

you need to alternate HEADS to properly read the tracks.

18 sectors head 0 track 0
18 sectors head 1 track 0
18 sectors head 0 track 1
18 sectors head 1 track 1

etc