Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Re: How to dete...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 8 Topic 4483 of 4860
Post > Topic >>

Re: How to determine the total size of the RAM in pure assembly

by s_dubrovich <spamtrap@[EMAIL PROTECTED] > Jan 10, 2008 at 11:59 AM

On Jan 10, 1:11 am, xmllmx  <spamt...@[EMAIL PROTECTED]
> wrote:
> I'm curious to know how to check the RAM size installed on the machine
> in x86 assembly language.
>
> In addition, there is a related question in my mind: Must the physical
> addresses of the RAM be contiguous? For example, provided that I have
> two RAM chips and the size of each is 16M, my PC's mainboard has 3
> slots to install RAM chips, let me number them as slot 0, slot 1, and
> slot 2. Assuming the addressing hardware numbers the address space
> from slot0 through slot2 (i.e. physical address 0 will be allocated to
> slot0 if it is equipped with a RAM chip). If I plug the two RAM chips
> into slot0 and slot2, and let slot1 empty. In this case, is the first
> 32M of the physical address space contiguous?
>
> I guess (am not very sure) the addressing hardware will guarantee the
> physical address space to be contiguous. For example, if the total RAM
> size is 32M, then the physical addresses from 0 to 32M are always
> addressable, no matter which slots the RAM chips occupy. Am I correct?
>
> Any help will be highly appreciated. Thanks in advance!

Regardless, if contiguous, the system may not map it as contiguous.
Here is some of Frank's code and sample output of int15h ax.E820h...
"
;;I've been meaning to investigate this interrupt ever since I first
heard
;of it. Your question prompted me to whip up this crude example. I
don't
;really know if it's "right" or not... seems reasonable... Here's the
;output from the sucker on my machine:

[MAP NE820.MAP]

;0000000000000000
;000000000009FC00
;00000001           1=Avail. to OS, 2=Not Avail.,
;000000000009FC00
;0000000000000400   2=Not Avail, Extended Bios Data Area here.
;00000002
;00000000000F0000
;0000000000010000
;00000002
;00000000FFFF0000
;0000000000010000
;00000002
;0000000000100000
;0000000007F00000
;00000001


;I'm not sure what's in those "reserved" blocks... better not mess
with
;them... (or *do*, and see what happens :)


;I don't know if this is any help to you... something to play with,
anyway.


;Best,
;Frank


; nasm -f bin -l ne2.lst -o ne2.bin  ne2.asm


;org 100h

section .text

struc mm_ent
     .base resq 1
     .len resq 1
     .type resd 1
endstruc


section .text
     mov di, buffer
     xor ebx, ebx
     xor si, si            ; counter
top:
     mov eax, 0E820h
     mov edx, 534D4150h    ; 'SMAP'
     mov ecx, 20
     int 15h
     jc error
     inc si                ; bump counter
     add di, cx
     or ebx, ebx
     jz done
     jmp short top
done:


     mov cx, si            ; count
     mov si, buffer
show:
     mov eax, [si + mm_ent.base + 4]
     call showeax
     mov eax, [si + mm_ent.base]
     call showeax
     call newline


     mov eax, [si + mm_ent.len + 4]
     call showeax
     mov eax, [si + mm_ent.len]
     call showeax
     call newline


     mov eax, [si + mm_ent.type]
     call showeax
     call newline


     add si, mm_ent_size


;    cmp si, di    ; this worked too, but I thought it
;    jne show      ; might be "safer" to count blocks


     loop show


error:


exit:
     ret


;------------------
showeax:
     push cx
     mov cx, 8
..top:
     rol eax, 4
     push eax
     and al, 0Fh
     cmp al, 0Ah
     sbb al, 69h
     das
     call putc
     pop eax
     loop .top
     pop cx
     ret
;-------------------


;-------------------
newline:
     push ax
     mov al, 13
     call putc
     mov al, 10
     call putc
     pop ax
     ret
;--------------------


;--------------------
putc:
     push ax
     push dx
     mov dl, al
     mov ah, 2
     int 21h
     pop dx
     pop ax
     ret
;----------------
;;section .bss

  buffer TIMES 200h db 0
;---------------------
"
...also..
mtypes db '   Types: 1=Avail. to OS, 2=Not Avail., '
   db '3=ACPI Avail. to OS, 4=NVS Not Avail.   '

hth,
Steve
 




 8 Posts in Topic:
How to determine the total size of the RAM in pure assembly lang
xmllmx <spamtrap@[EMA  2008-01-09 23:11:55 
Re: How to determine the total size of the RAM in pure assembly
"Benjamin David Lunt  2008-01-10 14:17:49 
Re: How to determine the total size of the RAM in pure assembly
Bjarni Juliusson <spa  2008-01-10 15:31:30 
Re: How to determine the total size of the RAM in pure assembly
s_dubrovich <spamtrap@  2008-01-10 11:59:54 
Re: How to determine the total size of the RAM in pure assembly
xmllmx <spamtrap@[EMA  2008-01-10 18:08:25 
Re: How to determine the total size of the RAM in pure assembly
Tim Roberts <spamtrap  2008-01-12 04:22:35 
Re: How to determine the total size of the RAM in pure assembly
"Alexei A. Frounze&q  2008-01-13 01:03:48 
Re: How to determine the total size of the RAM in pure assembly
Tim Roberts <spamtrap  2008-01-13 22:59:47 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Nov 20 20:50:42 CST 2008.