Je suis vraiment nouveau à la programmation de bas niveau et en utilisant 16 bits avec 4 registres, mais j'essaye d'écrire un programme pour vérifier si une chaîne entrée à partir du clavier, et terminé avec un arrêt complet (.), est un palindrome.Il sort 'y' au vdu si c'est le cas et 'n' sinon. Cependant, im des problèmes, il semble être que la sortie « y », peu importe si elle est un palindrome ou nonAsm programme pour vérifier un 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
16bit x86 a 8 registres, pas 4. (dont 7 sont plus ou moins généraux). 16bit est aussi plus compliqué que 32bit, donc c'est plus difficile à apprendre. Voir le [wiki du tag x86] (http://stackoverflow.com/tags/x86/info). –
Le'mov bl, 70' après 'palin:' doit être levé hors de la boucle, sinon vous allez vérifier le premier caractère tout le temps. –
quand vous dites sortir de la boucle, où dois-je exactement le mettre? merci par le chemin – DecafOyster208