VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/string/strncpy.asm@ 67979

Last change on this file since 67979 was 62477, checked in by vboxsync, 8 years ago

(C) 2016

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1; $Id: strncpy.asm 62477 2016-07-22 18:27:37Z vboxsync $
2;; @file
3; IPRT - No-CRT strncpy - AMD64 & X86.
4;
5
6;
7; Copyright (C) 2006-2016 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 pszDst gcc: rdi msc: rcx x86:[esp+4]
33; @param pszSrc gcc: rsi msc: rdx x86:[esp+8]
34; @param cbMax gcc: rdx msc: r8 x86:[esp+12]
35RT_NOCRT_BEGINPROC strncpy
36 ; input
37%ifdef RT_ARCH_AMD64
38 %ifdef ASM_CALL64_MSC
39 %define pszDst rcx
40 %define pszSrc rdx
41 %define cbMax r8
42 %else
43 %define pszDst rdi
44 %define pszSrc rsi
45 %define cbMax rdx
46 %endif
47 mov r9, pszDst
48%else
49 mov ecx, [esp + 4]
50 mov edx, [esp + 8]
51 push ebx
52 mov ebx, [esp + 12 + 4]
53 %define pszDst ecx
54 %define pszSrc edx
55 %define cbMax ebx
56 push pszDst
57%endif
58
59 ;
60 ; The rolled out loop.
61 ;
62.next:
63 cmp cbMax, 4
64 jb .simple_intro
65
66 mov al, [pszSrc]
67 mov [pszDst], al
68 test al, al
69 jz .done
70
71 mov al, [pszSrc + 1]
72 mov [pszDst + 1], al
73 test al, al
74 jz .done
75
76 mov al, [pszSrc + 2]
77 mov [pszDst + 2], al
78 test al, al
79 jz .done
80
81 mov al, [pszSrc + 3]
82 mov [pszDst + 3], al
83 test al, al
84 jz .done
85
86 add pszDst, 4
87 add pszSrc, 4
88 sub cbMax, 4
89 jmp .next
90
91 ;
92 ; Char by char.
93 ;
94.simple_intro:
95 test cbMax, cbMax
96 jz .done
97
98.simple_next:
99 mov al, [pszSrc]
100 mov [pszDst], al
101 test al, al
102 jz .done
103
104 dec cbMax
105 jz .done
106
107 inc pszSrc
108 inc pszDst
109 jmp .simple_next
110
111.done:
112%ifdef RT_ARCH_AMD64
113 mov rax, r9
114%else
115 pop ebx
116 pop eax
117%endif
118 ret
119ENDPROC RT_NOCRT(strncpy)
120
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