TASM 8086输出问题

时间:2017-04-11 23:22:23

标签: assembly intel x86-16 tasm

xor ax,ax
xor dx,dx
mov ax,prima
mov dl,al
mov ah,2
int 21h

变量' prima'已经存储了33h,它应该打印" 3",但它没有,它打印" 0"如果我正常运行程序。让我感到困惑的是我使用DOSBox进行调试,如果我按下查看输出它会显示" 3" (并且注册面板显示AL为33h)应该如此 以前有人遇到过这个问题吗?代码计算pi。

data segment
            s0 db 25 dup(0ah), 'pi=  $'
            s1 db 2 dup(0ah), ' $'
            n dw 0                 
            z dw 0               
            r dw 0           
            o dw 0
            j dw 0                  
            x dw 0                  
            y dw 0
            xp dw 0                 
            yp dw 0
            rp dw 0
            cp dw 0            
            l db 0
            css dw 0
            patru dw 0
            pi dw 0
            prima dw 0
            adoua dw 0
            atreia dw 0
            data ends

            assume cs:code, ds:data
            code segment
            start:
            mov ax,data
            mov ds,ax

            mov n,93
            mov z,10
            mov r,50
            mov o,1000
            mov j,1
            mov ax,n
            mov x,ax
            mov l,0
            mov css,56
            mov patru,4

        .for:

            cmp j,1
            jne .if1                

                mov ax,x            
                mul x
                mov x,ax

                cmp x,1000          
                    ja .nrbununu      
                    mov ax,x        
                    mul z
                    mov x,ax
                    .nrbununu:

                mov ax,x             ; x=x%1000/10
                xor dx,dx   
                div o
                mov ax,dx
                xor dx,dx
                div z
                mov x,ax             ;

                mov y,ax             ; y=x;
                inc j            

            .if1:



            cmp j,2
            jne .if2               

                mov ax,y            
                mul y
                mov y,ax

                cmp y,1000          
                    ja .nrbundoi       
                    mov ax,y         
                    mul z
                    mov y,ax
                    .nrbundoi:

                mov ax,y             ; y=y%1000/10
                xor dx,dx   
                div o
                mov ax,dx
                xor dx,dx
                div z
                mov y,ax             ;


                mov ax,x            
                mul x
                mov xp,ax
                mov ax,y
                mul y
                mov yp,ax
                mov ax,r
                mul r
                mov rp,ax           ;

                mov ax,xp
                add ax,yp

                cmp ax, rp
                ja .contor
                    inc bl

                .contor:
                mov j,1

            .if2:


        inc cx
        cmp cx,56
        jnle .forx
        jmp .for
        .forx:

        mov ax,bx
        mul patru
        xor dx,dx
        div css
        mov prima,ax
        add prima,48
        mov ax,dx
        mul z
        div css
        mov adoua,ax
        add adoua,48
        mov ax,dx
        mul z
        div css
        mov atreia,ax
        add atreia,48

        mov dx, offset s0
        mov ah,9
        int 21h

        xor ax,ax
        xor dx,dx
        mov ax,prima
        mov dl,al
        mov ah,2
        int 21h

        mov dl,2ch
        mov ah,2
        int 21h

        xor ax,ax
        xor dx,dx
        mov ax,adoua
        mov dl,al
        mov ah,2
        int 21h

        xor ax,ax
        xor dx,dx
        mov ax,atreia
        mov dl,al
        mov ah,2
        int 21h





        mov ah,4ch
        int 21h
        code ends
        end start

1 个答案:

答案 0 :(得分:0)

第一次使用CXinc cx。您假设CX在开始时为0。实际上,调试器将其设置为0.但是,假设是错误的。使用CX .for之前的xor cx,cx初始化_STACK SEGMENT PARA STACK 'STACK' dw 1024 dup (?) _STACK ENDS

BTW:别忘了定义一个堆栈:

doc.setTextWidth(options.rect.width())