t takes an integer number as parameter. Keep dividing
the number by 10 until it reaches zero. Then compute the percentage of odd digits in that
number. ( Example if num=73458? then the percentage is = 3/5=0.6)
.model small
.data
x dd 73458
.code
MOV AX,@DATA
MOV DS,AX
mov si,offset x
mov ax,[si]
mov dx,[si+2]
mov cx,0
start1:
mov bx,10
start:
div bx
test dl, 1
jz l1
inc cx
l1:
test ax, ax
jz l2
xor dx, dx
jmp start
l2:
mov dx,cx
add dl,30h
mov ah,2
int 21h
mov dl,','
mov ah,2
int 21h
jmp l3
l3:mov cx,0
l4:
mov di,offset x
mov ax,[di]
mov dx,[di+2]
jmp l5
l5:
inc di
inc cx
jmp l2
end
but it doesnt count how many number in x
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…