Je fais ce projet dans lequel l'utilisateur saisira deux chaînes et le programme identifiera ce qui est le plus long. Ensuite, il identifiera la première lettre, la lettre du milieu et la dernière lettre du mot le plus long.Langue de l'assemblage obtenant la première, le milieu et la dernière lettre d'un mot entré
Je ne parviens à le faire fonctionner si le 2ème mot est plus .. entrée mais quand le premier est plus je ne peux pas obtenir le milieu et la dernière aide letter..please .. Merci :)
mon code:
.data
msg db "Enter 1st word: $"
msg1 db 13,10,"Enter 2nd word: $"
msg2 db "1st word is longer $"
msg3 db "2nd word is longer $"
msg4 db "1st letter is: $"
msg5 db "middle letter is $"
msg6 db "last letter is $"
ln db 13,10,10,"$"
str1 dw 20
str2 dw 20
x db '0'
.code
main:
mov ax, @data
mov ds, ax
lea si, str1
lea di, str2
mov ah, 09
mov dx, offset msg
int 21h
mov ah, 0ah
mov dx, si
int 21h
mov ah, 09
mov dx, offset msg1
int 21h
mov ah, 0ah
mov dx, di
int 21h
;counter 1st word
mov bx, 0h
mov bx, str1 + 1
mov cl,bl
;counter 2nd word
mov bx, 0h
mov bx, str2 + 1
mov al, bl
cmp cl, al
jg long
jl short
long:
mov ah, 09
mov dx, offset ln
int 21h
mov ah, 09
mov dx, offset ln
int 21h
mov ah, 09
mov dx, offset msg2
int 21h
;first letter
mov ah, 09
mov dx, offset ln
int 21h
mov ah, 09
mov dx, offset msg4
int 21h
mov ah, 02
mov dl, si+2
int 21h
;/////////////////
;middle:
mov ah, 09
mov dx, offset ln
int 21h
mov ah, 09
mov dx, offset msg5
int 21h
mov bx, 0
mov bx, str1+1
mov ah, 0h
mov al, bl
mov bl, 02
div bl
mov ah, 0h
mov si, ax
mov bx,str1[si+4]
mov al,bl
mov ah, 02
mov dl, al
int 21h
;last
mov ah, 09
mov dx, offset ln
int 21h
mov ah, 09
mov dx, offset msg6
int 21h
mov bx, 0
mov bx, str1 + 1
mov bx, str1[si+6]
mov al, bl
mov ah, 02
mov dl,al
int 21h
jmp exit
short:
mov ah, 09
mov dx, offset ln
int 21h
mov ah, 09
mov dx, offset msg3
int 21h
mov ah, 09
mov dx, offset ln
int 21h
;first letter
mov ah, 09
mov dx, offset msg4
int 21h
mov ah, 02
mov dl, di+2
int 21h
;///////////////////////
;middle:
mov ah, 09
mov dx, offset ln
int 21h
mov ah, 09
mov dx, offset msg5
int 21h
mov bx, 0
mov bx, str2+1
mov ah, 0h
mov al, bl
mov bl, 02
div bl
mov ah, 0h
mov di, ax
mov bx,str1[di+4]
mov al,bl
mov ah, 02
mov dl, al
int 21h
;last
mov ah, 09
mov dx, offset ln
int 21h
mov ah, 09
mov dx, offset msg6
int 21h
mov bx, 0
mov bx, str2 + 1
mov bx, str1[di+6]
mov al, bl
mov ah, 02
mov dl,al
int 21h
jmp exit
exit:
end main
Donnez votre code, surtout si vous voulez que les autres vous aident. Décrivez votre algorithme, fournissez une entrée de test et une sortie attendue et réelle. Apprenez à utiliser un débogueur pour parcourir le code afin de trouver vos propres erreurs. – Jester
Un débogueur montrerait quelque chose de drôle quand vous lisez le deuxième mot. –
Veuillez montrer la sortie pour le cas de travail et le cas de non-travail. – prl