Array: Difference between revisions
Content added Content deleted
Puppydrum64 (talk | contribs) m (→Assembly) |
Puppydrum64 (talk | contribs) |
||
Line 84: | Line 84: | ||
Implementation of a reverse array slice such as <code>a[100:0:-2]</code> example for [[Python]] is much more difficult. First of all, computers cannot implicitly understand the concept of the "end" of an array. The start of an array is easy for a computer to grasp, it is simply a pointer to its first element. However, encoding an array's end point requires some form of metadata, such as a null terminator or an additional variable representing the array's maximum size. High-level languages typically handle this automatically. |
Implementation of a reverse array slice such as <code>a[100:0:-2]</code> example for [[Python]] is much more difficult. First of all, computers cannot implicitly understand the concept of the "end" of an array. The start of an array is easy for a computer to grasp, it is simply a pointer to its first element. However, encoding an array's end point requires some form of metadata, such as a null terminator or an additional variable representing the array's maximum size. High-level languages typically handle this automatically. |
||
Access of an individual element of an array depends on the language. |
|||
<lang asm>;6502 Assembly |
|||
lda $2000,x ;load the xth element of the array beginning at memory address $2000 |
|||
lda $3022,y ;load the yth element of the array beginning at memory address $3022 |
|||
lda ($20),y ;load the yth element of the array whose pointer is stored at consecutive memory addresses $0020 and $0021 |
|||
;68000 Assembly |
|||
move.b (4,A0,D1),D0 ;load into D0 the (4+D1.W)th element of the array whose beginning address is stored in A0. |
|||
;8086 Assembly |
|||
mov ax,[bx+di] ;load the BXth element of the array whose beginning is stored in DI, into AX |
|||
;ARM Assembly |
|||
ldr r0,[r1,#4] ;load the 1st element of the array whose pointer to its 0th element is stored in r1, into r0.</lang> |
|||
===[[Fortran]]=== |
===[[Fortran]]=== |