Array length: Difference between revisions
Content added Content deleted
No edit summary |
Puppydrum64 (talk | contribs) |
||
Line 37: | Line 37: | ||
Array length= 2 |
Array length= 2 |
||
</pre> |
</pre> |
||
=={{header|6502 Assembly}}== |
|||
{{trans|360 Assembly}} |
|||
Array length is computed at compilation time with the formula: (Array_End-Array). Even though the labels Array and Array_End are both 16-bit values, if their difference fits into 8 bits the assembler will allow you to load it into a register. |
|||
<lang 6502asm>start: |
|||
LDA #(Array_End-Array) ;evaluates to 5 |
|||
RTS |
|||
Array: |
|||
byte 3,6,9,12,15 |
|||
Array_End:</lang> |
|||
=={{header|68000 Assembly}}== |
|||
{{trans|360 Assembly}} |
|||
Array length is computed at compilation time with the formula: (Array_End-Array). Even though the labels Array and Array_End are both 32-bit memory addresses, if their difference is small enough it can fit into a 16-bit or even an 8-bit instruction operand. |
|||
<lang 68000devpac>start: |
|||
MOVE.B #(Array_End-Array) ;evaluates to 5 |
|||
RTS |
|||
Array: |
|||
DC.B 3,6,9,12,15 |
|||
Array_End:</lang> |
|||
=={{header|8th}}== |
=={{header|8th}}== |