简体   繁体   中英

int 13h ah=08h , What am i doing wrong?

okay, so this is my code..

mov ah,08h
mov dl,80h ;have Tried for 81h,82h....
int 13h


mov ah,0Eh
    int 10h ;  printing the value in al.

int 10h prints the ascii character on screen

after booting the result is always the "smiley ascii character" for everything including 80h,81h,82h.. output screen is here http://postimage.org/image/5twm1ml5j/ it's null for ah=0

i've attached harddrives, usbs to my laptop before trying out...

What am i doing Wrong??

using qemu pc emulator and nasm

This is my entire code.

    BITS 16

start:
mov ax, 1984    ; Set up 4K stack space after this bootloader
add ax, 288     ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096

mov ax, 1984        ; Set data segment to where we're loaded
mov ds, ax




mov ah,08h
mov dl,80h
int 13h


mov ah,0Eh
int 10h








times 510-($-$$) db 0   ; Pad remainder of boot sector with 0s
dw 0xAA55       ; The standard PC boot signature

Why are you calling the int 13h? That's for disk services, in particular with ah=08h you're asking for the first drive's parameters! (check here ).
Then you're moving whatever is in ah (one of these for sure) into al, which is the character to print. The face printed is ascii char number 1 so, looking here again, you gave wrong parameters to int 13h. ;)

First, always start a boot loader with a "jmp" (required by some ancient Compaq systems instead of the "boot signature"), disable IRQs when you load SS and SP (in case CPU is 8086), never write addresses and segments in decimal (use hexadecimal), the BIOS tells you the device number in DL (don't "hard code" your own), and you shouldn't let the CPU execute data/trash (put a "jmp $" or something after the "int 0x10").

Next, the "smiley ASCII character" isn't an ASCII character. For the "code page 437" character set (what you're probably seeing) there's 2 different smiley characters - a smiley outline (character 0x01) and a solid smiley (character 0x02). These would correspond to error codes "0x01 = invalid function in AH or invalid parameter" or "0x02 = address mark not found". The first error is far more likely.

An "invalid function in AH or invalid parameter" error could be caused by having the wrong value in DL (eg wrong device number). Alternatively, the device number might be correct but the function might not be supported for that device. Due to disk size problems the old "int 0x13" functions aren't really used for hard drives anymore (they're limited to 1024 cylinders, 256 heads and 63 sectors, or about 7.875 GiB or 8.455 GB, and modern hard disks are much larger). For hard drives you should try the "int 0x13 extensions" instead - specifically, "int 0x13, ah=0x48" (see http://www.ctyme.com/intr/rb-0715.htm ).

INT 13h AH=08h: Read Drive Parameters
Parameters:

Registers
AH  08h = function number for read_drive_parameters
DL  drive index (e.g. 1st HDD = 80h)
ES:DI[4]    set to 0000h:0000h to work around some buggy BIOS

Results:

CF  Set On Error, Clear If No Error
AH  Return Code
DL  number of hard disk drives
DH[4]   logical last index of heads = number_of - 1 (because index starts with 0)
CX  [7:6] [15:8][4] logical last index of cylinders = number_of - 1 (because index starts with 0)
[5:0][4] logical last index of sectors per track = number_of (because index starts with 1)

BL[4]   drive type (only AT/PS2 floppies)
ES:DI[4]    pointer to drive parameter table (only for floppies)

http://en.wikipedia.org/wiki/INT_13H

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM