Jump to content

Compound data type: Difference between revisions

no edit summary
m (typo)
No edit summary
Line 42:
3
T</pre>
=={{header|6502 Assembly}}==
 
The method below is a bit unusual compared to [[C]], where each member of a struct is stored consecutively. The addressing modes of 6502 make it much more efficient to store each member of many different structs consecutively. In other words, the index used to offset into <code>point_x</code> represents which instance of the data type the CPU is accessing.
 
NESASM3 syntax:
<lang 6502asm>MAX_POINT_OBJECTS = 64 ; define a constant
.rsset $0400 ; reserve memory storage starting at address $0400
point_x .rs MAX_POINT_OBJECTS ; reserve 64 bytes for x-coordinates
point_y .rs MAX_POINT_OBJECTS ; reserve 64 bytes for y-coordinates</lang>
 
VASM syntax:
<lang 6502asm>MAX_POINT_OBJECTS equ 64 ; define a constant
point_ram equ $0400
point_x equ point_ram
point_y .rs point_ram+MAX_POINT_OBJECTS</lang>
 
=={{header|ActionScript}}==
1,489

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.