Я действительно новичок в программировании на низком уровне и с использованием 16-битного с 4 регистрами, но я пытаюсь написать программу, чтобы проверить, введена ли строка с клавиатуры и завершена с полной остановкой (.), является палиндром. Он выводит «y» в vdu, если он есть, и «n», если нет. Однако им с проблемами, кажется, будет выводить только «Y», независимо от того, если это палиндром или неПрограмма Asm для проверки на palindrome
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
16 бит x86 имеет 8 регистров, а не 4. (7 из которых более или менее универсальны). 16 бит также более сложный, чем 32-битный, поэтому его сложнее изучить. См. [X86 tag wiki] (http://stackoverflow.com/tags/x86/info). –
The'mov bl, 70' после 'palin:' необходимо вытащить из цикла, иначе вы будете проверять первый символ все время. –
, когда вы говорите, что выходите из петли, где именно я должен это поставить? спасибо, кстати, – DecafOyster208