-4

アセンブリで2つの30桁の数字を追加したいと思います。ご存知のように、8086では30桁の数字を2つ追加することはできません。だから私は文字列でそれをしなければなりません。そして、AAAコマンドを使用して結果を合計変数に入れ、最後に実行したかどうかを確認しますが、主な問題は合計の結果が正しくないことです。それは私にこの668399+759133の合計で59427532を与えています。

正確な問題はどこにあるのか教えていただけますか?

    .model small
    .stack 64
    .data
    max1 db 30  
    acc1 db ?
    num1 db 30 dup('0')
    max2 db 30
    acc2 db ?
     num2 db 30
    sum db 31 dup('0'),'$'
    .code 
    start:
     mov ax,@data
     mov ds, Ax
     mov ah,0ah
     lea dx, max1   ;take max 1 and length store it to acc1
     int 21h 
     mov ah,0ah
     lea dx,max2    ;take max2 and length store it to acc2
     int 21h
       mov cl,acc1  ;check if they are equal
     cmp cl,acc2
     jne exit
     mov ch,0   ;make sure our cx is the length of our string
     clc
      mov si,cx ;set the length for index the char
      dec si        
      l1:
      mov al,num1[si]   ;sum two hex number
      adc al,num2[si]   ;add with carry flag
       aaa          ;seperate carry and  hex number and store it into al
       pushf    
       add al,30h       ;convert it to ascii again
       mov sum[si+2],al ;because of dec si we have to step
       popf
       dec si
       loop l1
       jne print
        mov sum,31h     ; if we have carry flag add to sum otherwise jumpt print 
       print:
       mov ah,09h       ;the main problem is here shows the result
       lea dx,sum
        int 21h                      
       exit:
      mov ax,4c00h
       int 21h
     end start    
4

1 に答える 1

1

私が問題を見つけたあなたの助けを私の友人に感謝します。mov sum [si + 2]、alの代わりにmov sum [si + 1]、alを置き換える必要があります

于 2012-04-19T11:34:49.840 に答える