|
cl, VisualStudio 6.0
1. С оптимизацией по размеру, > cl /O1 /Fa /FAsc /c strtrm.c
PUBLIC _strtrm
; COMDAT _strtrm
_TEXT SEGMENT
_ptr$ = 8
_strtrm PROC NEAR ; COMDAT
; 7 : char *_pt = ptr;
; 8 : char _ch;
; 9 : while (*_pt++); // Find the string end
00000 8b 44 24 04 mov eax, DWORD PTR _ptr$[esp-4]
00004 80 38 00 cmp BYTE PTR [eax], 0
00007 8d 48 01 lea ecx, DWORD PTR [eax+1]
0000a 74 07 je SHORT $L471
$L470:
0000c 8a 11 mov dl, BYTE PTR [ecx]
0000e 41 inc ecx
0000f 84 d2 test dl, dl
00011 75 f9 jne SHORT $L470
$L471:
; 10 : --_pt; // Adjust pointer
00013 49 dec ecx
$L484:
; 11 : while (_pt > ptr) // Go to the sring start
00014 3b c8 cmp ecx, eax
00016 76 0e jbe SHORT $L482
; 12 : {
; 13 : _ch = *--_pt; // Get byte
00018 8a 51 ff mov dl, BYTE PTR [ecx-1]
0001b 49 dec ecx
; 14 : if (_ch!=' ' && _ch!='\t') // It's not a space or tab
0001c 80 fa 20 cmp dl, 32 ; 00000020H
0001f 74 f3 je SHORT $L484
00021 80 fa 09 cmp dl, 9
; 11 : while (_pt > ptr) // Go to the sring start
00024 74 ee je SHORT $L484
$L482:
; 15 : break; // then all done
; 16 : }
; 17 : *(_pt+1) = 0; // Terminate the string
00026 80 61 01 00 and BYTE PTR [ecx+1], 0
; 18 : return ptr;
; 19 : }
0002a c3 ret 0
_strtrm ENDP
2. Без оптимизации, > cl /Od /Fa /FAsc /c strtrm.c
PUBLIC _strtrm
_TEXT SEGMENT
_ptr$ = 8
__pt$ = -8
__ch$ = -4
_strtrm PROC NEAR
; 6 : {
00000 55 push ebp
00001 8b ec mov ebp, esp
00003 83 ec 08 sub esp, 8
; 7 : char *_pt = ptr;
00006 8b 45 08 mov eax, DWORD PTR _ptr$[ebp]
00009 89 45 f8 mov DWORD PTR __pt$[ebp], eax
$L470:
; 8 : char _ch;
; 9 : while (*_pt++); // Find the string end
0000c 8b 4d f8 mov ecx, DWORD PTR __pt$[ebp]
0000f 0f be 11 movsx edx, BYTE PTR [ecx]
00012 8b 45 f8 mov eax, DWORD PTR __pt$[ebp]
00015 83 c0 01 add eax, 1
00018 89 45 f8 mov DWORD PTR __pt$[ebp], eax
0001b 85 d2 test edx, edx
0001d 74 02 je SHORT $L471
0001f eb eb jmp SHORT $L470
$L471:
; 10 : --_pt; // Adjust pointer
00021 8b 4d f8 mov ecx, DWORD PTR __pt$[ebp]
00024 83 e9 01 sub ecx, 1
00027 89 4d f8 mov DWORD PTR __pt$[ebp], ecx
$L473:
; 11 : while (_pt > ptr) // Go to the sring start
0002a 8b 55 f8 mov edx, DWORD PTR __pt$[ebp]
0002d 3b 55 08 cmp edx, DWORD PTR _ptr$[ebp]
00030 76 27 jbe SHORT $L474
; 13 : _ch = *--_pt; // Get byte
00032 8b 45 f8 mov eax, DWORD PTR __pt$[ebp]
00035 83 e8 01 sub eax, 1
00038 89 45 f8 mov DWORD PTR __pt$[ebp], eax
0003b 8b 4d f8 mov ecx, DWORD PTR __pt$[ebp]
0003e 8a 11 mov dl, BYTE PTR [ecx]
00040 88 55 fc mov BYTE PTR __ch$[ebp], dl
; 14 : if (_ch!=' ' && _ch!='\t') // It's not a space or tab
00043 0f be 45 fc movsx eax, BYTE PTR __ch$[ebp]
00047 83 f8 20 cmp eax, 32 ; 00000020H
0004a 74 0b je SHORT $L475
0004c 0f be 4d fc movsx ecx, BYTE PTR __ch$[ebp]
00050 83 f9 09 cmp ecx, 9
00053 74 02 je SHORT $L475
; 15 : break; // then all done
00055 eb 02 jmp SHORT $L474
$L475:
; 16 : }
00057 eb d1 jmp SHORT $L473
$L474:
; 17 : *(_pt+1) = 0; // Terminate the string
00059 8b 55 f8 mov edx, DWORD PTR __pt$[ebp]
0005c c6 42 01 00 mov BYTE PTR [edx+1], 0
; 18 : return ptr;
00060 8b 45 08 mov eax, DWORD PTR _ptr$[ebp]
; 19 : }
00063 8b e5 mov esp, ebp
00065 5d pop ebp
00066 c3 ret 0
_strtrm ENDP
E-mail: info@telesys.ru