flat assembler
Message board for the users of flat assembler.
Index
> DOS > Allocating large memory in flat mode |
Author |
|
JohnFound 29 Apr 2012, 18:19
Well, the whole memory should be there in the address space. Just use it as you like.
|
|||
29 Apr 2012, 18:19 |
|
Homeground 29 Apr 2012, 18:46
Really? You mean, you don't have to request memory allocation from a memory manager? You can just use all that space without permission?
|
|||
29 Apr 2012, 18:46 |
|
JohnFound 29 Apr 2012, 19:27
AFAIK, the flat mode is just that - 32bit mode with all memory accessible on its physical addresses.
|
|||
29 Apr 2012, 19:27 |
|
Tomasz Grysztar 29 Apr 2012, 20:53
The flat real mode just gives you access to memory, but whether this memory is already used by some other program is a different problem. Usually you have some XMS manager in system and you can allocate memory through it (and it guarantees there will be no conflict with any other program as long as it is respecting the XMS), but there are also some other, older methods of signalizing what extended memory is already in use, like the VDISK-style memory location (see MODES.INC in fasm's sources for an example, this method was borrowed from the open-source PMODE extender).
|
|||
29 Apr 2012, 20:53 |
|
Homeground 29 Apr 2012, 21:51
What other programs could be using the space? If you booted into real mode DOS, your program is the only one running. Unless XMS is doing stuff behind the scenes...
So I'm back to my original question. How do I get my 10Mb and know that I'm not sharing it with some other ghostly user? |
|||
29 Apr 2012, 21:51 |
|
freecrac 30 Apr 2012, 06:52
Maybe a XMS-Ramdisk-driver is in use?
... I think it is also recommend to check if our ram is free, or already in use and reserved for the bios. http://wiki.osdev.org/Detecting_Memory_(x86) PS: I can only read my answer inside the edit window, but not in the preview window and also not the submitted text. I do not know why. Dirk revolution says: Fixed it, now we can see it. |
|||
30 Apr 2012, 06:52 |
|
rugxulo 30 Apr 2012, 22:51
Use FASM + WDOSX (+ its WDMEM) and everything should be okay. Of course it can always be more complicated if you let it.
|
|||
30 Apr 2012, 22:51 |
|
Homeground 03 May 2012, 15:28
I'm looking for something a little more practical. Could someone at least tell me this: there is INT 0x15, AX = 0xE801, which returns contiguous memory blocks above 1Mb. Can I trust that this would be free memory from that point on, that is, until I exit the program, or would I have to keep checking that some other device hasn't decided to start using it?
A second point. I'm still in the process of deciding whether Flat mode is worth using at all. If it is, it might be worth getting to grips with FASM. But at the moment, I don't know, it seems a bit limited. Not only is it confined to DOS, it's confined to DOS minus memory managers. It only works on a very barebones OS. I've also noticed an anomaly. Trying to read/write with 32-bit regs, I found lods and stos and movs work fine. But not mov reg, [reg]. That instruction seems to load from some other area. At the moment I'm getting instruction codes by planting prefixes 66 and/or 67 in front of normal x86 16-bit codes, assuming that that would make them all work as 32-bit instructions. But it looks like some don't work that way. Is that the case, or have I made an error somewhere? |
|||
03 May 2012, 15:28 |
|
Dex4u 03 May 2012, 15:51
If you running under real Dos "INT 0x15, AX = 0xE801", will not work.
It would be helpful if you let us know what your program is for, as there maybe a suitable hobby OS to suit your needs. Example in DexOS your program is loaded to 8MB you call top of memory function and your program is free to use all memory from 8mb to top of memory (all 32bit usable ram, minus any drivers loaded) returned by calling the function. Theres also dos2x that does the same as DexOS, but runs on top of Dos and lets you use most Dos ints etc too, from PM. |
|||
03 May 2012, 15:51 |
|
Homeground 03 May 2012, 16:38
My program is an editor of sorts, which needs a large database containing as many Elizabethan documents as I eventually get round to downloading. It would include all the plays of Shakespeare, Marlowe, Jonson, and several others, as well as poems and pamphlets from the period. The version I have at the moment works purely in 16-bit real mode, and the database consists of files of size 8000h bytes stored on disk and loaded sequentially, if need be, using normal DOS load/save services. Obviously using disk-swap techniques instead of memory slows things down, and it would be great to have the whole database loaded at +1Mb. I could have gone the PM route, but that would mean abandoning Ketman (an app I know and like), so I thought flat mode working off Ketman would be a good compromise. And I do want to do it in assembly language, by the way, not in C or Pascal or anything else.
But it's turning out a bit more complicated than I thought. I've been experimenting since my last post, and I've discovered that putting 66/67 codes in front of mov reg, [bp] makes it read from [si] and mov reg,[bx] reads from [di]. I haven't found out all the others yet, but I'm in it now for the long haul if only I can secure memory and have it safe. Is there no way of doing that in flat mode? If int 15/ax=E801 doesn't work, what does? |
|||
03 May 2012, 16:38 |
|
revolution 03 May 2012, 16:45
Homeground: You shouldn't be putting manual 0x66/0x67 prefixes in your code. Let the assembler do its job and everything will work fine:
Code: use16 mov eax,[esi] ;assembler automatically puts prefixes when needed ;... use32 mov eax,[esi] ;assembler doesn't put prefixes when they are not required |
|||
03 May 2012, 16:45 |
|
Homeground 03 May 2012, 16:54
revolution wrote: Homeground: You shouldn't be putting manual 0x66/0x67 prefixes in your code. Let the assembler do its job and everything will work fine: As I said, Ketman is a 16-bit app. It doesn't even recognize mov eax,[esi]. Quote:
Surely, the only reason they wouldn't be required is that you are running in PM? Last edited by Homeground on 03 May 2012, 16:56; edited 1 time in total |
|||
03 May 2012, 16:54 |
|
revolution 03 May 2012, 16:54
Homeground wrote: So I'm back to my original question. How do I get my 10Mb and know that I'm not sharing it with some other ghostly user? |
|||
03 May 2012, 16:54 |
|
revolution 03 May 2012, 16:57
Homeground wrote: Surely, the only reason they [prefixes] wouldn't be required is that you are running in PM? |
|||
03 May 2012, 16:57 |
|
freecrac 04 May 2012, 13:28
http://files.osdev.org/mirrors/geezer/osd/ram/index.htm#layout
Quote: Determining extended memory size is surprisingly difficult: http://wiki.osdev.org/Memory_Map_(x86) (@revolution: Thanks for fixing my postings. If i do something wrong, please let me know.) Dirk revolution says: fixed url encoding |
|||
04 May 2012, 13:28 |
|
Homeground 04 May 2012, 21:29
Those are good links. Thanks.
|
|||
04 May 2012, 21:29 |
|
Dex4u 05 May 2012, 11:19
The problem is when Dos boots, it hooks into these ints and reports less than a MB.
Under win98 or xp this maybe be different ?. But from my test under real Dos (freeDos), it does not give true ram available. |
|||
05 May 2012, 11:19 |
|
rugxulo 05 May 2012, 13:14
Homeground wrote: I'm looking for something a little more practical. Eh? Seriously, you can do whatever you want, esp. if you're just learning. But if you use an extender like WDOSX, you don't have to worry about segment overrides or detecting memory or playing nice with memory managers or any of that goop. You just write, and it just works in almost all situations. I tried to write up a simple example, but perhaps it's not too useful. Nevertheless, it should prove the point, as it does work. (BTW, you don't have to use WFSE, but for laughs I did, esp. to prove that you could bind the data file to the extender. But that is for PE format only, so if you want something else [why? WDOSX makes it DOS friendly], it won't support that. And honestly, ~3 MB .EXE is fairly big, heheh, [though compressed, originally ~6 MB!!] but simplifies deployment of only one file, nifty right?) P.S. EXE is ~3 kb with no extender (but won't run!), ~12 kb with extender, everything else is data. So you could presumably keep the data in separate file(s) if you really wanted a slim binary. Use int 31h, 501h (DPMI) to dynamically alloc extra memory (use 500h to detect how much available) if not statically allocating at assembly time, and use WDMEM.EXE if you need to shrink resident .EXE size if shelling out to call another app. http://www.gutenberg.org/files/1581/1581.zip (1.8 MB .ZIP, aka, douayrheims.txt) Code: ; fasm bible.asm (FASM 1.70.01) ; stubit bible.exe (WDOSX 0.97) ; wadd bible.exe douayr~1.txt douayrheims.txt (from Project Gutenberg) format pe section '.text' code readable executable Komenco: mov ah,9 mov edx,bar int 21h Check_WFSE: mov eax,0FFFDh stc int 21h jc Fino cmp eax,'ESFW' ; WFSE jnz Fino Open: mov eax,3D00FFFDh mov edx,bible int 21h jc Fino mov [handle],ax SeekStart: mov eax,4200FFFDh mov bx,[handle] mov ecx,4000000 ; skip to middle of big file movzx edx,cx shr ecx,16 int 21h jc Close Read: mov eax,3F00FFFDh mov bx,[handle] mov ecx,70000 ; bigger than 64 kb mov edx,textdata int 21h jc Close DisplayText: mov ebx,67930 ; find our Amos quote mov [textdata+ebx+55+1],'$' mov ah,9 lea edx,[textdata+ebx] ; say quote int 21h Close: mov eax,3E00FFFDh mov bx,[handle] Fino: mov eax,4C00h int 21h section '.data' data readable writeable bar db '=======Amos 3:4=="Will a lion..."==' db '===================================',13,10,'$' bible db 'douayrheims.txt' handle dw 0 section '.bss' data ; automatically allocs this much at runtime textdata rb 70000 section '.reloc' fixups data readable discardable ; WDOSX needs relocs |
|||
05 May 2012, 13:14 |
|
nop 11 Jun 2012, 01:49
Homeground wrote: Really?.... You can just use all that space without permission? |
|||
11 Jun 2012, 01:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.