News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Memory Addressing and such.

Started by Mirage, September 03, 2010, 03:36:51 AM

Previous topic - Next topic

Mirage

Coming from programming java heavily and some VB, I've always had some issues with memory addressing and such.

So here I was wondering if anyone here knows a good ebook/website which goes over x86 or x86_64 memory addressing?

hutch--

I don't know if there is a book dedicated to this specific topic but the basic distinctions are reasonably simple once you get used to them. Think of a section of memory like a sequence of bytes.


  bytedata db 0,1,2,3,4,5,6,7,8,9


The named variable "bytedata" is the start of the section of memory. Now if you actually convert WHERE this memory is located you get its ADDRESS. It will be a 32 bit integer if you convert it to a string to display it. Once you know WHERE the data is you then want to know WHAT the data is at that ADDRESS.

Now "bytedata" would convert to something like 41000000 but when you read the data AT that ADDRESS the first BYTE is "0".

There are a few other tricks, in modern 32/64 bit operating systems the memory is protected so you can only read and write to the memory range that you have allocated. With the simple example above, if you tried to read or write below the start address or past the end of the allocated memory you will get what is called a "general protection fault" where the operating system generates an "exception" if you go ot of the bounds of the memory you have allocated.

This is done so that you don't have problems like the old win3 series of operating systems where one application could damage the data in another because it overwrote a section of memory that it did not allocate. In those days it used to crash the opertaing system.

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mirage

I know theres got to be a book or two around, and I grasp the basic memory stuff (I've dabbled a bit with poking at programs with memory editors and such)

hutch--

try it the other way, allocate some memory and make sure you only read and write to that memory range. There are many books that talk about addressing over a long period, (mainly in C) but it means you must learn that notation to read them.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mirage

I wish I was in highschool again, oh all that free time to learn new things  :wink


Found this ebook/book

http://www.mindshare.com/shop/?c=b&section=0A6B17101710

Looks promising I think :)

hutch--

It looks OK and you can download the PDF but make sure you get the current Intel manuals, they are the final reference for x86 hardware, 32 and 64 bit.

It can be hard going for a while but the Intel manuals are the best you can get and at least at the right price.  :bg
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Mirage

Can't you magical assembly people just meditate and create the book by staring at the website? :P


And by manuals you mean the stuff here?

http://www.intel.com/products/processor/manuals/

Hilariously I just managed to find that book in a 'free' version, not by piracy but more by the fact that they sadly have it on a public FTP; I think I shall report that to them.

hutch--

Download from.

Intel® 64 and IA-32 Architectures Software Developer's Manual

to

Intel® 64 and IA-32 Architectures Optimization Reference Manual

These will keep you out of trouble for some time to come.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

sinsi

Do you want to know from the bottom up (how the CPU uses page tables etc.) or top-down (how Windows/Linux uses pointers)?
Ask the right questions and you will get good answers.
Light travels faster than sound, that's why some people seem bright until you hear them.

Mirage

Top down moreso but I think these books will do good.