Click to See Complete Forum and Search --> : i need help again(((((((((((((


king-gideon
April 3rd, 2009, 11:46 AM
i need to replace all the negative elements in an array with zero.i also have to print out the new array.example 1,2,3,-5,6,-6 wud become 1,2,3,0,6,0.i tried writing this and its nt working:( i need help pls


.model small
.stack 100h
.data
DEC_SIZE EQU 5
RES DB DEC_SIZE DUP('0')
TEMP DW ?
array dw 1,2,3,-5,6,-6
.code
start:mov cx,6
mov bx,array
cmp [bx],0
jnl Mark
mov [bx],0


Mark:
add bx,2
cmp [bx],0
jnl omark
cmp[bx],0
omark: LOOP Mark

mov bx,array
MOV AX,[bx]
MOV CX,10
MOV RES+DEC_SIZE,'$'
MOV BX,OFFSET RES+DEC_SIZE
CYCLE: DEC BX
XOR DX,DX
DIV CX
ADD DL,'0'
MOV [BX],DL
CMP BX,OFFSET RES
JNE CYCLE
MOV AH,09
LEA DX,RES
INT 21H
mov cx,6

ft: mov cx,TEMP
MOV AX,[bx]
MOV CX,10
MOV RES+DEC_SIZE,'$'
MOV BX,OFFSET RES+DEC_SIZE
xCYCLE: DEC BX
XOR DX,DX
DIV CX
ADD DL,'0'
MOV [BX],DL
CMP BX,OFFSET RES
JNE xCYCLE
MOV AH,09
LEA DX,RES
INT 21H
mov cx,temp
loop ft

ret
End Start

rxbagain
April 3rd, 2009, 12:08 PM
Check my reply on your other thread (http://www.codeguru.com/forum/showpost.php?p=1829488&postcount=5) :)