Question: The following 8 0 8 6 assembly program is supposed to concatenate two strings but it doesn't work properly. Why is that? . 5 8
The following assembly program is supposed to concatenate two strings but it doesn't work properly. Why is that?
MODEL FLAT
STACK
INCLUDE ioh
DATA
Inputstr BYTE DUP
Inputstr BYTE DUP
Outputstr BYTE DUP
prompt BYTE "Enter the first string:
prompt BYTE "Enter the second string:
displayLbl BYTE "Concatenated string:
CODE
MainProc PROC
input prompt Inputstr
input prompt Inputstr
; Copy the first string to Outputstr
mov esi, OFFSET Inputstr
mov edi, OFFSET Outputstr
mov ecx,
cld
rep movsb
; Find the end of the first string
mov ebx, edi ; Save the current position in ebx
lea esi, OFFSET Inputstr
add edi, ; Move edi to the end of the copied string
mov ecx,
repne scasb ; Find the null terminator
; Copy the second string to Outputstr
mov esi, OFFSET Inputstr
mov edi, ebx ; Restore the saved position
sub edi, ; Move edi back one byte to overwrite the null terminator
mov ecx,
cld
rep movsb
output displayLbl, Outputstr
mov eax,
ret
MainProc ENDP
END
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
