flat assembler
Message board for the users of flat assembler.

Index > DOS > Accessing low memory from DPMI

Author
Thread Post new topic Reply to topic
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 29 Dec 2006, 07:46
How to access low DOS memory from DPMI ? Question

Do I have full access to all the area from 0 to$FFFFF or even $10FFFF ?

DGJPP provides the functions "dosmemget" and dosmemput" for this -
how to do in ASM ? What is the best way to write a bigger amount of
data into VGA memory (80386 code, no MMX) ?

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 29 Dec 2006, 07:46
View user's profile Send private message Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
Japheth 29 Dec 2006, 23:24
> How to access low DOS memory from DPMI ?

It depends Smile

> Do I have full access to all the area from 0 to$FFFFF or even $10FFFF ?

0-FFFFFh yes, 0-10FFFFh not necessarily.

> DGJPP provides the functions "dosmemget" and dosmemput" for this -
> how to do in ASM ?

Do you want access to conventional memory or do you want to allocate conventional memory. This is a tiny difference.
To get/free/resize DOS memory, there exist some DPMI functions (0x100-0x102).

> What is the best way to write a bigger amount of
> data into VGA memory (80386 code, no MMX) ?

"rep movsd" will be a good starting point Smile.
Post 29 Dec 2006, 23:24
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 30 Dec 2006, 01:33
Thanks.

Quote:
0-10FFFFh not necessarily.


No problem Wink

Quote:
Do you want access to conventional memory or do you want to allocate conventional memory. This is a tiny difference.


Access only (VGA, "environment"). Is it accessible without previous
creation/allocation of segments, "selectors", etc. ?

Quote:
"rep movsd" will be a good starting point


How to tell the CPU to write into low memory instead my great 4 MB segment ?

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 30 Dec 2006, 01:33
View user's profile Send private message Reply with quote
Japheth



Joined: 26 Oct 2004
Posts: 151
Japheth 30 Dec 2006, 08:11
> How to tell the CPU to write into low memory instead my great 4 MB segment ?

this is a weakness of the simple MZ file format approach: you can easily get a flat memory-model, but it is not zero-based (that's why PE or LE formats are a better choice for 32bit and why almost all DOS extenders [except DJGPP] use them). Best thing to do for MZ is to allocate another descriptor and make it zero-based, 4 GB in size. Then use FS or GS to permanently hold it. For memory transfers with "REP MOVSD" you mightl then have to change DS/ES temporarily.
Post 30 Dec 2006, 08:11
View user's profile Send private message Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1900
DOS386 31 Dec 2006, 03:36
Thanks.

Quote:
(that's why PE or LE formats are a better choice for 32bit and why almost all DOS extenders [except DJGPP] use them)


I have my reasons NOT to use extenders/compilers/linkers
using/producing bloated executables full of garbage and external crappy code Wink

Quote:
this is a weakness of the simple MZ file format approach: you can easily get a flat memory-model, but it is not zero-based


Quote:
Best thing to do for MZ is to allocate another descriptor and make it zero-based, 4 GB in size.


Is this need of an additional segment the ONLY problem ?

Quote:
Then use FS or GS to permanently hold it. For memory transfers with "REP MOVSD" you mightl then have to change DS/ES temporarily.


COOL. Seems to work. I can read out the complete DOS memory and write
to VGA also, and display a bitmap.

Code:
    mov cx,1
    xor ax,ax
    int 31h           ; allocate descriptor for data
    mov di,ax
    mov dx,ds
    lar cx,dx
    shr cx,8
    or  cx,0C000h
    mov bx,di
    int 31h           ; set data descriptor access rights
    mov ecx,0   ;ZERO
    mov edx,0
    mov ax,7          ; set descriptor base address CX:DX // CX high
    int 31h
    mov bx,di   ;HACK
    int 31h
    mov cx,0FFFFh
    mov dx,0FFFFh
    mov ax,8          ; set segment limit to 4 GB
    int 31h           ; result : di : data descriptor
    


Is this ^^^ the correct way to create the segment ? Seems to work. But: 2
segments (start segment from USEDPMI example and my low segment)
share same memory: no problem in PM ???

Code:
       push ds
       pop es         ; legal ???
       cld
       mov ecx,$40000 ; 256K * 4 bytes
       mov esi,0
       mov edi,$1000
       rep movs dword [es:edi],[fs:esi]  ; low segment is in fs
    


Correct way ^^^ to read out all 1 MB, suppposing DPMI segment is 4 MB
and code <4 KB ???

Code:
       push fs         ;low segment in fs
       pop es         ; legal ???
       cld
       mov ecx,16000 ; 320*200 = 64000
       mov esi,$3F0600      ;stored in last 64'000 bytes
       mov edi,$A0000
       rep movs dword [es:edi],[ds:esi]
    


Writing ^^^ complete 64'000 bytes into VGA - correct ? Seems to work.

_________________
Bug Nr.: 12345

Title: Hello World program compiles to 100 KB !!!

Status: Closed: NOT a Bug
Post 31 Dec 2006, 03:36
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.