Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
486 views
in Technique[技术] by (71.8m points)

x86 16 - i want to write this code in assembly 8086 macro

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...