I have a task: to count the number of elements in the array that are less than the entered number. How to properly compare an array element with this variable? It turns out to compare the value of an element with a constant, but not with the entered number My code:
.model small
.stack 100h
.data
array db 1, 2, 3, 4, 7, 5, 6
n db 3, ?, 3 dup(?)
counter dw 0
.code
StrToNumber PROC
mov bh, [si + 2]
mov bl, [si + 3]
sub bx, 3030h
mov al, 10
mul bh
add al, bl
ret
ENDP
start:
;started program exe
mov ax,@data
mov ds, ax
mov ah, 0Ah
lea dx, n
int 21h
lea si, n
call StrToNumber
mov cl, al
lea bx, array
beg:
mov ax, [bx]
cmp ax, 0
jge skip
push bx
lea bx, counter
mov ax, [bx]
inc ax
mov [bx], ax
pop bx
skip:
add bx, 4
loop beg
exit:
mov ax,4c00h
int 21h
end start