VirtualBox

Changeset 40788 in vbox


Ignore:
Timestamp:
Apr 6, 2012 12:52:33 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
77296
Message:

IPRT:strncpy implementation for the no-crt mode.

Location:
trunk/src/VBox/Runtime
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r40668 r40788  
    202202        common/string/strchr.asm \
    203203        common/string/strcpy.asm \
     204        common/string/strncpy.asm \
    204205        common/string/strcmp.asm \
    205206        common/string/strlen.asm
  • trunk/src/VBox/Runtime/common/string/strncpy.asm

    r40783 r40788  
    11; $Id$
    22;; @file
    3 ; IPRT - No-CRT strcpy - AMD64 & X86.
     3; IPRT - No-CRT strncpy - AMD64 & X86.
    44;
    55
    66;
    7 ; Copyright (C) 2006-2007 Oracle Corporation
     7; Copyright (C) 2006-2012 Oracle Corporation
    88;
    99; This file is part of VirtualBox Open Source Edition (OSE), as
     
    3232; @param    pszDst   gcc: rdi  msc: rcx  x86:[esp+4]
    3333; @param    pszSrc   gcc: rsi  msc: rdx  x86:[esp+8]
     34; @param    cbMax    gcc: rdx  msc: r8   x86:[esp+12]
    3435RT_NOCRT_BEGINPROC strcpy
    3536        ; input
     
    3839  %define pszDst rcx
    3940  %define pszSrc rdx
     41  %define cbMax  r8
    4042 %else
    4143  %define pszDst rdi
    4244  %define pszSrc rsi
     45  %define cbMax  rdx
    4346 %endif
    44         mov     r8, pszDst
     47        mov     r9, pszDst
    4548%else
    4649        mov     ecx, [esp + 4]
    4750        mov     edx, [esp + 8]
     51        push    ebx
     52        mov     ebx, [esp + 12 + 4]
    4853  %define pszDst ecx
    4954  %define pszSrc edx
     55  %define cbMax  ebx
    5056        push    pszDst
    5157%endif
    5258
    5359        ;
    54         ; The loop.
     60        ; The rolled out loop.
    5561        ;
    5662.next:
     63        cmp     cbMax, 4
     64        jb      .simple_intro
     65
    5766        mov     al, [pszSrc]
    5867        mov     [pszDst], al
     
    7786        add     pszDst, 4
    7887        add     pszSrc, 4
     88        sub     cbMax,  4
    7989        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
    80110
    81111.done:
    82112%ifdef RT_ARCH_AMD64
    83         mov     rax, r8
     113        mov     rax, r9
    84114%else
     115        pop     ebx
    85116        pop     eax
    86117%endif
Note: See TracChangeset for help on using the changeset viewer.

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