Question: NEED HELP WITH 1 & 2 ASSEMBLY CODE // Inline.cpp // // This file contains routines where functionality is inlined in assembly language // #include
NEED HELP WITH 1 & 2 ASSEMBLY CODE

// Inline.cpp // // This file contains routines where functionality is inlined in assembly language //
#include
void inline_memmove( void *dst, void *src, int nCount) { __asm {
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
DESCEND: std add edi,ecx dec edi add esi,ecx dec esi ASCEND: movsb dec ecx jne ASCEND
EXIT: cld pop eax // Student code ends here
pop ecx pop esi pop edi } return; } // inline_memmove
void printBytes(char *data, int length) { int x;
for(x = 0; x
return; } // printBytes
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!"); // requires 29 bytes 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 - Dst
// Case #3 - Dst > Src with overlap memset(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); } // callInLineFunctions
(10 pts) VS 1843 Computer Organization I. HW #06 Name/abc123; Due Mon Nov 6", 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 menmove 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. mommove! void *dstination, void *soirce, int nCounty. Assune 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 cash below after modification. 1. Destination and Scurce do not overlap. 2. Destination address Source address with overlap. Source Code on next two pages and included as "Inline.cpp" file also. (10 pts) VS 1843 Computer Organization I. HW #06 Name/abc123; Due Mon Nov 6", 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 menmove 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. mommove! void *dstination, void *soirce, int nCounty. Assune 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 cash below after modification. 1. Destination and Scurce do not overlap. 2. 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
Get step-by-step solutions from verified subject matter experts
