Question about Assembly Language. What is this line doing?

Given the MASM data declarations below. .DATA OddArray word 18,20,22,24 EvenArray word 19,21,23,25 1) Write the assembly language instructions to swap the values of the two arrays using direct addressing. 2) Write the assembly language instructions to swap the values of two arrays using indirect addressing. This is for number one: mov ax,OddArray mov dx,EvenArray mov OddArray,dx mov EvenArray,ax mov ax,OddArray + TYPE OddArray mov dx,EvenArray + TYPE EvenArray mov OddArray + TYPE OddArray,dx mov EvenArray + TYPE EvenArray,ax mov ax,OddArray + TYPE OddArray * 2 ;what is going on in this code? what does the 2 mean? mov dx,EvenArray + TYPE EvenArray * 2 ;same with this one and the ones below it that have a number. mov OddArray + TYPE OddArray * 2,dx mov EvenArray + TYPE EvenArray * 2,ax mov ax,OddArray + TYPE OddArray * 3 mov dx,EvenArray + TYPE EvenArray * 3 mov OddArray + TYPE OddArray * 3,dx mov EvenArray + TYPE EvenArray * 3,ax and this is number two, but I already understand number two. mov rsi,offset OddArray mov rdi,offset EvenArray mov rcx,LENGTHOF OddArray mov rbx,0 L1: mov ax,[rsi + rbx*TYPE OddArray] mov dx,[rdi + rbx*TYPE EvenArray] mov [rsi + rbx*TYPE OddArray],dx mov [rdi + rbx*TYPE EvenArray],ax inc rbx loop L1
Answers

bocephusmcguire

TYPE is returning the size of a single element in the array, so 'mov ax, OddArray' is moving the first element. 'mov ax, OddArray + TYPE OddArray' is moving the second element. And 'mov ax, OddArray + TYPE OddArray * 2' is moving the next element, and so on...