I am learning assembly and I need to write a program linking c and assembly. Starting at c, the user is required to enter a drive number (1=a, 2=b, 3=c etc.) then down in assembly, using Int 13h function 15h, report back what type of drive that was selected (00h=Drive not present, 01h & 02h = Diskette and 03h = fixed disk). At present my program always reports back the code 00h for Drive not present, no matter what is entered. I would like to use an error code as well, but for now would be happy just getting the interrupt to work properly.
Following is my c and assembly code so far. It is still in the working and will compile as it is, but any help or suggestions would be greatly appreciated.
C
#include <stdio.h>
extern int GetDriveType(int*, int);
void main(void)
{
int drivetype;
int drivenum;
printf("Select a drive number, 1=a: 2=b: 3=c: and so on\n"
;
scanf("%d", &drivenum);
printf("The drive type is %d\n", drivetype);
printf("0=No Drive, 1&2=Floppy drive, 3=fixed disk.\n"
;
}
Assembly
.model large
.stack 100h
public _GetDriveType
vdrivenum equ [bp+10]
adrivetype equ [bp+6]
.data
.code
_GetDriveType proc
push bp
mov bp, sp
push ds
mov dl, vdrivenum
mov ah, 15h
int 13h
mov bh, 0
mov bl, ah
lds si, adrivetype
mov ds:[si], bx
pop ds
pop bp
ret
_GetDriveType endp
end _GetDriveType
If you can help me, I will be one happy chappy.
Following is my c and assembly code so far. It is still in the working and will compile as it is, but any help or suggestions would be greatly appreciated.
C
#include <stdio.h>
extern int GetDriveType(int*, int);
void main(void)
{
int drivetype;
int drivenum;
printf("Select a drive number, 1=a: 2=b: 3=c: and so on\n"
scanf("%d", &drivenum);
printf("The drive type is %d\n", drivetype);
printf("0=No Drive, 1&2=Floppy drive, 3=fixed disk.\n"
}
Assembly
.model large
.stack 100h
public _GetDriveType
vdrivenum equ [bp+10]
adrivetype equ [bp+6]
.data
.code
_GetDriveType proc
push bp
mov bp, sp
push ds
mov dl, vdrivenum
mov ah, 15h
int 13h
mov bh, 0
mov bl, ah
lds si, adrivetype
mov ds:[si], bx
pop ds
pop bp
ret
_GetDriveType endp
end _GetDriveType
If you can help me, I will be one happy chappy.