Mail Archives: djgpp/1998/07/13/14:03:08
From: | tmurez AT planete DOT net
|
Newsgroups: | alt.lang.asm,comp.lang.asm.x86,comp.os.msdos.djgpp
|
Subject: | Problem building a vesa lib with nasm&djgpp
|
Date: | 13 Jul 1998 17:51:38 GMT
|
Organization: | Planete.net, France
|
Lines: | 159
|
Approved: | <johnfine AT erols DOT com>
|
Message-ID: | <6odhfa$ec6$1@winter.news.erols.com>
|
NNTP-Posting-Host: | 207-172-240-250.s59.as4.bsd.erols.com
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hi,
(excuse my mistakes i m french)
I'm used to build programs with BC++ and his inline assembly. I wanted to
use DMPI so i got DJGPP and NASM. I've written the following routine. My
problems and what i noticed with fsdb (djgpp debugger) are written in the
routine.
*************************************************************************
vbelib.asm :
[BITS 32]
[GLOBAL _VBE2Detect]
[SECTION .text]
;Function VBE2Detect();
;out : 0 if error or vesa 2 not available, 1 if vesa 2 or greater
; available
_VBE2Detect:
pushad
mov AX, 0100h ;DPMI Allocate DOS Memory Block int 31h fct 100h
mov BX, 32 ;32 paragraphs equ to 512 bytes (vesa info header)
int 31h
jnc .MemoireAllouee ;jump if memory allocated
popad ;else pop registers and return 0
xor eax, eax
ret
.MemoireAllouee:
mov [DOSMEM_RMSEG], AX ;save real mode segment
mov [DOSMEM_SELECTOR], DX ;save mem selector
mov ecx, eax ;ecx will be linear address
and ecx, 0FFFFh ;clear high 16bits
shl ecx, 4 ;seg*16
mov [DOSMEM_LINADDR], ECX ;save linear address
mov dword [ecx+VbeInfoBlock+VbeSignature], 'VBE2'
;asking for VBE 2.0 Info
push ds
pop es ;es=ds to prevent GPF
mov EDI, RMREGS ;edi=offset RMREGS
mov dword [RM_EAX], 04F00h ;VESA Fct 00h
mov dword [RM_EDI], 0 ;offset dosmem=0
mov word [RM_ES], AX ;segment returned from int31h
mov AX, 0300h ;DPMI Simulate Real ModeInterrupt
mov BX, 0010h ;real mode int 10h
xor CX, CX ;cx=0
int 31h
jnc .Interrupt31Succes ;jump if success
;else free dos mem and return 0
mov AX, 0101h ;DPMI Free DOS Memory Block
mov DX, [DOSMEM_SELECTOR]
int 31h
popad
xor EAX, EAX
ret
.Interrupt31Succes:
mov eax, [RM_EAX]
cmp dword AX, 04Fh ;Check if Vesa fct call succeed
je .InterruptVbeSucces ;jump if success
;else free dos mem and return 0
mov AX, 0101h
mov DX, [DOSMEM_SELECTOR]
int 31h
popad
xor eax, eax
ret
;using fsdb i can tell everything works fine until here.
;the dosmem is still not used by vesa and the follwing comp
; fails because dosmem[0]=VBE2 !
;I tried to use a dumb seg and offs with vesa function and it
;returned 4fh(success) so i think the pb is that im not using
;the good real mode address...
;i think i need an advise on using dpmi fct 100h
.InterruptVbeSucces:
mov ecx, [DOSMEM_LINADDR]
cmp dword [ecx+VbeInfoBlock+VbeSignature], 'ASEV'
je .VESADetecte
mov AX, 0101h
mov DX, [DOSMEM_SELECTOR]
int 31h
popad
xor eax, eax
ret
.VESADetecte:
cmp word[ecx+VbeInfoBlock+VbeVersion], 0200h
jge .VBE2
mov AX, 0101h
mov DX, [DOSMEM_SELECTOR]
int 31h
popad
xor eax, eax
ret
.VBE2:
mov AX, 0101h
mov DX, [DOSMEM_SELECTOR]
int 31h
popad
xor eax, eax
inc eax
ret
[SECTION .data]
DOSMEM_RMSEG dw 0
DOSMEM_SELECTOR dw 0
DOSMEM_LINADDR dd 0
struc VbeInfoBlock
VbeSignature resb 4 ; VBE Signature
VbeVersion resw 1 ; VBE Version
OemStringPtr resd 1 ; Pointer to OEM String
Capabilities resb 4;Capabilities of graphics cont.
VideoModePtr resd 1 ; Pointer to Video Mode List
TotalMemory resw 1 ; Number of 64kb memory blocks
; Added for VBE 2.0
OemSoftwareRev resw 1 ; VBE implementation Software
revision
OemVendorNamePtr resd 1 ; Pointer to Vendor
Name String
OemProductNamePtr resd 1 ; Pointer to Product
Name String
OemProductRevPtr resd 1 ; Pointer to Product
Revision String
Reserved resb 222 ; Reserved for VBE
implementation
; scratch area
OemData resb 256 ; Data Area for OEM
Strings
endstruc
RMREGS:
RM_EDI dd 0
RM_ESI dd 0
RM_EBP dd 0
RM_Reserved dd 0
RM_EBX dd 0
RM_EDX dd 0
RM_ECX dd 0
RM_EAX dd 0
RM_Flags dw 0
RM_ES dw 0
RM_DS dw 0
RM_FS dw 0
RM_GS dw 0
RM_IP dw 0
RM_CS dw 0
RM_SP dw 0
RM_SS dw 0
- Raw text -