Memory allocation: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) |
|||
Line 86: | Line 86: | ||
Shared memory between the CPU and connected hardware is accessed via memory-mapped ports. These appear as memory locations in the CPU's address space. However, they do not necessarily have the same properties as regular memory. Some are read-only, some are write-only, others have unusual behavior. |
Shared memory between the CPU and connected hardware is accessed via memory-mapped ports. These appear as memory locations in the CPU's address space. However, they do not necessarily have the same properties as regular memory. Some are read-only, some are write-only, others have unusual behavior. |
||
=={{header|68000 Assembly}}== |
|||
The <code>LINK</code> and <code>UNLK</code> instructions are designed to create [[C]]-style stack frames. The operands of the <code>LINK</code> instruction are an address register (other than A7) and a displacement (must be even and either 0 or negative.) |
|||
<lang 68000devpac>MyFunction: |
|||
LINK A6,#-16 ;create a stack frame of 16 bytes. Now you can safely write to (SP+0) thru (SP+15). |
|||
;your code goes here. |
|||
UNLK A6 ;free the stack frame |
|||
RTS</lang> |
|||
<code>LINK An, #-disp</code> is effectively equivalent to the following: |
|||
<lang 68000devpac>MOVE.L An,-(SP) |
|||
MOVEA.L SP,An |
|||
SUBA.L #disp,SP</lang> |
|||
You can use negative offsets of <code>An</code> or positive offsets of <code>SP</code> to refer to the same memory region. |
|||
=={{header|Action!}}== |
=={{header|Action!}}== |