ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

помогите найти ошибку или скажите решение задачи - assembler
Posted by neanabol 8 Sep 2008 21:47
задание
в массиве переставить положительные элементы в обратном порядке

мой вариант решения нерабочий чето

data    segment
x       dw     1,2,3,-9,-8,0,5,-6,4,5
nx      dw     10
y       dw     1,2,3,5,-5,0,6
ny      dw     7
r       dw     ?
data    ends

stack segment
stack ends

code    SEGMENT
assume ds:data,cs:code,ss:stack
start:
        mov ax,data
    mov ds,ax

lea bx,x
mov di,nx
dec di
add di,di
call procedure1

lea bx,y
mov di,ny
dec di
add di,di
call procedure1

procedure1 proc near
c1:
cmp si,di
jnl m11

m1:
cmp [bx+si],0
jng m22

m2:
cmp [bx+di],0
jng m33

m3:
push cx
mov ax,[bx+si]
mov cx,[bx+di]
mov r,ax
mov ax,cx
mov cx,r
pop cx
sub cx,2
add si,2
sub di,2
jmp m11

m22:
add si,2
dec bx
jmp m11

m33:
sub di,2
dec bx

m11:

loop c1

ret

procedure1 endp

           mov ah,4ch
           int 21h

code    ends
        end     start

Edited by author 08.09.2008 21:49