Answer the question
In order to leave comments, you need to log in
How to implement such a loop in assembler: FOR I:=1 TO 9 DO IF X[I] < 0 THEN AL:=AL+1?
Here's what I have, maybe someone will tell you what's wrong or what to add, something is missing (it seems to me), and what I can't understand (don't judge strictly).
MOV SI,1
MOV CX,9
M1: MOV AL,ARRAY_X[SI]
CMP AL,0
JS M2
INC SI
M2: inc AL
LOOP M1
Answer the question
In order to leave comments, you need to log in
1. Do you place an array element in AL and increment it?
2. In this case, you can simply sum the sign bits in the elements. Something like this:
mov al, 0
mov si, 1
mov cx, 9
m1:
mov bl, ARRAY_X[si]
shr bl, 7
add al, bl
inc si
loop m1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question