home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 2,726 of 4,675   
   Rod Pemberton to Rick C. Hodgin   
   Re: Optimize stricmp() algorithm (casele   
   26 Jun 17 20:14:20   
   
   From: NeedNotReplyHere@nospicedham.xrsevnneqk.cem   
      
   On Mon, 26 Jun 2017 01:45:25 -0700 (PDT)   
   "Rick C. Hodgin"  wrote:   
      
   > Oh my ... AT&T syntax.   
      
   With -O2, 32-bit GCC (DJGPP for DOS) generates:   
      
   .globl _rp_stricmp   
   _rp_stricmp:   
   	push	ebp   
   	mov	ecx, 1   
   	mov	ebp, esp   
   	push	esi   
   	push	ebx   
   	mov	edx, DWORD PTR [ebp+12]   
   	mov	ebx, DWORD PTR [ebp+8]   
   L10:   
   	test	ecx, ecx   
   	je	L3   
   	movsx	ecx, BYTE PTR [ebx]   
   	movsx	esi, BYTE PTR [edx]   
   	inc	ebx   
   	inc	edx   
   	cmp	ecx, esi   
   	je	L10   
   	mov	al, BYTE PTR _lower[esi]   
   	cmp	BYTE PTR _lower[ecx], al   
   	je	L10   
   L3:   
   	sub	ecx, esi   
   	pop	ebx   
   	mov	eax, ecx   
   	pop	esi   
   	pop	ebp   
   	ret   
      
   With -O2, 64-bit GCC (for Linux) generates:   
      
   	.globl	rp_stricmp   
   	.type	rp_stricmp, @function   
   rp_stricmp:   
   .LFB15:   
   	.cfi_startproc   
   	push	rbx   
   	.cfi_def_cfa_offset 16   
   	.cfi_offset 3, -16   
   .L2:   
   	movsx	eax, BYTE PTR [rdi]   
   	movsx	edx, BYTE PTR [rsi]   
   	add	rdi, 1   
   	add	rsi, 1   
   	cmp	eax, edx   
   	je	.L4   
   	movsx	rcx, edx   
   	movsx	r8, eax   
   	movzx	ebx, BYTE PTR lower[rcx]   
   	cmp	BYTE PTR lower[r8], bl   
   	je	.L4   
   .L3:   
   	sub	eax, edx   
   	pop	rbx   
   	.cfi_remember_state   
   	.cfi_def_cfa_offset 8   
   	ret   
   	.p2align 4,,10   
   	.p2align 3   
   .L4:   
   	.cfi_restore_state   
   	test	eax, eax   
   	jne	.L2   
   	.p2align 4,,7   
   	jmp	.L3   
   	.cfi_endproc   
      
      
   Rod Pemberton   
   --   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca