ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл лллллллллллллллллллллллл ллллллллллллллллллллллл лллллллллллллллллллллллл 32bMM : DOCUMENTATION ллллллллллллллллллллллл лллллллллллллллллллллллл ппппппппппппппппппппп ллллллллллллллллллллллл лллллллллллллллллллллллл 32 bits Memory Manager was ллллллллллллллллллллллл лллллллллллллллллллллллл Coded by LCA of Psychose Inc. ллллллллллллллллллллллл лллллллллллллллллллллллл V.1 ллллллллллллллллллллллл лллллллллллллллллллллллл ллллллллллллллллллллллл лллллллллллллллллллллллл (C)opyright 1993 by LCA of ллллллллллллллллллллллл лллллллллллллллллллллллл Psychose Inc. ллллллллллллллллллллллл лллллллллллллллллллллллл ллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл л л л л л 1) Introduction л л р/ Who's done it? л л р/ What for? л л р/ Can you use it? л л л л 2) How to use it? л л р/ New addressing mode л л р/ Use the Flat-Real mode in your programs л л р/ The Object-File : "32bMM.OBJ" л л л л 3) Do you want to contact "Psychose Inc."? л л р/ Use your MINITEL if you are French л л р/ Write to me л л л л 4) Conclusion л л л л л ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл 1) Introduction ппппппппппппппп р/ Who's done it? ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ I (LCA of "Psychose Inc.") coded this Object-File. It was of course programmed in assembler. р/ What for? ЭЭЭЭЭЭЭЭЭЭЭЭ Two years ago, I read a book in which the writer explains how to address 4 Giga-bytes in linear mode AND in real mode on a 80386. Then months after months I got bored with those coders that were proud of addressing the memory in flat protected mode. And I hope that you know that the protected-mode is slower than the real mode. Then I decided to code a Memory-Manager in Flat- Real Mode: 32bMM. The purpose of this unit is to address the memory: * in flat-mode * in real-mode * stay compatible with DOS The problem is to stay compatible with DOS. So I decided to use the XMS-driver to keep the compatibility. Therefore, if you want to use 32bMM, the XMS-Driver must be installed. Be careful : The processor MUST NOT be in protected-mode when using 32bMM. If it is, then the 32bMM won't initialize and you won't be able to use the Flat-Real mode. р/ Can you use it? ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ This Object-File is FreeWare : you can use it IF AND ONLY IF : * The program using 32bMM is not a commercial program (shareware is considered as commercial software). * You mention in your program that you used "32bMM of Psychose Inc.". * 32bMM is not modified in any way and stay in its original form. You can (sorry, YOU MUST!!!!) copy the 32bMM-package. I just hope 32bMM won't be used by little coders also called lamers............ Moreover, SEND me your programs using 32bMM, I would be pleased to try it!!! лллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл 2) How to use it? ппппппппппппппппп р/ New addressing mode: ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ With the Flat-Real Mode, you can address the whole memory that way : MOV Reg,[GS:reg32] or anyway you want, provided that the segment is "GS". Indeed, here is how the Flat-Real mode is initialized: * All segments except GS have a length of 64 Kilo-Bytes. * The segment "GS" has a length of 4 Giga-Bytes, and GS=0000h. What does it mean? Let's study this question threw some examples: 1/ Before instruction: * ESI=4000h ("4" and three "0") Instruction: * MOV AL,[ESI] Action: * the byte pointed by DS:ESI is transfered to AL... Well nothing new... 2/ Before instruction: * ESI=40000h ("4" and four "0") Instruction: * MOV AL,[ESI] Action: * ERROR because the size of DS is 64 Kilo-Bytes and ESI>65535!! 3/ Before instruction: * ESI=40000h ("4" and four "0") Instruction: * MOV AL,[GS:ESI] Action: * the byte pointed by GS:ESI is transfered to AL... That is new!! Do you understand the advantages of Flat-Real mode?? р/ Use the Flat-Real mode in your programs ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ To use 32bMM in your programs, you just have to do two things: * Insert the line: INCLUDE 32bMM.INC in your source-text. * LINK your Objects-Files with "32bMM.OBJ" Note : The 32bMM-procedures or variables are in a FAR-Segment, but the Class of this segment is 'CODE' so that you won't have problems to set the memory size needed by your program, as you'll soon see in the example-file. р/ The Object-File : "32bMM.OBJ" ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ Ok, here you'll learn how to call the 32bMM-Procedures with their parameters and so on..... 1) VARIABLES: * MemoryMode (Byte) In this variable, there is the way the memory is being allocated. That is to say, either in DOS mode or in XMS mode. In the Include File :"32bMM.INC", there are 2 Constants: DOS_Mode = 0 XMS_Mode = 1 These are the only values possible in MemoryMode. * Processor (Byte) In this variable, there is the number corresponding to the Detected- Processor. The possible values are: CPU8086 = 0 CPU286 = 2 CPU386 = 3 ; 80386 in Real-Mode CPU386P = 4 ; 80386 in Protected Mode ; If the CPU is in V86 Mode ('cause of an EMS- ; driver...), it is necessary in Protected-Mode. Note : There is no constant for the other processors and for the 80286 in Protected-Mode, because it is useless. * How reaching these constants?? Well, it is very simple: Example: mov ax,Seg MemoryMode push es mov es,ax mov al,es:MemoryMode pop es 2) PROCEDURES * Init32bMM -Parameters CALL : No parameters RETURN : AL=Processor AH=MemoryMode The content of AH and AL is the value in MemoryMode and Processor. See the previous section for more informations... Note : Other registers may have been modified. -Action You must call this procedure to initialize the Flat-Real Mode. Therefore, you should call it at the beginning of your Code. It will detect the current Processor, and it will also detect if an XMS-Driver is installed. If ever the Processor value (=AL) is not CPU386, then the Flat-Real Mode is not initialized and you should send a message to the user, either to buy a new computer, or to remove his EMS-Driver (or the program that puts the CPU in Protected-Mode!!). YOU SHOULDN'T modifie the content of GS in your code, if so, you may lose some datas... * End32bMM -Parameters CALL : No parameters RETURN : Nothing Note : some registers may have been modified. -Action This will remove the Flat-Real Mode (if Processor=CPU386). You must call this procedure at the end of your program. * AskRAM -Parameters CALL : AX = Size in Kilo-Byte of the wanted memory block. RETURN : If EAX=0 then an error has occured!! else GS:EAX=pointer to the selected block CL=MemoryMode DX=handle number -Action This procedure allocates a Memory Block. Its size is in AX (Kilo- Bytes). If an XMS-Driver was detected, then it will try to allocate an XMS- memory block. If it can't, then it'll try to allocate a DOS-Memory block. If it still can't, then EAX=0. If it could allocate the Memory Block, then EAX is a 32 bits pointer to the beginning of this block. You MUST save CL and DX in your own variables, so as to free this block later with LetRAM (See bellow). * LetRAM -Parameters CALL : CL=MemoryMode of the selected block DX=Handle Number of the selected block RETURN : Nothing -Action This procedure will free the previously selected block with AskRAM. лллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл 3) Do you want to contact "Psychose Inc."? пппппппппппппппппппппппппппппппппппппппппп If your deepest dream is to get in touch with us (hahaha!!!???), then р/ If you are French, then use your lovely MINITEL: ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ * 3615 RTEL BAL : LCA (Coder of Psychose Inc.) BAL : NAPALM (......................) BAL : HACKER CROLL (......................) р/ If you wanna contact me, then write to: ЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭЭ BERMOND Cedric (LCA) 12, Rue Paul RONIN 42100 Saint-Etienne FRANCE But, you must know that I may not answer to every letters since I am not rich and I've got lots of homework with my study. Therefore can you put in your letter a self-addressing envelope??? лллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл 3) Conclusion ппппппппппппп I hope you'll enjoy this little Object-File. Since it is the first version, there are not a lot of procedures (like knowing the free memory and so on...). But, as soon as I can, I'll improve it!! Well I haven't got anything else to tell you, so Have a good programming (ASM ONLY!!!!!!), LCA of Psychose Inc.