프로그래밍 어셈블리를 처음 사용했습니다. 이제 10 진수에서 2 진수로 변환하는 프로그램을 작성하려고합니다. 그러나 입력을 시도하는 중에 하나의 프로그램에 붙어 있습니다. msg2를 출력하고 루프에 들어가면 프로그램이 꺼지지 않습니다. 많은 숫자를 입력 할 수 있으며 프로그램이 꺼지지 않습니다. 나는 문제가 convertnumber에있는 것 같아요 : cmp si, cx (si는 얼마나 많은 숫자를 입력해야합니까, cx- 내가 얼마나 많은 숫자를 썼는지), 그러나 그것에 대해서는 확실하지 않습니다. 나는 어디에서 실수를했으며 어떻게 해결할 수 있습니까?어셈블리 프로그래밍 버그
.MODEL small
.Stack 100h
.DATA
msg0 db 'how many numbers will include your input number(example. 123 is 3 numbers)? $'
msg1 db 'Now input number from 0 to 65535: $'
number db 255, ?, 256 dup ('$')
numberinAscii db 255, ?, 256 dup ('$')
enterbutton db 13,10,'$'
.CODE
start:
mov ax, @data
mov ds,ax
mov ah,09h
mov dx, offset msg0 ; first message output
int 21h
xor ah,ah ; function 00h of
int 16h ; int 16h gets a character (ASCII translation in AL)
int 3
mov bl,al
mov dl,al
mov ah,02h ; function 02h - display character
int 21h ; call DOS service
mov ah,09h
mov dx, offset enterbutton
int 21h
mov ah, 09h
mov dx, offset msg1 ; output second message
int 21h
jmp covertHowMany ; converting number that we entered
next:
xor si,si
mov si, ax ; number that we entered now is in si
xor cx,cx
mov cx,0 ;cx=0
enterfirstnumber: ;entering first number (example 123, first number is 1)
xor ah,ah
int 16h ; int 16h gets a one character
int 3
mov bl,al
mov dl,al
mov ah,02h ; function 02h - display character
int 21h ;
jmp convertnumber ; converting this number
input: ;converting number from ascii char to ascii integer
mov ax,bx
mov dx,10
mul dx ; ax:=ax*10
mov bx,ax ; number that I try to convert is in bx now
xor ah,ah
int 16h ; int 16h gets a character (ASCII translation in AL)
int 3
mov bl,al
mov dl,al
mov ah,02h ; function 02h - display character
int 21h
jmp convertnumber
convertHowMany:
sub al,30h ; convert from ascii character to ascii number
jmp next
convertnumber:
sub al,30h
add bx,ax
inc cx
cmp cx, si
jne input
jmp ending
ending:
mov ax,04C00h
int 21h
end start
디버거를 사용하는 방법을 배우고 직접 문제를 찾을 수 있도록하는 것이 좋습니다. –