⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 一个通讯程序源码
💻
字号:
memmove() is a very, very fast non-overlapping memory copy, butsince it does not save certain registers it uses, calling fromGCC can be tricky.  GCC does a fabulous job of grinding all itcan out of the available registers; MSC doesn't make very gooduse of registers, er, I mean keeps a lot of registers for scratchuse.  I've never seen 386 MSC use dx except as a side effect ofmultiply.  I guess that's what somebody (Gates?) meant by "tuning"one compiler to meet many needs being adequate. Enough philosophy,though.I am using -fcall-used-{ax,bx,cx,dx} since in at least onecase (ecufkey.c display_keyset()), rigorous optimization andreally righteous register usage caused a call to strlen() toscrew up since cx is not preserved by strlen.strlen:         push    edistrlen+0x1:     mov     edi,[esp+0x8]strlen+0x5:     xor     eax,eax               <-- goodbye ax strlen+0x7:     mov     ecx,0xffffffff        <-- goodbye cxstrlen+0xc:     repne   scasbstrlen+0xe:     inc     ecx     strlen+0xf:     mov     eax,ecx strlen+0x11:    not     eaxstrlen+0x13:    pop     edistrlen+0x14:    retmemmove:        push    ebpmemmove+0x1:    mov     ebp,espmemmove+0x3:    mov     edx,edi               <-- move rather than pushmemmove+0x5:    mov     ebx,esi               <-- move rather than pushmemmove+0x7:    mov     esi,[ebp+0xc]memmove+0xa:    mov     edi,[ebp+0x8]memmove+0xd:    mov     eax,edi               <-- goodbye ax memmove+0xf:    mov     ecx,[ebp+0x10]        <-- goodbye cx (OK w/MSC)memmove+0x12:   jcxz    memmove+0x43memmove+0x14:   cmp     edi,esimemmove+0x16:   jbe     memmove+0x2ememmove+0x18:   mov     eax,esimemmove+0x1a:   add     eax,ecxmemmove+0x1c:   cmp     edi,eaxmemmove+0x1e:   jae     memmove+0x2ememmove+0x20:   mov     eax,edimemmove+0x22:   add     esi,ecxmemmove+0x24:   add     edi,ecxmemmove+0x26:   dec     esimemmove+0x27:   dec     edimemmove+0x28:   stdmemmove+0x29:   rep     movsbmemmove+0x2b:   cldmemmove+0x2c:   jmp     near memmove+0x43memmove+0x2e:   mov     eax,edimemmove+0x30:   test    Byte Ptr 0x1f:0x1,almemmove+0x36:   je      memmove+0x3amemmove+0x38:   movsbmemmove+0x39:   dec     ecxmemmove+0x3a:   shr     ecx,1memmove+0x3c:   rep     movswmemmove+0x3f:   adc     ecx,ecxmemmove+0x41:   rep     movsbmemmove+0x43:   mov     esi,ebxmemmove+0x45:   mov     edi,edxmemmove+0x47:   pop     ebpmemmove+0x48:   retmemmove+0x49:   nopmemmove+0x4a:   nopmemmove+0x4b:   nop---------------------------------------------------------------------The memmove in theis directory is written in x86 assemblerand is courtesy of Chip Salzenberg with some help fromRoger Cornelius.  I hacked out the .asm versions.Chip Salzenberg:> SCO's memmove() function in the 3.2v2 development system libc.a> library has an insidious bug: it trashes the EBX register.  This> register is used to hold register variables.  I suspect the bug crept> in due to a simple-minded translation of a '286 routine, because on> the '286, BX need not be preserved.> > The fix is to replace memmove.o in /lib/libc.a with the version> included below.  Note that if you use profiling, you must also put a> profiling version of memmove() in /usr/lib/libp/libc.a.> > To assemble the non-profiling version:> >     as -m -o memmove.o memmove.s(How strange that this bug has gone unnoticed for so long...)Roger Cornelius <rac@sherpa.UUCP> :> The following will build the profiling memmove.o correctly:> > m4 profile.s memmove.s > memmove_p.s    # order is important!> as -o memmove_p.o memmove_p.s> > Note also that manually running memmove.s through m4 (instead of> using as -m) before assembling will also save 100 or so bytes in the> .o file for the non-profiling version.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -