ALP for DOS Protected Mode Interface(DPMI).
ALP for DOS Protected Mode Interface(DPMI).
disp macro msg ;declaration of macro
lea dx,msg
mov ah,09h
int 21h
endm
.model small
.486p ;use to access pentium instruction set
.data
dpmi dw ?,? ;declaration of variables
gdtr dq ?
idtr dq ?
ldtr dw ?
msw dw ?
tr dw ?
msg1 db 10,13,"Processror supports protected mode $"
msg2 db 10,13,"Processor does not support protected mode $"
msg3 db 10,13,"Memory allocated by the system $"
msg4 db 10,13,"Error in allocating the memory $"
msg5 db 10,13,"Memory allocated manually $"
msg6 db 10,13,"$"
msg7 db 10,13,"Contents of GDTR is $"
msg8 db 10,13,"Contents of LDTR is $"
msg9 db 10,13,"Contents of IDTR is $"
msg10 db 10,13,"Contents of MSW is $"
msg11 db 10,13,"Contents of TR is $"
.code
mov ax,@data
mov ds,ax
mov ax,1687h ;use for checking presence of DPMI
int 2fh
cmp ax,0000h
je l1
disp msg2
jmp gend
l1 : disp msg1
jmp l2
l2 : mov dpmi[0],di ;es:di gives entry address of
mov dpmi[2],es ;protected mode
mov bx,si
jmp l3
l3 : mov ah,4ah ;use for checking memory availability
int 21h
cmp si,0000h
je l5
jmp l4
l4 : mov ah,48h ;use to allocate memory manually
int 21h
jc l6
jmp l7
l5 : disp msg6
disp msg3
jmp l7
l6 : disp msg4
jmp gend
l7 : disp msg6
disp msg5
mov es,ax ;starting address of memory location
call dword ptr dpmi ;calling of DPMI
sgdt gdtr ;for storing contents of gdt in gdtr
sldt ldtr ;for storing contents of ldt in ldtr
sidt idtr ;for storing contents of idt in idtr
smsw msw ;for storing contents in msw
str tr ;for storing contents in tr
mov bx,word ptr [gdtr+4]
disp msg6
disp msg7
call display1
mov bx,word ptr [gdtr+2]
call display1
mov bx,word ptr gdtr
call display1
mov bx,ldtr
disp msg6
disp msg8
call display1
mov bx,word ptr [idtr+4]
disp msg6
disp msg9
call display1
mov bx,word ptr [idtr+2]
call display1
mov bx,word ptr idtr
call display1
mov bx,msw
disp msg6
disp msg10
call display1
mov bx,tr
disp msg6
disp msg11
call display1
disp msg6
jmp gend
proc display1 near ;procedure for display
mov cx,0404h
l8 : rol bx,0004h
mov dx,bx
and dx,000fh
cmp dx,0009h
jbe l9
add dx,0007h
l9 : add dx,0030h
mov ah,02h
int 21h
dec ch
jnz l8
ret
endp
gend : mov ah,4ch ;use for termination of program
int 21h
end
;OUTPUT
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\student>cd..
C:\Documents and Settings>cd..
C:\>cd tasm
C:\tasm>edit dpmi.asm
C:\tasm>tasm dpmi.asm
Turbo Assembler Version 2.0 Copyright (c) 1988, 1990 Borland International
Assembling file: dpmi.asm
Error messages: None
Warning messages: None
Passes: 1
Remaining memory: 472k
C:\tasm>tlink dpmi
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\tasm>cls
C:\tasm>dpmi
Processror supports protected mode
Memory allocated manually
Contents of GDTR is 8003F00003FF
Contents of LDTR is 0048
Contents of IDTR is 8003F40007FF
Contents of MSW is 003B
Contents of TR is 0028
C:\tasm>
0 comments:
Post a Comment