Hello
I have built a simple COM file to get the size of a hard disk, using the INT 13h extensions.
It is a bit annoying the WindowsXP Command Line does not support the INT 13h extensions at all (installation check fails). So I have to reboot....
I have tried this on 2 different computers and it didn't work on both.
For some reason.... INT 13h AH=48h always fails!
I always get: Disk size ERROR
I can't get the disk info for some reason?
If someone can work out whats going on, that would be much appreciated.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; TEST Int13h IBM/MS EXTENSIONS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 100h
mov ax, cs ;just making sure....
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0xFFFE
; Intialize int13-48h buffer to zeros (probably not required)
mov di, buffer
xor ax, ax
mov cx, 42h/2
cld
rep stosw
clc
; Installation Check
mov ax, 4100h
mov bx, 55AAh
mov dx, 0080h
int 13h
jc .endInt48h
cmp bx, 0AA55h
jne .endInt48h
mov si, int48extYes
call PrintString
mov al, cl
add al, 48 ;convert to ascii
mov ah, 0Eh
xor bh, bh
mov cx, 1
int 10h ;ah=09h prints character with attributes but doesn't move cursor
mov si, newLine
call PrintString
; Get hard disk size
mov ax, 4800h
mov dx, 0080h
mov si, buffer
int 13h
jc .errDiskSize ;error so skip disk size
mov si, diskSizeYes
call PrintString
; Convert QWORD into asciiz string
; Assumes sector size is a power of 2
mov eax, [buffer+10h]
mov edx, [buffer+14h]
mov cx, [buffer+18h]
bsf cx, cx ; finding first set bit from right to left
shld edx, eax, cl ; multiply via shift
shl eax, cl ; edx:eax now has size in bytes of disk
mov ecx, 1000000 ; divide byte size by 1,000,000 to get metric size
idiv ecx
xor edx,edx ; edx:eax now has size in metric megabytes
;Loop to generate string
; [di] = destination string, it must consist of 11 space (' ') characters
; bx = string offset
; commaPos = keep track of where to insert commas
; ecx = 10 (divisor)
; edx:eax = size in megabytes, edx must be less than 10
mov di, sizeNbrStr ; string pointer
mov bx, 10 ; start at right most position
mov ecx, 10 ; divide by 10 to convert to ascii
.startStrLoop:
cmp eax, 0
je .endStrLoop
cmp [commaPos], byte 3
jb .getStrChar
mov [di+bx], byte ','
dec bx
cmp bx, 0
jl .endStrLoop
mov [commaPos], byte 0 ; reset it
.getStrChar:
idiv ecx
add dl, 48 ; remainder in dl, convert to ascii
mov [di+bx], dl ; store in memory
dec bx
cmp bx, 0
jl .endStrLoop
xor dl, dl ; edx is reset for next idiv
inc byte [commaPos]
jmp .startStrLoop
.endStrLoop:
; Print the message
mov si, sizeMsg1
call PrintString
mov si, sizeNbrStr
call PrintString
mov si, sizeMsg2
call PrintString
; Finish
jmp .quit
.endInt48h:
mov si, int48extNo
call PrintString
jmp .quit
.errDiskSize:
mov si, diskSizeNo
call PrintString
jmp .quit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;exit
.quit:
mov ax,4C00h
int 21h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; PrintString
;
; Use BIOS routines to print an asciiz string
;
; In:
; - valid stack required
; SI Address of string
;
; Out:
; - void
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PrintString:
push ax
push bx
push cx
push dx
push si
.startLoop:
mov al, byte [si]
cmp al, 0
je .endLoop
mov ah, 0Eh
xor bh, bh
mov cx, 1
int 10h ;ah=09h prints character with attributes but doesn't move cursor
mov ah, 03h
int 10h
inc si
jmp .startLoop
.endLoop:
pop si
pop dx
pop cx
pop bx
pop ax
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End PrintString:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; DATA
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
newLine: db 0Dh,0Ah,0
int48extYes db 'Int48h Extensions are installed. API Subset Support Bitmap (CL): ',0
int48extNo db 'Int48h Extensions NOT supported.',0Dh,0Ah,0
diskSizeYes db 'Got disk size',0Dh,0Ah,0
diskSizeNo db 'Disk size ERROR',0Dh,0Ah,0
sizeMsg1: db 'Disk size: ',0
sizeNbrStr: db ' ',0
sizeMsg2: db 'MB',0Dh,0Ah,0Dh,0Ah,0Dh,0Ah,0
commaPos: db 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; UNINITIALIZED DATA
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 16
buffer: rb 512