Changeset 8e3f47b3 in mainline
- Timestamp:
- 2005-10-04T22:06:07Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1084a784
- Parents:
- ce031f0
- Location:
- arch/ia32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/ia32/include/memstr.h
rce031f0 r8e3f47b3 32 32 extern void memsetw(__address dst, size_t cnt, __u16 x); 33 33 extern void memsetb(__address dst, size_t cnt, __u8 x); 34 35 extern int memcmp(__address src, __address dst, int cnt);36 34 37 35 /** Copy memory … … 72 70 73 71 72 /** Compare memory 73 * 74 * Compare a given number of bytes (3rd argument) 75 * at memory locations defined by 1st and 2nd argument 76 * for equality. If memory is equal, returns 0. 77 * 78 * @param pointer 1 79 * @param pointer 2 80 * @param number of bytes 81 * @return 0 on match or non-zero if different 82 */ 83 static inline int memcmp(const void * mem1, const void * mem2, size_t cnt) 84 { 85 __u32 d0, d1, d2; 86 int ret; 87 88 __asm__ ( 89 "repe cmpsb\n\t" 90 "je 1f\n\t" 91 "movl %3, %0\n\t" 92 "addl $1, %0\n\t" 93 "1:\n" 94 : "=a" (ret), "=%S" (d0), "=&D" (d1), "=&c" (d2) 95 : "0" (0), "1" (mem1), "2" (mem2), "3" (cnt) 96 ); 97 98 return ret; 99 } 74 100 75 101 #endif -
arch/ia32/src/asm.S
rce031f0 r8e3f47b3 40 40 .global memsetb 41 41 .global memsetw 42 .global memcmp43 44 42 45 43 ## Turn paging on … … 200 198 pop %eax 201 199 202 ret203 204 205 ## Compare memory regions for equality206 #207 # Compare a given number of bytes (3rd argument)208 # at memory locations defined by 1st and 2nd argument209 # for equality. If the bytes are equal, EAX contains 0.210 #211 SRC=12212 DST=16213 CNT=20214 memcmp:215 push %esi216 push %edi217 218 movl CNT(%esp),%ecx219 movl DST(%esp),%edi220 movl SRC(%esp),%esi221 222 repe cmpsb %es:(%edi),%ds:(%esi)223 movl %ecx,%eax # %ecx contains the return value (zero on success)224 225 pop %edi226 pop %esi227 228 200 ret 229 201
Note:
See TracChangeset
for help on using the changeset viewer.