Memory allocation: Difference between revisions

m
No edit summary
Line 76:
 
=={{header|6502 Assembly}}==
The first 256 bytes in the 6502's address space are collectively referred to as the "zero page" and can be used for any purpose. The next 256 bytes are reserved for the stack. Since this is assembly, there is no structured system for allocating/deallocating memory. It's all there for the programmer to use.
 
The "heap" can be considered the zero page, or any other section of RAM that the hardware allows for general access. Anything besides the zero page is platform-specific. Accessing the heap is as simple as storing values in a specified address.
<lang 6502asm>LDA #$FF ;load 255 into the accumulator
STA $00 ;store at zero page memory address $00
STA $0400 ;store at absolute memory address $0400</lang>
 
A byte can be stored to the stack with <code>PHA</code> and retrieved with <code>PLA</code>. Later revisions of the 6502 allowed the X and Y registers to be directly pushed/popped with <code>PHX</code>, <code>PHY</code>, <code>PLX</code>, and <code>PLY</code>. The original 6502 could only access the stack through the accumulator.
 
=={{header|Ada}}==
===Stack===
1,489

edits