Question: help! Implement the memset function using inline assembly. The memset function copies value starting at the destination address and ending at destination address + nCount
help!
Implement the memset function using inline assembly. The memset function copies "value" starting at the destination address and ending at destination address + nCount -1. It is used to set a block of memory to a specific value, often times initializing a memory block with a value of zero. memset (void *destination, unsigned char value, int nCount). Example: dst = 0x1000, value = 0xA5, nCount = 5 Memory values Before: 0x1000: 3A 28 A1 BE CA FE DE AD 11.. After: 0x1000: A5 A5 A5 A5 A5 FE DE AD 11... Void function() { char string[] = " The end is near!";//this is 16 bytes + null printf("The message is: %s ", string): _asm { mov eax, 16: push the length push eax mov eax, 0x41: push the value push eax lea eax, string: push the address of string push eax call inline-memset add esp, 12 jmp EXIT inline-memset:: this is where you write the code to implement the memset EXIT: } printf("Now return the message string is: %s ", string): return: }//end function Deliverables: Hard copy of your source code WITH COMMENTS and a screenshot of the output of your program running. Implement the memset function using inline assembly. The memset function copies "value" starting at the destination address and ending at destination address + nCount -1. It is used to set a block of memory to a specific value, often times initializing a memory block with a value of zero. memset (void *destination, unsigned char value, int nCount). Example: dst = 0x1000, value = 0xA5, nCount = 5 Memory values Before: 0x1000: 3A 28 A1 BE CA FE DE AD 11.. After: 0x1000: A5 A5 A5 A5 A5 FE DE AD 11... Void function() { char string[] = " The end is near!";//this is 16 bytes + null printf("The message is: %s ", string): _asm { mov eax, 16: push the length push eax mov eax, 0x41: push the value push eax lea eax, string: push the address of string push eax call inline-memset add esp, 12 jmp EXIT inline-memset:: this is where you write the code to implement the memset EXIT: } printf("Now return the message string is: %s ", string): return: }//end function Deliverables: Hard copy of your source code WITH COMMENTS and a screenshot of the output of your program running
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
