This code segment moves data from the end of an array to the beginning. It loads the data segment address into DS, sets a counter CX to 5, and uses LEAs to point SI to the last element and DI to the first empty element. It then copies each element from SI to DI, decrementing both pointers and the counter, repeating until CX is not zero.
1 of 1
Download to read offline
More Related Content
Ece2
1. assume cs:code,ds:data
data segment
x db 0Ah,0Bh,0Ch,0Dh,0Eh;
data ends
code segment
start:mov ax,data
mov ds,ax
mov cx,05h
lea si,x+04
lea di,x+04+05
up:mov bl,[si]
mov[di],bl
dec si
dec di
dec cx
jnz up
mov ah,4ch
int 21h
code ends
end start
end