In: Computer Science
Write an assembly program that rearrange the values in the following array as 40, 30, 20, 10:
.data byte1 BYTE 10, 20, 30, 40
Save the original four byte data into eax, and the rearranged data into ebx, from the least significant bit to the most significant bit. Insert a call DumpRegs statement to display the register values.
instruction source
offset result
mov bx,[bx]
1000h
1BACh
mov cx,[si]
2000h
20FEh
mov bx,[ax] illegal source
register
add [si],[di] illegal
memory-memory add
inc [di]
3000h
031Eh
Processing Arrays using Register-Indirect Mode
W dw
10,20,30,40,50,60,70,80,90,10
xor ax,ax ; ax holds sum
lea si,W ; si points to array W
mov cx,10 ; cx has number of elements
addnos:
add ax,[si] ; sum = sum + element
add si,2 ; move pointer to the next
element
loop addnos ; loop until done