flat assembler
Message board for the users of flat assembler.
Index
> DOS > FASMHX Sample |
Author |
|
Japheth 03 Sep 2007, 08:13
Hello,
I made a FASM sample of a 32bit DOS extended binary with a DPMI host included. Thus no external modules are needed when running in DOS. http://www.japheth.de/Download/fasmhx.zip The DPMI host which is included (HDPMI32) has full DOS API translation, that is, you can directly use the int 21h API with pointers. |
|||
03 Sep 2007, 08:13 |
|
f0dder 03 Sep 2007, 10:38
Cute
|
|||
03 Sep 2007, 10:38 |
|
DOS386 04 Sep 2007, 20:37
> I made a FASM sample of a 32bit DOS extended binary with a DPMI host included
Thanks. |
|||
04 Sep 2007, 20:37 |
|
Japheth 05 Sep 2007, 05:46
> Cute
> Also there is a magic with DOS memory release - what is exactly being done and is it required ? the DPMI host needs 8 kB for a translation buffer. > end if should move ? > Why push'ing bp here ? code is not optimized (yet), just working. Code: mov ax, 1687h ; is DPMI host now installed? int 2Fh and ax, ax jnz nohost ; Possible ??? Confused Yes. Try to run the sample under (J)emm386 with NOVCPI. > HDPMI size reduced by almost 2 KiB command line parsing and help text are removed |
|||
05 Sep 2007, 05:46 |
|
sinsi 05 Sep 2007, 06:27
I've been looking for an example of using DPMI for ages...there doesn't seem to be any around (even in C :shudder:).
Your bit of code has shown me the way to go about it - thanks Japheth. BTW I am using the DPMI host in XP and not your built-in one, but the theory is there. Once again, thanks mate |
|||
05 Sep 2007, 06:27 |
|
Japheth 06 Sep 2007, 07:00
sinsi wrote: I've been looking for an example of using DPMI for ages...there doesn't seem to be any around (even in C :shudder:). Thanks for you kind words, sinsi! However, if you ever downloaded the FASM package in recent years you could have found the USEDPMI sample very easily. In fact, I took this sample and just modified it slightly. |
|||
06 Sep 2007, 07:00 |
|
DOS386 06 Sep 2007, 22:45
Quote: I've been looking for an example of using DPMI for ages... Why didn't you ask ? Quote: there doesn't seem to be any around Wrong There are USEDPMI (by Tomasz, since FASM 1.0 in 2000 ) and my "LE" / DOS/32A example Quote: (even in C :shudder:) Use __any__ "Hello world" program ... and a 32-bit DOS compiler Quote: BTW I am using the DPMI host in XP and not your built-in one Then you have 33 KiB of dead code Code: format MZ heap 0 entry _TEXT:start segment _TEXT use16 inithdpmi: include "HDPMI32.INC" start: push cs pop ds mov ax, 1687h ; DPMI host installed? int 2Fh test ax, ax jz havehost mov es, PSP ; Get it from somewhere push cs ; HDPMI init code returns with a RETF! call inithdpmi mov ax, 1687h ; is DPMI host now installed? int 2Fh test ax, ax jnz nohost ; Possible if "V86" NOVCPI or similar silly reasons havehost: push es ; Save DPMI entry address push di test si, si ; Requires host client-specific DOS memory? jz @f mov bx, si mov ah, 48h ; Alloc DOS memory int 21h jc nomem ; mov es, ax @@: mov bp, sp mov ax, 1 ; start a 32-bit client call far [bp] ; initial switch to protected-mode jc initfailed ;now in protected-mode mov cx,1 ;get a descriptor for the 32-bit code segment mov ax,0 int 31h jc dpmierr mov bx,ax mov dx,_TEXT32 mov cx,dx shl dx,4 shr cx,12 mov ax,7 ; set base int 31h or dx,$FFFF ; Save 1 byte ??? xor cx,cx mov ax,8 ; set limit int 31h mov cx,cs lar cx,cx shr cx,8 or ch,40h ;make a 32bit CS mov ax,9 int 31h push bx push start32 retf ;jump to 32bit CS ;------- nohost: mov dx, dErr1 error: mov ah, 9 int 21h mov ax, $4C00 int 21h nomem: mov dx, dErr2 jmp error initfailed: mov dx, dErr3 jmp error dpmierr: mov dx, dErr4 jmp error szWelcome db "welcome in protected-mode",'$' dErr1 db "no DPMI host installed",'$' dErr2 db "not enough DOS memory for client initialisation",'$' dErr3 db "DPMI initialisation failed",'$' dErr4 db "no LDT descriptors available",'$' ;--- the 32-bit code segment segment _TEXT32 use32 start32: mov edx, szWelcome ; Print welcome message mov ah,9 int 21h ; mov ax, 4C00h ; Return to DOS int 21h > the DPMI host needs 8 kB for a translation buffer. Thanks ... but my point was something else Removing the "release" code results (surprisingly) in "out of memory", nevertheless, heap 0 fixes the bug again ... is it safe to use heap 0 or are there arguments to hog all the low memory first and release it then ? > Try to run the sample under (J)emm386 with NOVCPI. Obviously ... no need to test ... What are the requirements of this version of HDPMI ? Just sitting at begin of RM segment (seem to be no fixups) and far call to IP=0 ? PSP in ES is required or no ? Can I call inithdpmi and mode-switch with ES=0 or ES=CS ? There seems to be a big magic about this PSP deal in DPMI ... but isn't it just a relict from 16-bit DPMI ? Quote:
DPMI host will hack it ? And maybe change back on every switch to RM ? So I should pick PSP and envir address before switch to PM ? Last edited by DOS386 on 07 Sep 2007, 22:47; edited 1 time in total |
|||
06 Sep 2007, 22:45 |
|
Japheth 07 Sep 2007, 06:20
Quote: heap 0 fixes the bug again ... is it safe to use heap 0 or are there arguments to hog all the low memory first and release it then ? yes, no. Quote: What are the requirements of this version of HDPMI ? Just sitting at begin of RM segment (seem to be no fixups) and far call to IP=0 ? PSP in ES is required or no ? Can I call inithdpmi and mode-switch with ES=0 or ES=CS ? it expects to reside at the begin of a segment. It might be a good idea to put it in the very first segment of a binary. ES must contain the current PSP. Quote:
the environment pointer in the PSP is never used by DOS, no need to change it once it has been converted to a selector. |
|||
07 Sep 2007, 06:20 |
|
DOS386 07 Sep 2007, 22:45
Thanks.
> ES must contain the current PSP. otherwise what disaster can happen ? And ES=DS=CS=SS is good for mode switch call ? After switch to PM, will anyone except my application use my stack ? So I could create a new one in DPMI memory and [ab]use the RM one for something else (transfer buffer for ex.) ? |
|||
07 Sep 2007, 22:45 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.