Problem loading first sector on head 0, track 1 in RealMode
Posted: Wed Dec 08, 2010 5:40 am
Hi,
if i run the following code in bochs 2.3.7 with "show dbg-all" enabled,
i get this output:
Reading of all sectors in the first track (0) works but there is a problem in track 1.
I think the offset 18432 is to high for my CHS, because it is the 36th sector!
Of course there is nothing to read (returns 0) because my image is smaller. (14kB)
Are the last 4 lines the input data for the int 0x13? But then head is not correct.
And sector doesn't change if i try to read e.g. the 3rd sector.
if i run the following code in bochs 2.3.7 with "show dbg-all" enabled,
i get this output:
Code: Select all
CPU 0: Interrupt 0x13 occured (error_code=0x0000)
00008083438i[CMOS ] CMOS read of CMOS register 0x10
00008084067i[FDD ] drive=0
00008084067i[FDD ] offset=18432
00008084067i[FDD ] bytes=512
00008084067i[FDD ] direction=from
00008084067i[FDD ] read() on floppy image returns 0
00008084075i[SYS ] pc_system: Setting INTR=0 on bootstrap processor 0
CPU 0: Interrupt 0x08 occured (error_code=0x0000)
CPU 0: Interrupt 0x1c occured (error_code=0x0000)
00008106800i[FDD ] <<READ DONE>>
00008106800i[FDD ] AFTER
00008106800i[FDD ] drive = 0
00008106800i[FDD ] head = 1
00008106800i[FDD ] cylinder = 1
00008106800i[FDD ] sector = 1
I think the offset 18432 is to high for my CHS, because it is the 36th sector!
Of course there is nothing to read (returns 0) because my image is smaller. (14kB)
Are the last 4 lines the input data for the int 0x13? But then head is not correct.
And sector doesn't change if i try to read e.g. the 3rd sector.
Code: Select all
[BITS 16]
CPU 386
GLOBAL start
STACK_ADR equ 0x7C00 ; upper startaddress of the bootsector stack
SECTION .text
start:
cli ; disable all maskable interrupts
jmp WORD 0x0000:start2 ; far jump um CS sicher auf 0x0000 zu setzen
bootlaufwerk: ; Diskettenlaufwerk von dem gebootet wurde
db 0x00 ; Standard: Laufwerk A
start2:
; wir sind bei absolut 0x07C00, der Code startet also bei 0x7C00 im Segment 0x0000
xor ax, ax ; AX = 0 setzen
mov ds, ax ; Datensegment DS zu 0x0000 setzen
mov es, ax ; Extrasegment ES zu 0x0000 setzen
mov ss, ax ; Stacksegment SS zu 0x0000 setzen
;
; Stack vorbereiten
mov ax, STACK_ADR
mov sp, ax ; Stackpointer SP setzen (direkt unterhalb Bootsektor)
mov [bootlaufwerk], dl ; Bootlaufwerk aus DL sichern
; Floppy Test
_readSector_again:
xor ax, ax
xor dx, dx
int 0x13 ; reset floppy drive
jc _readSector_again ; retry on error
mov ax, 0x000
mov es, ax ; set ES
mov ah, 0x02 ; function nr
mov al, 1 ; read only one sector
mov ch, 1 ; track (0 to N-1)
mov cl, 1 ; first sector (1 to M)
mov dh, 0 ; head (0 or 1)
mov dl, [bootlaufwerk] ; drive A
mov bx, 0x7E00 ; offset
int 0x13 ; start reading
jc _readSector_again ; retry on error
jmp $