Assembly 汇编除法小数余数多于一个

Assembly 汇编除法小数余数多于一个,assembly,nasm,x86-16,division,Assembly,Nasm,X86 16,Division,我应该如何在组装中获得更多的分区号? 我只能打印第一个十进制数字:c org 100h ;start xor edx,edx mov eax,1 mov ebx,7 div ebx ; 1 / 7 ; EAX / EBX = EAX; remainder IN EDX ; EDX VALUE IS ONLY 1 INSTEAD OF 1428571428571429‬.... ; SO instead of printing 0,1428571428571429‬...x ;(x

我应该如何在组装中获得更多的分区号?
我只能打印第一个十进制数字:c

org 100h ;start

xor edx,edx 
mov eax,1 
mov ebx,7 
div ebx ; 1 / 7  
; EAX / EBX = EAX; remainder IN EDX
; EDX VALUE IS ONLY 1 INSTEAD OF 1428571428571429‬....
; SO instead of printing 0,1428571428571429‬...x 
;(x is how many decimal numbers I want) I can only print out 0,1 :(

mov ax,4c00h;end
int 21h

整数除法
div
从计算1/7中减去分数,因为它只能将结果的整数部分存储在
EAX
寄存器中

可以打印带9位小数的1/7计算结果,但仍然只能使用整数运算。只需将其放大一点,然后计算100000000/7

    ORG     256

    mov     eax, 1000000000
    mov     ebx, 7
    xor     edx, edx
    div     ebx          ; -> EAX = 142857142 EDX=6
; Rounding to nearest
    shr     ebx
    cmp     ebx, edx
    adc     eax, 0
; Converting to decimal characters
    mov     ebx, 10
    push    bx           ; Sentinel
  NextDiv:
    xor     edx, edx
    div     ebx
    add     dl, '0'
    push    dx
    test    eax, eax
    jnz     NextDiv
; Printing the result
    mov     ah, 02h      ; DOS.PrintChar
    mov     dl, '0'
    int     21h
    mov     dl, '.'
    int     21h
    pop     dx
  NextChar:
    int     21h
    pop     dx
    cmp     dx, bx
    jne     NextChar
; Giving yourself an opportunity to see the result
    mov     ah, 00h      ; BIOS.GetKey
    int     16h
; Quiting the program
    mov     ax, 4C00h    ; DOS.Terminate
    int     21h
上述程序将打印:

0.142857143 ‬


请注意,
div
给出的是余数,而不是小数点。在你的例子中,这个数字等于第一个小数位,这是一个巧合。尝试长除法。谢谢你的回答:)我是汇编新手,所以我应该使用函数还是循环?使用你需要的任何东西来解决这个问题。如果您不确定,请尝试先用高级语言绘制算法草图,然后将其翻译成汇编。指令
div
执行整数除法,在您的示例中,它给出商EAX=0,余数EDX=1。如果需要实数除法,请将内存中的数字定义为float
divident DD 1.0
除数DD 7.0
,然后使用