Program compilation and execution flow
First of all, you are fundamentally confusing the purpose of RAM and hard disk. RAM is the only part of memory that CPU can access. Hard disk exists to expand the capacity of RAM as well as store the data permanently (data on RAM is transient).

How it works -


The computer generates an executable and stores it in the hard disk. It is just a passive program right now.
Another process (already in memory and currently running) calls the program you just created using the access path (full psth + name) in the filesystem. This is a system call; an interrupt is issued and control is transferred to OS.
OS decodes the path to get the actual location(s) on hard disk where the program data blocks are stored. Hard disk is treated as any other I/O device; it vouches for CPU time like any other I/O device. Here, OS has two choices:

either it needs to fetch data from hard disk each time hard disk has some to give (hard disk announces it by issuing interrupts) and store it in RAM. But with ever faster hard disk speeds nowadays, frequency of interrupts can be high enough to be inefficient for CPU.
second option is that CPU, while issuing the read command for program data blocks, also specifies the RAM memory addresses to which hard disk should directly copy its data (Direct Memory Access). Since CPU, I/O devices (including hard disk) and memory all share common bus, data can be transferred one at a time. Moreover, CPU meanwhile also has other processes (in RAM) to run while data is being copied by hard disk to RAM. Thus, both CPU and hard disk take turns when copying data to RAM. Here, DMA would be faster if CPU is idle or requires less memory accesses. When hard disk has completed writing data to RAM as specified by CPU, it issues interrupt to CPU to tell it that it has completed its task.

Take note above that CPU has never accessed the data of hard disk directly. The hard disk works the same way as any other device like keyboard or modem would work (via interrupts etc). Now after hard disk has copied data and interrupt generated, OS assigns stack memory and other resources for this newly created process and inserts it into the queue of active processes.


That is why when creating small beginner programs, we can never save the state of programs. We create some variables while the process is running and modify them, but never explicitly store them on the hard disk (unless engaging with the file handling aspect). When we destroy the program all the memory is lost. and all the read, write operations of a language are merely wrappers around the system calls provided by the OS so as to make the code portable across several operating systems (since system calls of each are different). These read/write/open/close system calls are requests for OS to let us access a file on hard disk, different from the RAM.

As to your question about logical addresses, it is a little ambiguous as to what you want to say. Logical addresses are used in reference to RAM by programs, and usually refer to the program's view of its memory. For a program, its logical addresses may start from 0, but that doesn't translate into the fact that all programs start at physical address 0 of RAM! You are right that CPU has to process data, but it needs some data at all to process, with is stored in RAM. The addresses provided by program code are logical (say, get data stored in location '7 + start of program') and CPU has to calculate its actual physical address to work upon (i.e. replace 'start of program' with the base address of process code blocks in RAM).

Thus, logical addresses have nothing to do with hard disks.