我如何修复此代码的等效值? : 在notepad++中使用tasm/tlink/dosbox

How do i fix the equivalent value of this code? : Using tasm/tlink/dosbox in notepad++

我将尝试对 Bases 进行编码,我正在尝试使用 Bases 进行编码,但是当我进行编码时,出现了一个正确的等效值,但还有更多不正确的等效值。我的代码有什么问题?

我的代码:需要输入 2 位数字并根据所需的碱基范围和等效碱基将出现。如果您注意到我没有任何比较来确定是否需要输入基数 3 或所需的基数,我会把它放在下一个但首先我必须考虑我的代码逻辑有什么问题。

我在记事本++中的代码:

.model small
.stack 100h
.data
    
    Spc     db 0dh,0ah, " $"                                                ;New Line
    
    ;Bases Conversion
    ConT    db 0dh,0ah, "   Conversion  $"                                  ;Conversion Title
    ConBs3  db 0dh,0ah, "Base 3  to Base 5  "                           
            db 0dh,0ah,0dh,0ah, "Base 3 [00 to 22] : $"                     ;Enter Base 03 Number
    EqBs3       db 0dh,0ah, "Base 5 Equivalent : $"                         ;Equivalent Base 05
    
    ConBs4  db 0dh,0ah, "Base 4  to Base 5  "                           
            db 0dh,0ah,0dh,0ah, "Base 4 [00 to 33] : $"                     ;Enter Base 04 Number
    EqBs4       db 0dh,0ah, "Base 5 Equivalent : $"                         ;Equivalent Base 05
    
    ConBs5  db 0dh,0ah, "Base 5  to Base 4  "                           
            db 0dh,0ah,0dh,0ah, "Base 5 [00 to 44] : $"                     ;Enter Base 05 Number
    EqBs5       db 0dh,0ah, "Base 4 Equivalent : $"                         ;Equivalent Base 04
    
.code
main proc
    
    mov ax,@data                    ;initialize ds
    mov ds,ax
    
    Base3:
        mov ah,09h
        lea dx, Spc                 ;new line
        int 21h
        
        lea dx, ConT
        int 21h
        lea dx, ConBs3
        int 21h
        
        mov ah,01h
        int 21h                     ;1st Digit
        
        sub al,30h
        mov ch,al
        
        mov ah,01h
        int 21h                     ;2nd Digit
        
        sub al,30h
        mov cl,03h
        mul cl
        mov bx,ax
    
    Con1:
        add ch,bl
        mov ax,0000h
        mov al,ch
        mov bh,05h
        div bh
        mov cx,ax
        add cx,3030h
        
        mov ah,09h
        lea dx, EqBs3
        int 21h
        
        mov ah,02
        mov dl,cl
        int 21h
        mov dl,ch
        int 21h
    
    Base4:
        mov ah,09h
        lea dx, Spc                 ;new line
        int 21h
        
        lea dx, ConBs4
        int 21h
        
        mov ah,01h
        int 21h                     ;1st Digit
        
        sub al,30h
        mov ch,al
        
        mov ah,01h
        int 21h                     ;2nd Digit
        
        sub al,30h
        mov cl,04h
        mul cl
        mov bx,ax
        
    Con2:
        add ch,bl
        mov ax,0000h
        mov al,ch
        mov bh,05h
        div bh
        mov cx,ax
        add cx,3030h
        
        mov ah,09h
        lea dx, EqBs4
        int 21h
        
        mov ah,02
        mov dl,cl
        int 21h
        mov dl,ch
        int 21h
        
    Base5:
        mov ah,09h
        lea dx, Spc                 ;new line
        int 21h
        
        lea dx, ConBs5
        int 21h
        
        mov ah,01h
        int 21h                     ;1st Digit
        
        sub al,30h
        mov ch,al
        
        mov ah,01h
        int 21h                     ;2nd Digit
        
        sub al,30h
        mov cl,05h
        mul cl
        mov bx,ax
        
    Con3:
        add ch,bl
        mov ax,0000h
        mov al,ch
        mov bh,04h
        div bh
        mov cx,ax
        add cx,3030h
        
        mov ah,09h
        lea dx, EqBs5
        int 21h
        
        mov ah,02
        mov dl,cl
        int 21h
        mov dl,ch
        int 21h
        
        
    mov ah,4Ch                      ;end here
    int 21h
    
main endp
end main

等效输出误差:

建号出错

mov ah,01h
int 21h                     ;1st Digit
sub al,30h
mov ch,al

mov ah,01h
int 21h                     ;2nd Digit
sub al,30h
mov cl,03h
mul cl
mov bx,ax

您输入的第一个数字最高有效数字,这就是您需要的数字乘以基数。您的代码错误地将最低有效数字相乘!

    mov ah, 01h
    int 21h        ; 1st Digit
    sub al, 30h
    mov cl, 3      ; Radix
    mul cl
    mov ch, al     ; -> CH = MostSignificantDigit * Radix
    
    mov ah, 01h
    int 21h        ; 2nd Digit
    sub al, 30h
    add ch, al     ; -> CH = MostSignificantDigit * Radix + LeastSignificantDigit

其他数基也一样。