Array concatenation: Difference between revisions

m
Line 17:
[1, 2, 3, 4, 5, 6]
</pre>
 
=={{header|68000 Assembly}}==
In order for this to work, you'll either need to use <code>malloc()</code> or know a memory location of "free space" at compile time. This example shall use the latter.
 
<lang 68000devpac>ArrayRam equ $00FF2000 ;this label points to 4k of free space.
 
;concatenate Array1 + Array2
LEA ArrayRam,A0
LEA Array1,A1
MOVE.W #5-1,D1 ;LEN(Array1), measured in words.
JSR memcpy_w
;after this, A0 will point to the destination of the second array.
LEA Array2,A1
MOVE.W #5-1,D1 ;LEN(Array2), measured in words
JSR memcpy_w
 
JMP * ;halt the CPU
memcpy_w:
MOVE.W (A1)+,(A0)+
DBRA D1,memcpy_w
rts
 
Array1:
DC.W 1,2,3,4,5
Array2:
DC.W 6,7,8,9,10</lang>
 
=={{header|8th}}==
1,489

edits