Question
Copy and paste version please help guys void inline_memmove( void *dst, void *src, int nCount) { __asm { DESCEND: ASCEND: EXIT: } push edi push
Copy and paste version please help guys
void inline_memmove( void *dst, void *src, int nCount) {
__asm {
DESCEND:
ASCEND:
EXIT:
}
push edi push esi push ecx
mov edi,dst push edi mov esi,src mov ecx,nCount
// Student modification code begins here
xor eax,eax cmp eax,edi je EXIT
cmp eax,esi je EXIT
cmp edi,esi je EXIT
cld jc ASCEND
std add edi,ecx dec edi add esi,ecx dec esi
movsb dec ecx jne ASCEND
cld pop eax // Student code ends here
pop ecx pop esi pop edi
return; } // inline_memmove
2017 06 CS 3843 Computer Organization - Homework
Page 2
void callInLineFunctions() {
int x, tmpi; char dstA[32], srcA[64]; // no overlap char overlap[256], *ptrDstO, *ptrSrcO;
// Case #1 - no overlap
memset(dstA, 0x90, 32); strcpy(srcA, "Say goodbye to the lazy dog!"); printf(" --- srcA = %s ", srcA); printBytes(srcA, 32); tmpi = inline_memmove4(dstA, srcA, strlen(srcA)+1 ); printf(" dstA @ Address:%08x (tmpi=%08x) = %s ", dstA, tmpi, dstA); printBytes(dstA, 32);
// Case #2 - Dstmemset(overlap, 0x90, 256); ptrDstO = &overlap[0]; ptrSrcO = &overlap[5]; strcpy(ptrSrcO, "Say goodbye to the lazy dog that quietly jumped over the brown red
fox."); printf(" --- srcA @ Address:%08x = %s, %d ", ptrSrcO, ptrSrcO,
strlen(ptrSrcO)+1 ); printBytes(ptrSrcO, 96);tmpi = inline_memmove4(ptrDstO, ptrSrcO, strlen(ptrSrcO)+1 ); printf(" dstA @ Address:%08x (tmpi=%08x) = %s ", ptrDstO, tmpi, ptrDstO); printBytes(ptrDstO, 96);
// Case #3 - Dst > Src with overlapmemset(overlap, 0x90, 256); ptrDstO = &overlap[5]; ptrSrcO = &overlap[0]; strcpy(ptrSrcO, "Say hello to the brown red fox that quietly jumped over the lazy
dog."); printf(" --- srcA @ Address:%08x = %s, %d ", ptrSrcO, ptrSrcO,
strlen(ptrSrcO)+1); printBytes(ptrSrcO, 96);tmpi = inline_memmove4(ptrDstO, ptrSrcO, strlen(ptrSrcO)+1 ); printf(" dstA @ Address:%08x (tmpi=%08x) = %s ", ptrDstO, tmpi, ptrDstO); printBytes(ptrDstO, 96);
//*/
exit(0); } // callInLineFunctions10 pth) CS 3843 Computer orpaniwioa li w Namcabe23. Due Wed Jul 261th, 2017 1. (5 pts) Implement the memmove instruction as discussed in class and verify that it works- the code is below. Also note that I have set up the stack to test the various scenarios memmove is supposed to encounter. This memmove copies one byte at a time 2. (5 pts) Enhance the memmove as described in class such that it will copy 4 bytes at a time and then finish off the remaining 1,2, or 3 bytes as needed. memmove void "destination, void source, int nCount) As sume edi = destination address, esi = source address and ecx = nCount Deliverables: Hard copy of the modified source code WITH COMMENTS on the student source code, and a screenshot of the output of your program running. Make sure to show 6 cases: Each of the ones below before code modification and each below after modification 1. Destination and Source do not overlap 2. Destination address Source address with overlap. 3. Destination address > Source address with overlap. Source Code on next two pages and included as "Inline.cpp" file also
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started