Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Assembly Language, Create a strcat procedure (like C\'s strcat function).

ID: 3557402 • Letter: U

Question

Using Assembly Language,

Create a strcat procedure (like C's strcat function). Your procedure will be given the addresses (using the method presented in Chapter 8) of two string arrays. It will add the contents of the second array to the first. Make sure there is enough extra space in the first array to accomodate the characters that will be added. Your program will print the contents of both strings before calling strcat, then print the contents of string1 after the call. It should not change the second string in any way.

Here is the main for this assignment:

Explanation / Answer

strcat

enter     0,0

push    ECX

push    EDI

push    ESI

push    DS

push    ES

les        EDI,STRING1

mov      EDX,STR_MAX

cld                                  ;forward search

mov     AL,0                   ;null character

repne scasb

jcxz      st_no_string

dec      EDI                             ;back upto point to null

lds      ESI,STRING2             ;src string pointer

push    DS

push    ESI

call       str_len

jc          st_no_string

mov      ECX,EAX

inc        ECX         ;increment

cld

rep       movsb

mov     EAX,[EBP+8]

clc

jmp     SHORT st_done

st_no_string

stc

st_done:

pop     ES

pop     DS

pop    ESI

pop    EDI

pop    ECX

leave

ret       16                          ;clear stack and return

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote