assembly - How to Slide numbers in an array? -
i trying slide numbers array
example, array 8,7,6,5,4,3,2,1
, when code finishes loop, should 1,8,7,6,5,4,3,2
, not sure how that
.model small .data arr db 8,7,6,5,4,3,2,1 .code .startup mov cx,8 mov si ,7 lop: mov al ,arr[si] mov bl ,arr[si-1] mov arr[si], bl mov arr[si-1], al dec si loop lop .exit
that drag last element thorough whole array:
.model small .data arr db 8,7,6,5,4,3,2,1 .code .startup mov cx , 7 ; here: 1 less ( shift size-1 elements) mov si , 7 lop: mov al,arr[si-1] xchg al, arr[si] mov arr[si-1], al dec si loop lop .exit
can't possibly imagine why need kind of algorithm, still.
Comments
Post a Comment