fix bug when edx caused too big number for division

This commit is contained in:
mykola2312 2024-08-07 18:00:01 +03:00
parent c0e1b0efc2
commit 2a66650ee0
2 changed files with 2 additions and 1 deletions

View file

@ -36,7 +36,7 @@ entry:
.bootloader: .bootloader:
call serial_init call serial_init
mov $2342424, %eax mov $9999999, %eax
call lba_to_chs call lba_to_chs
.halt: .halt:
jmp .halt jmp .halt

View file

@ -48,6 +48,7 @@ lba_to_chs:
# chs->sector = (lba % conf->num_sectors + 1); # chs->sector = (lba % conf->num_sectors + 1);
mov -4(%bp), %eax # LBA mov -4(%bp), %eax # LBA
movw disk_sectors, %bx movw disk_sectors, %bx
xor %dx, %dx
div %ebx div %ebx
# dx - sector, but needs +1 # dx - sector, but needs +1
inc %dx inc %dx