VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/memcmp.asm@ 72778

Last change on this file since 72778 was 69219, checked in by vboxsync, 7 years ago

Runtime: scm cleanups

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.2 KB
Line 
1; $Id: memcmp.asm 69219 2017-10-24 15:01:30Z vboxsync $
2;; @file
3; IPRT - No-CRT memcmp - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2017 Oracle Corporation
8;
9; This file is part of VirtualBox Open Source Edition (OSE), as
10; available from http://www.virtualbox.org. This file is free software;
11; you can redistribute it and/or modify it under the terms of the GNU
12; General Public License (GPL) as published by the Free Software
13; Foundation, in version 2 as it comes in the "COPYING" file of the
14; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; The contents of this file may alternatively be used under the terms
18; of the Common Development and Distribution License Version 1.0
19; (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20; VirtualBox OSE distribution, in which case the provisions of the
21; CDDL are applicable instead of those of the GPL.
22;
23; You may elect to license modified versions of this file under the
24; terms and conditions of either the GPL or the CDDL or both.
25;
26
27%include "iprt/asmdefs.mac"
28
29BEGINCODE
30
31;;
32; @param pv1 gcc: rdi msc: rcx x86:[esp+4]
33; @param pv2 gcc: rsi msc: rdx x86:[esp+8]
34; @param cb gcc: rdx msc: r8 x86:[esp+0ch]
35RT_NOCRT_BEGINPROC memcmp
36 cld
37 xor eax, eax
38
39 ; Do the bulk of the work.
40%ifdef RT_ARCH_AMD64
41 %ifdef ASM_CALL64_MSC
42 mov r10, rdi ; save
43 mov r11, rsi ; save
44 mov rdi, rcx
45 mov rsi, rdx
46 mov rcx, r8
47 mov rdx, r8
48 %else
49 mov rcx, rdx
50 %endif
51 shr rcx, 3
52 repe cmpsq
53 jne .not_equal_qword
54%else
55 push edi
56 push esi
57
58 mov ecx, [esp + 0ch + 8]
59 mov edi, [esp + 04h + 8]
60 mov esi, [esp + 08h + 8]
61 mov edx, ecx
62 jecxz .done
63 shr ecx, 2
64 repe cmpsd
65 jne .not_equal_dword
66%endif
67
68 ; The remaining bytes.
69%ifdef RT_ARCH_AMD64
70 test dl, 4
71 jz .dont_cmp_dword
72 cmpsd
73 jne .not_equal_dword
74%endif
75.dont_cmp_dword:
76 test dl, 2
77 jz .dont_cmp_word
78 cmpsw
79 jne .not_equal_word
80.dont_cmp_word:
81 test dl, 1
82 jz .dont_cmp_byte
83 cmpsb
84 jne .not_equal_byte
85.dont_cmp_byte:
86
87.done:
88%ifdef RT_ARCH_AMD64
89 %ifdef ASM_CALL64_MSC
90 mov rdi, r10
91 mov rsi, r11
92 %endif
93%else
94 pop esi
95 pop edi
96%endif
97 ret
98
99;
100; Mismatches.
101;
102%ifdef RT_ARCH_AMD64
103.not_equal_qword:
104 mov ecx, 8
105 sub rsi, 8
106 sub rdi, 8
107 repe cmpsb
108.not_equal_byte:
109 mov al, [xDI-1]
110 movzx ecx, byte [xSI-1]
111 sub eax, ecx
112 jmp .done
113%endif
114
115.not_equal_dword:
116 mov ecx, 4
117 sub xSI, 4
118 sub xDI, 4
119 repe cmpsb
120%ifdef RT_ARCH_AMD64
121 jmp .not_equal_byte
122%else
123.not_equal_byte:
124 mov al, [xDI-1]
125 movzx ecx, byte [xSI-1]
126 sub eax, ecx
127 jmp .done
128%endif
129
130.not_equal_word:
131 mov ecx, 2
132 sub xSI, 2
133 sub xDI, 2
134 repe cmpsb
135 jmp .not_equal_byte
136ENDPROC RT_NOCRT(memcmp)
137
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette