Task

Loop over multiple arrays   (or lists or tuples or whatever they're called in
your language)   and display the    i th    element of each.

Use your language's   "for each"   loop if it has one, otherwise iterate
through the collection in order with some other loop.



For this example, loop over the arrays:

    (a,b,c)
    (A,B,C) 
    (1,2,3) 

to produce the output:

    aA1
    bB2
    cC3



If possible, also describe what happens when the arrays are of different lengths.



Related tasks

   Loop over multiple arrays simultaneously
   Loops/Break
   Loops/Continue
   Loops/Do-while
   Loops/Downward for
   Loops/For
   Loops/For with a specified step
   Loops/Foreach
   Loops/Increment loop index within loop body
   Loops/Infinite
   Loops/N plus one half
   Loops/Nested
   Loops/While
   Loops/with multiple ranges
   Loops/Wrong ranges


	cpu	8086
	bits	16
	org	100h
section	.text
	mov	ah,2		; Tell MS-DOS to print characters
	xor	si,si		; Clear first index register (holds _i_)	
outer:	mov	di,As		; Put array-of-arrays in second index register
	mov	cx,Aslen	; Put length in counter register
inner:	mov	bx,[di]		; Load array pointer into BX (address) register
	mov	dl,[bx+si]	; Get SI'th element from array
	int	21h		; Print character
	inc	di		; Go to next array (pointers are 2 bytes wide)
	inc	di
	loop	inner		; For each array
	mov	dl,13		; Print newline
	int	21h
	mov	dl,10
	int	21h
	inc	si		; Increment index register
	cmp	si,Alen		; If it is still lower than the array length
	jb	outer		; Print the next items
	ret
section	.data
	;;;	Arrays
A1:	db	'a','b','c'
A2:	db 	'A','B','C'
A3:	db	'1','2','3'
Alen:	equ	$-A3		; Length of arrays (elements are bytes)
	;;;	Array of arrays
As:	dw	A1,A2,A3
Aslen:	equ	($-As)/2	; Length of array of arrays (in words)