Re: how do you start learning assembly language



På Sat, 12 Jan 2008 20:07:00 +0100, skrev Keith Kanios <keith@xxxxxxxxxx>:

On Jan 12, 9:57 am, "Ratch" <watc...@xxxxxxxxxxx> wrote:
Just by definition, the paging mechanism is a relocation method. It
converts a logical address to a physical address. Isn't that obvious?


I haven't heard that one before.

However, I've heard/implemented other definitions of what paging is/
does...

1.) To get around physical address space fragmentation/holes.
2.) For memory space isolation, a form of protection.
3.) To abstract the architecture's full memory address space even if
you don't have the equivalent amount of RAM to support it.
4.) To establish shared memory regions despite potential barriers,
e.g. a monolithic kernel, dynamic libraries and file buffers.
5.) As a means of memory/buffer overflow protection, e.g. stack
"guard" pages.

I think there may be a few more definitions, but the above should
cover the majority of expected use.

I've always heard of relocation as a by-product of #2 and a result of
#4 above, but never as a method *of* paging.

As an example, your standard PE is linked with the assumption of
having a base address at 0x00400000. If for some reason it can't load
there, the loader will try to find a memory location sufficient for
loading and recalculate all appropriate relocatable addresses based
upon the newly established base address. Please note that this is
beyond your standard relocation calculations like those done for DLL
linking.

I have gaps to fill here for sure.
What happens with the datasegment, inside the PE?

if I say

[somedata: 100]
mov ecx D$SomeData ; "static" data "segment"

Does the CPU perform the relative translation of the label based on information elsewhere, or does the "linker", do it?? What about a dynamic segment. That is allocated at runtime, yes? So then it must be the CPU doing the translation. And the relocation must then just be telling somehow the CPU the new relative adresse?

[somedata2: ?]

mov ecx D$SomeData2

If I save this code (its binary) to a file,
and CHANGE the PE, and then load the binary file, then
it will no more work. The address will be incorrectly translated.

So all data and code can be "relocated" and this must be just some small operation for the loader, to just somehow inform the CPU where to find the new relative address for the page(s)?. then what I said earlier must be wrong.


The binary:
8b 0d 00 30 40 00 (00403000) ; mov ecx D$Somedata
8b 0d 04 30 40 00 (00403004) ; mov ecx D$SomeData2

6A 00 ; push 0
FF 15 03 10 40 00 (00401030) ; call "kernel32.ExitProcess"


hmm. just 4 bytes appart? thats weird isnt it?
shouldnt those segements be at further apart?
Whats the rest of the PE filled with then?

Did you do some trickey here Betov? Did you get fed
up with beeing critized of the PE being sooooo "large" and
implemented some trixs to make it smaller in the case
of small PES????? :D

Then why it is so big????

See what I am saying?

:)

a hexlisting is definitly needed sometimes.













.



Relevant Pages

  • Re: upgrading memory
    ... what is in memory has to be written on the disk and the new ... Although this is paging, it's essentially one-time paging, usually ... and it doesn't use the CPU and it doesn't page. ... Additional RAM might help some, but how just much it'll help mostly ...
    (microsoft.public.windowsxp.basics)
  • Re: CPU usage for paging
    ... I am not aware of any specific RMF report that gives you what you want. ... non-linear relationship between paging and throughput. ... calculation of how much benefit per unit increase in memory capacity. ... Other kinds of paging also takes up cpu time and competes for ASM ...
    (bit.listserv.ibm-main)
  • Re: CPU usage for paging
    ... but I don't think there is an RMF report that tells you how much CPU is used by paging. ... It might help if you told us just how many pages per second you are doing, and how many paging devices you have. ... If you are running at 100% CPU utilization, adding memory will certainly buy pack a small percent of CPU. ...
    (bit.listserv.ibm-main)
  • Re: Rethinking V.M.S
    ... >> initially paging in the program when it starts. ... The CPU always has to do the 1st sentence (dereference ... > to track the physical pages in memory assigned to a process. ... add a few extra instructions to the "invalid memory" trap handler ...
    (comp.os.vms)
  • Re: how do you start learning assembly language
    ... I've heard/implemented other definitions of what paging is/ ... For memory space isolation, a form of protection. ... beyond your standard relocation calculations like those done for DLL ...
    (alt.lang.asm)