Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to index page
Thread view  Board view
nico7550

21.07.2023, 21:15
 

Looking for info about INT12h, mem tools and copy tools (Miscellaneous)

Hi,

While searching for the smallest mem like tools that can output conventional memory in bytes, I decide to look how it's done.

So I take a look to MEMSTAT from Japheth (in the JEMM package) because of the size of the source that it's easier for a skillless like me... and so I found the INT12h(AX) but it give the memory in KB only. And all the interrupt list I parse only speak of Kb none of bytes.

Can someone point me on some documentation that explain how this info is retrieve ?

And If you have a small tools that can display conventional memory in bytes and all the others infos, it will be appreciate thanks. (I use mi.com for the moment https://www.hiren.info/downloads/dos-files).

In parallel, I was looking for an external copy tools because one of the kernel I test (Paragon dos 7.01) give sharing buffer overflow when I install a ramdisk. I test VCOPY.COM (2KB) but big file give CRC error, so I use XCOPY (16Kb) while waiting to find for a smaller tools, if you have any suggestion ?

Thanks

CandyMan

21.07.2023, 22:51

@ nico7550
 

Looking for info about INT12h, mem tools and copy tools

> Hi,
>
> While searching for the smallest mem like tools that can output
> conventional memory in bytes, I decide to look how it's done.
>
> So I take a look to MEMSTAT from Japheth (in the JEMM package) because of
> the size of the source that it's easier for a skillless like me... and so I
> found the INT12h(AX) but it give the memory in KB only. And all the
> interrupt list I parse only speak of Kb none of bytes.
>
> Can someone point me on some documentation that explain how this info is
> retrieve ?
>
> And If you have a small tools that can display conventional memory in bytes
> and all the others infos, it will be appreciate thanks. (I use mi.com for
> the moment https://www.hiren.info/downloads/dos-files).
>
> In parallel, I was looking for an external copy tools because one of the
> kernel I test (Paragon dos 7.01) give sharing buffer overflow when I
> install a ramdisk. I test VCOPY.COM (2KB) but big file give CRC error, so I
> use XCOPY (16Kb) while waiting to find for a smaller tools, if you have any
> suggestion ?
>
> Thanks

Int 12h returns the content of the word (in KB) from address 0040h:0013h. To convert KB to bytes, multiply by 1024 (shl 10). Usually it is 640KB. In order for this value to fit in a word, it is given in KB and not in bytes. Some programs can use this memory by reducing it, for example, by 4KB. This was done by some viruses that transferred when booting from an infected disk, or by running an infected program.

Look for MCBs (Memory Control Blocks) on the internet.

Format of DOS memory control block:
Offset  Size    Description     (Table 01628)
 00h    BYTE    block type: 5Ah if last block in chain, otherwise 4Dh
 01h    WORD    PSP segment of owner or special flag value (see #01629)
 03h    WORD    size of memory block in paragraphs
 05h  3 BYTEs   unused by MS-DOS
                (386MAX) if locked-out block, region start/prev region end
---DOS 2.x,3.x---
 08h  8 BYTEs   unused
---DOS 4.0+ ---
 08h  8 BYTEs   ASCII program name if PSP memory block or DR DOS UMB,
                  else garbage
                null-terminated if less than 8 characters
Notes:  the next MCB is at segment (current + size + 1)
        under DOS 3.1+, the first memory block is the DOS data segment,
          containing installable drivers, buffers, etc.  Under DOS 4.0+ it is
          divided into subsegments, each with its own memory control block
          (see #01633), the first of which is at offset 0000h.
        for DOS 5+, blocks owned by DOS may have either "SC" or "SD" in bytes
          08h and 09h.  "SC" is system code or locked-out inter-UMB memory,
          "SD" is system data, device drivers, etc.
        Some versions of DR DOS use only seven characters of the program name,
          placing a NUL in the eighth byte.

nico7550

22.07.2023, 09:35

@ CandyMan
 

Looking for info about INT12h, mem tools and copy tools

Thanks, I will dig that way.

But divide byb 10242 the block reported will not give a precise value as seen on some tools.

Depending of the kernel, the max coventional memory is not always exactly the same, so I thinks it manage to grab this value and then remove the amount of used memory to have the exact remaining free value in bytes.

Rugxulo

Homepage

Usono,
25.07.2023, 01:38

@ nico7550
 

Looking for info about INT12h, mem tools and copy tools

There's an old FASM thread titled How to determine amount of free conventional memory? that may help.

For instance, I pointed to a download link of TSRW31.ZIP that had FREERAM.ASM inside it. But I don't recall how accurate it was. (Maybe it's only largest block?)

I do have some old "walk the MCB chain" code I found in a Turbo C book somewhere (but not sure of the license).

You could also just use Turbo Pascal "writeln(memavail);", and then disassemble that to see how it's done. That's usually pretty accurate, IMHO. Actually, even better, just use FreePascal's code (sorry, don't know the exact filename): rtl/i8086

nico7550

26.07.2023, 12:49

@ Rugxulo
 

Looking for info about INT12h, mem tools and copy tools

@Rugxudo
Thanks for all the info, I can tell that freeram code is is enough acurate, I compare with other memory stats tools I have and the difference is below 500b.

That say the code is more complicate that a "simple" int12 call.

As I start from nothing, I will have to learn a lot to understand how it works.

Thanks again

marcov

26.07.2023, 17:18

@ Rugxulo
 

Looking for info about INT12h, mem tools and copy tools

> You could also just use Turbo Pascal "writeln(memavail);", and then
> disassemble that to see how it's done. That's usually pretty accurate,
> IMHO. Actually, even better, just use FreePascal's code (sorry, don't know
> the exact filename):
> rtl/i8086

Memavail is the dynamic memory available to the heapmanager. But that is potentially decreased by code,stack and (static) data segment and startup allocations.

Anyway, these functions get info from the heapmanager, so the bit that is interesting is how the RTL finds the amount of memory and initializes the heapmanage)

CandyMan

26.07.2023, 14:24

@ nico7550
 

Looking for info about INT12h, mem tools and copy tools

There is MS.COM (Memory Statistics).

https://megawrzuta.pl/download/e7c2a5ace1d02143ea0c64ac15b49135.html

Back to index page
Thread view  Board view
22049 Postings in 2034 Threads, 396 registered users, 40 users online (0 registered, 40 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum