Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory Size

Status
Not open for further replies.

adholioshake

Programmer
Feb 9, 2003
136
How do you find out memory size in assembly?
I know there are the bios interrupts 11 and 12, but they only work in kb, which isn't very good if you have for example 20M. Also these don't include extended memory.
Does anyone have any ideas ?
 
If your program works on Windows,you can use API.
I'm sorry, I don't know how to accomplish it under DOS.
 
Hi!

================================================================
getting memory sizes
================================================================
>is here any good way to count a system's memory?
>something that might be easily portable to other architectures?

To get PC extended memory size, start with BIOS interrupts,
in this order:
- INT 15h AX=E820h (look for type 1 memory)
- INT 15h AX=E801h
- INT 15h AH=88h
Details:

If none of those work, read extended memory size from CMOS
; get extended memory size from CMOS -- won't
; report more than 63.999 meg (65535/1024)
mov al,18h
out 70h,al
in al,71h
mov ah,al
mov al,17h
out 70h,al
in al,71h
mov [ext_mem_size],ax ; in K

Direct probing is fraught with problems:
- Address "aliasing" caused by unconnected high-order address
lines. I have a 486 system in which addresses 64 meg, 128 meg,
192 meg, etc. "wrap around" to address 0.
- Memory mapped hardware that causes the computer to freeze
when your memory probe steps on it.
- PC might have a bizarre and unique method of turning on the
A20 gate; a method not supported by your direct probing code.
- C memory probing code that does not use 'volatile', or buggy
compiler (Borland C++ 3.1) for which 'volatile' does not work
- Bus float causes the memory test to succeed even if there's
no memory
 
Thanks OSProgrammer :) Very Useful comments and some source code as well.
Are you currently writing an OS ?


The mind is like a parachute - it works better when open...
 
Hi adholioshake!

Yes.I'm Trying to make an OS All With Assembly, And Currently I am Working on It's Graphic User Interface.

Best Wishes...
OSProgrammer
 
I highly recommend Micahel Abrash for graphic at assembly level. I've read his "black book" on graphics and his "Zen on graphics". Both books are very good, but I tend to get a bit lost in it. He talks about how he created the quake graphics engine... :)


The mind is like a parachute - it works better when open...
 
Thanks adholioshake For Your Guide!

How about you? What do you do with assembly!!?


 
I just like to program a bit more deeply... I am currently an undergrad on an electronic engineering course. I would love to create my own OS, but at the moment my time goes on other things (like work and play). I have started working on a few low level OS designs on random floppys, but haven't got as far as the kernel yet. The way I see it, if I design an OS I wan't it to be compatible with the other more common OS's, so as a result much of the file system will be the same. My OS would probably be a small version of linux, another one on the shelf for the much larger linux community :)

I enjoy helping people stuck on assembly mostly, because a) It gives me a problem to solve and b) they learn more (hopefully). Happy programming...




The mind is like a parachute - it works better when open...
 
Hi adholioshake!

If You Want to write an os like linux You Can Use C/C++/Djgpp Programming.

This site has good tutorial for WRITING YOUR OWN OS.


Best Wishes

Hamidreza Vakilian(Iran)
Email: vakilian@go.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top