Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in main.asm when a char is encrypted to '\0' (NULL char) #38

Closed
MostafaSaad7 opened this issue Jan 8, 2021 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@MostafaSaad7
Copy link
Collaborator

BUG in main.asm

main.asm have a bug: When a char is encrypted to '\0', there is a problem happens when we copy teaOut to teaIn again for decryption because Str_copy copys characters till it finds a '\0' so the teaOut is not fully copied back to teaIn in this case.

Failed test case:
input: MACBETH. My dearest love, Duncan comes here tonight. LADY MACBETH. And when goes hence? MACBETH. Tomorrow, as he purposes. LADY MACBETH.
Enter Key 1: 7
Enter Key 2: 8
Enter Key 3: 9
Enter Key 4: 0

-------------------------------------------------------------------------------------------------------------------------

Program Output:

Encrypted: ╤;╘ûطQ▼s�<Rn╩n"ئnص²ظp├╕ٌّDû╨╗fo┴¤ئ├╖%"╪�►└3
┼→¤ ?<eء:ص#كِs√(z5ًB╬
VV-H4J≡}g �.cصطyٌë�ê╤;╘ûط
Q▼╧┬■Z ≡▼ⁿ╟�7ُئcS╙%╢/اْrف▐▄عu╔ô╜ë/╤;╘ûط~Q▼

Decrypted: MACBETH. My dearest love, Duncan comes here tonight. LADY MACBET∙↑┘'3îّTb↔️═┐Z)زx│«nlt«$→▀ْ5╥▒╩��♣️ى┐PT
UPr▬إ%
«رt►ج▼1ع~دس≡#\VP╫ب£▀ْ5╥▒╩��

-------------------------------------------------------------------------------------------------------------------------

Expected Output:

Encrypted: ╤;╘ûطQ▼s�<Rn╩n"ئnص²ظp├╕ٌّDû╨╗fo┴¤ئ├╖%"╪�►└3
┼→¤ ?<eء:ص#كِs√(z5ًB╬
V V-H4J≡}g �.cصطyٌë�ê╤;╘ûط
Q▼╧┬■Z ≡▼ⁿ╟�7ُئcS╙%╢/اْrف▐▄عu╔ô╜ë/╤;╘ûط~Q▼

Decrypted: MACBETH. My dearest love, Duncan comes here tonight. LADY MACBETH. And when goes hence? MACBETH. Tomorrow, as he purposes. LADY MACBETH.

@MariamGad
Copy link
Collaborator

MariamGad commented Jan 8, 2021

Fri 8/1/2021
I solved this bug by replacing how teaOut is copied into teaIn

Replaced

; teaIn = teaOut //copy teaOut in teaIn
lea eax, teaOut
lea ebx, teaIn
INVOKE Str_copy,eax, ebx

in main
to

; teaIn = teaOut //copy teaOut in teaIn
mov ecx, newSize
lea ebx, teaOut
lea edx, teaIn
copyLoop:
mov al, [ebx]
mov [edx], al
inc edx
inc ebx
LOOP copyLoop

@MostafaAE MostafaAE moved this from In progress to Done in Microprocessor course project Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

5 participants