VirtualBox

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

Last change on this file since 75129 was 75129, checked in by vboxsync, 6 years ago

IPRT: Make Watcom C an alterntive for compiling the OS/2 kernel code (GA mainly), governed by VBOX_USE_WATCOM_FOR_OS2.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.0 KB
Line 
1; $Id: strncpy.asm 75129 2018-10-28 17:00:27Z vboxsync $
2;; @file
3; IPRT - No-CRT strncpy - 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 pszDst gcc: rdi msc: rcx x86:[esp+4] wcall: eax
33; @param pszSrc gcc: rsi msc: rdx x86:[esp+8] wcall: edx
34; @param cbMax gcc: rdx msc: r8 x86:[esp+12] wcall: ebx
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 %ifdef ASM_CALL32_WATCOM
50 mov ecx, eax
51 %define pszDst ecx
52 %define pszSrc edx
53 %define cbMax ebx
54 %else
55 mov ecx, [esp + 4]
56 mov edx, [esp + 8]
57 push ebx
58 mov ebx, [esp + 12 + 4]
59 %define pszDst ecx
60 %define pszSrc edx
61 %define cbMax ebx
62 %endif
63 push pszDst
64%endif
65
66 ;
67 ; The rolled out loop.
68 ;
69.next:
70 cmp cbMax, 4
71 jb .simple_intro
72
73 mov al, [pszSrc]
74 mov [pszDst], al
75 test al, al
76 jz .done
77
78 mov al, [pszSrc + 1]
79 mov [pszDst + 1], al
80 test al, al
81 jz .done
82
83 mov al, [pszSrc + 2]
84 mov [pszDst + 2], al
85 test al, al
86 jz .done
87
88 mov al, [pszSrc + 3]
89 mov [pszDst + 3], al
90 test al, al
91 jz .done
92
93 add pszDst, 4
94 add pszSrc, 4
95 sub cbMax, 4
96 jmp .next
97
98 ;
99 ; Char by char.
100 ;
101.simple_intro:
102 test cbMax, cbMax
103 jz .done
104
105.simple_next:
106 mov al, [pszSrc]
107 mov [pszDst], al
108 test al, al
109 jz .done
110
111 dec cbMax
112 jz .done
113
114 inc pszSrc
115 inc pszDst
116 jmp .simple_next
117
118.done:
119%ifdef RT_ARCH_AMD64
120 mov rax, r9
121%else
122 %ifndef ASM_CALL32_WATCOM
123 pop ebx
124 %endif
125 pop eax
126%endif
127 ret
128ENDPROC RT_NOCRT(strncpy)
129
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