VirtualBox

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

Last change on this file since 2988 was 2988, checked in by vboxsync, 17 years ago

InnoTek -> innotek part 4: more miscellaneous files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1; $Id: memcmp.asm 2988 2007-06-01 17:36:09Z vboxsync $
2;; @file
3; innotek Portable Runtime - No-CRT memcmp - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2007 innotek GmbH
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 as published by the Free Software Foundation,
13; in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14; distribution. VirtualBox OSE is distributed in the hope that it will
15; be useful, but WITHOUT ANY WARRANTY of any kind.
16;
17; If you received this file as part of a commercial VirtualBox
18; distribution, then only the terms of your commercial VirtualBox
19; license agreement apply instead of the previous paragraph.
20;
21
22%include "iprt/asmdefs.mac"
23
24BEGINCODE
25
26;;
27; @param pv1 gcc: rdi msc: rcx x86:[esp+4]
28; @param pv2 gcc: rsi msc: rdx x86:[esp+8]
29; @param cb gcc: rdx msc: r8 x86:[esp+0ch]
30BEGINPROC RT_NOCRT(memcmp)
31 cld
32
33 ; Do the bulk of the work.
34%ifdef __AMD64__
35 %ifdef ASM_CALL64_MSC
36 mov r10, rdi ; save
37 mov r11, rsi ; save
38 mov rdi, rcx
39 mov rsi, rdx
40 mov rcx, r8
41 mov rdx, r8
42 %else
43 mov rcx, rdx
44 %endif
45 mov rax, rdi ; save the return value
46 shr rcx, 3
47 repe cmpsq
48 jne .not_equal_qword
49%else
50 push edi
51 push esi
52
53 mov ecx, [esp + 0ch + 8]
54 mov edi, [esp + 04h + 8]
55 mov esi, [esp + 08h + 8]
56 mov edx, ecx
57 xor eax, eax
58 jecxz .done
59 shr ecx, 2
60 repe cmpsd
61 jne .not_equal_dword
62%endif
63
64 ; The remaining bytes.
65%ifdef __AMD64__
66 test dl, 4
67 jz .dont_cmp_dword
68 cmpsd
69 jne .not_equal_dword
70%endif
71.dont_cmp_dword:
72 test dl, 2
73 jz .dont_cmp_word
74 cmpsw
75 jne .not_equal_word
76.dont_cmp_word:
77 test dl, 1
78 jz .dont_cmp_byte
79 cmpsb
80 jne .not_equal_byte
81.dont_cmp_byte:
82
83.done:
84%ifdef __AMD64__
85 %ifdef ASM_CALL64_MSC
86 mov rdi, r10
87 mov rsi, r11
88 %endif
89%else
90 pop esi
91 pop edi
92%endif
93 ret
94
95;
96; Mismatches.
97;
98%ifdef __AMD64__
99.not_equal_qword:
100 mov ecx, 8
101 sub rsi, 8
102 sub rdi, 8
103.not_equal_byte:
104 repe cmpsb
105 mov al, [xDI-1]
106 movzx ecx, byte [xSI-1]
107 sub eax, ecx
108 jmp .done
109%endif
110
111.not_equal_dword:
112 mov ecx, 4
113 sub xSI, 4
114 sub xDI, 4
115 repe cmpsb
116%ifdef __AMD64__
117 jmp .not_equal_byte
118%else
119.not_equal_byte:
120 mov al, [xDI-1]
121 movzx ecx, byte [xSI-1]
122 sub eax, ecx
123 jmp .done
124%endif
125
126.not_equal_word:
127 mov ecx, 2
128 sub xSI, 2
129 sub xDI, 2
130 repe cmpsb
131 jmp .not_equal_byte
132ENDPROC RT_NOCRT(memcmp)
133
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