Function 用于检查回文的Asm程序

Function 用于检查回文的Asm程序,function,assembly,palindrome,low-level,16-bit,Function,Assembly,Palindrome,Low Level,16 Bit,我对低级编程非常陌生,使用16位和4个寄存器,但我正在尝试编写一个程序来检查从键盘输入并以句号(.)结尾的字符串是否是回文。如果是,它会向vdu输出“y”,如果不是,则输出“n”。 然而,我有问题,它似乎只输出“y”,不管它是否是回文 mov bl,70 ; Memory Start Address mov dl,0 ; how many characters make up the string loop: in 00 ;read inpu

我对低级编程非常陌生,使用16位和4个寄存器,但我正在尝试编写一个程序来检查从键盘输入并以句号(.)结尾的字符串是否是回文。如果是,它会向vdu输出“y”,如果不是,则输出“n”。 然而,我有问题,它似乎只输出“y”,不管它是否是回文

mov bl,70        ; Memory Start Address
mov dl,0         ; how many characters make up the string

loop:
in 00            ;read input from the keyboard
cmp al, 2E       ;check to see if the input is a fullstop
jz palin         ;jump to see if the input is a palindrome
mov [bl], al     ;save the input in memory address
inc bl           ;goto next memory addr in bl
inc dl           ;increment dl by 1 to the length of the string
push al
jmp loop

palin:
cmp dl,0         ;check if it has gone through the whole string
jz ispalin       ;jump it has then the string is a palindrome
mov bl, 70       ;bring back the first input character
mov dl,[bl]
pop cl           ;put the last input character
cmp cl,dl        ;check if these two values are the same
jnz notpalin     ;if they are not then jump to notpalin
inc bl           ;go to the next input addr
dec dl           ;take away 1 from the length of the string
jmp palin        ;jump pack to the start of palin

notpalin:
mov dl,c0
mov cl,6E
mov [dl],cl      ;print the character 'n' to the vdu

ispalin:
mov dl,c0
mov cl,79
mov [dl],cl      ;print the character 'y' to the vdu

end

如果要在代码中的某个位置更改程序流,则需要使用跳转:

notpalin:
mov dl,c0
mov cl,6E
mov [dl],cl      ;print the character 'n' to the vdu
jmp done         ; do not execute the code at ispalin

ispalin:
mov dl,c0
mov cl,79
mov [dl],cl      ;print the character 'y' to the vdu

done:

我没有检查代码的其余部分,因此可能存在其他问题。

如果要在代码中的某个位置更改程序流,需要使用跳转:

notpalin:
mov dl,c0
mov cl,6E
mov [dl],cl      ;print the character 'n' to the vdu
jmp done         ; do not execute the code at ispalin

ispalin:
mov dl,c0
mov cl,79
mov [dl],cl      ;print the character 'y' to the vdu

done:

我没有检查代码的其余部分,因此可能存在其他问题。

16位x86有8个寄存器,而不是4个。(其中7个或多或少是通用的)。16位也比32位更复杂,所以学习起来更难。请参见
mov bl,70
佩林:之后的?顺便说一下,谢谢16位x86有8个寄存器,而不是4个。(其中7个或多或少是通用的)。16位也比32位更复杂,所以学习起来更难。请参见
mov bl,70
佩林:之后的?顺便谢谢你