How to address above 4GB using assembly language ?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
prayag.ganoje
Posts: 3
Joined: Wed Oct 24, 2007 5:20 am

How to address above 4GB using assembly language ?

Post by prayag.ganoje »

Can any one tell me how to represent the physical address above 4GB using assembly language... viz

Code: Select all

DS:EDI
?
ReD Only !!
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Using PAE or long mode? In a x86_64 machine all registers are 64 bits long anyway...
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: How to address above 4GB using assembly language ?

Post by Brendan »

Hi,
prayag.ganoje wrote:Can any one tell me how to represent the physical address above 4GB using assembly language... viz

Code: Select all

DS:EDI
?
For 32-bit code you'd do it the exact same way you'd store any other 64-bit integer. For example, EDX might hold the highest 32-bits of the address and EAX might hold the lowest 32-bits.

If you're wondering how to access a 64-bit address in 32-bit assembly, the simple answer is you don't. Without paging you can't access anything above 4 GB, and with paging (PAE or PSE36) you're still using 32-bit linear addresses. To access a 64-bit physical address you need to map the page containing the address into the 32-bit linear address space, then use a 32-bit linear address to access it.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
rv6502
Posts: 19
Joined: Fri Nov 02, 2007 8:28 pm

Post by rv6502 »

have a look at how EMS memory works, how a C128 can have more than 64KiB of ram, how a C64 can have 64KiB ram + 32Kib ROM, how a NES can access 1MiiB ROM cartridges, etc.

http://en.wikipedia.org/wiki/Bank_switching

you can implement something similar using paging

good luck
Post Reply