repo_id
stringlengths 5
115
| size
int64 590
5.01M
| file_path
stringlengths 4
212
| content
stringlengths 590
5.01M
|
|---|---|---|---|
32bitmicro/newlib-nano-1.0
| 2,043
|
newlib/libc/machine/spu/scanf.S
|
/*
Copyright (c) 2007, Toshiba Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of Toshiba nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "c99ppe.h"
.text
.align 4
GLOBL scanf
.type scanf, @function
scanf:
stqd $0, 16($sp) /* save caller address */
il $2, 1 /* number of fixed arguments */
brsl $0, __stack_reg_va /* save register to the stack frame */
il $3, SPE_C99_SIGNALCODE
il $4, SPE_C99_VSCANF
ai $5, $sp, 16*2 /* data ($3 save address) */
brsl $0, __send_to_ppe
il $2, 16*(SPE_STACK_REGS+2+2)
a $sp, $sp, $2
lqd $0, 16($sp) /* load caller address */
bi $0 /* return to caller */
.size scanf, .-scanf
|
32bitmicro/newlib-nano-1.0
| 2,061
|
newlib/libc/machine/spu/snprintf.S
|
/*
Copyright (c) 2007, Toshiba Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of Toshiba nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "c99ppe.h"
.text
.align 4
GLOBL snprintf
.type snprintf, @function
snprintf:
stqd $0, 16($sp) /* save caller address */
il $2, 3 /* number of fixed arguments */
brsl $0, __stack_reg_va /* save register to the stack frame */
il $3, SPE_C99_SIGNALCODE
il $4, SPE_C99_VSNPRINTF
ai $5, $sp, 16*2 /* data ($3 save address) */
brsl $0, __send_to_ppe
il $2, 16*(SPE_STACK_REGS+2+2)
a $sp, $sp, $2
lqd $0, 16($sp) /* load caller address */
bi $0 /* return to caller */
.size snprintf, .-snprintf
|
32bitmicro/newlib-nano-1.0
| 2,049
|
newlib/libc/machine/spu/sscanf.S
|
/*
Copyright (c) 2007, Toshiba Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the names of Toshiba nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#include "c99ppe.h"
.text
.align 4
GLOBL sscanf
.type sscanf, @function
sscanf:
stqd $0, 16($sp) /* save caller address */
il $2, 2 /* number of fixed arguments */
brsl $0, __stack_reg_va /* save register to the stack frame */
il $3, SPE_C99_SIGNALCODE
il $4, SPE_C99_VSSCANF
ai $5, $sp, 16*2 /* data ($3 save address) */
brsl $0, __send_to_ppe
il $2, 16*(SPE_STACK_REGS+2+2)
a $sp, $sp, $2
lqd $0, 16($sp) /* load caller address */
bi $0 /* return to caller */
.size sscanf, .-sscanf
|
32bitmicro/newlib-nano-1.0
| 3,694
|
newlib/libc/machine/spu/spu-mcount.S
|
/*
(C) Copyright IBM Corp. 2008
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of IBM nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Author: Ken Werner <ken.werner@de.ibm.com>
*/
/* _mcount extracts the address of the function just entered and the address
of the caller of that function and then calls __mcount_internal. The
prologue calls mcount without saving any registers. The return address is
stored in $75. The _mcount function has to:
- create a new stack frame
- save registers $2 to $75 on the stack
- copy the two addresses ($0 and $75) into the argument registers $3 and $4
- call __mcount_internal
- restore registers
- return to $75 */
/* The following two convenience macros assist in the coding of the
saving and restoring the register.
saveregs first, last Saves registers from first to the last.
restoreregs first, last Restores registers from last down to first.
Note: first must be less than or equal to last. */
.macro saveregs first, last
stqd $\first, \first*16($SP)
.if \last-\first
saveregs "(\first+1)",\last
.endif
.endm
.macro restoreregs first, last
lqd $\last, \last*16($SP)
.if \last-\first
restoreregs \first,"(\last-1)"
.endif
.endm
/* _mcount needs to be resident since the overlay manager uses the scratch
registers too. */
.text
.align 3 /* 8 byte alignment. */
.global _mcount
.type _mcount, @function
_mcount:
stqd $lr, 16($sp) /* Save link register in the callers stack frame. */
stqd $lr, -1216($sp) /* Store back pointer. */
il $lr, -1216 /* Push a new stack frame. */
a $sp, $sp, $lr /* Frame size: 16 * (74 + 2) = 1216. */
/* Save registers $2 to $75 on the stack. */
saveregs 2, 75
/* Bring the __mcount_internal arguments in place. */
lqd $3, 1232($sp) /* frompc (the link register). */
ori $4, $75, 0 /* selfpc (the gcc prologue puts "brsl $75, _mcount" in
front of every function). */
brsl $lr, __mcount_internal
/* Restore register $2 to $75 from the stack. */
restoreregs 2, 75
il $lr, 1216
a $sp, $sp, $lr /* Pop the stack frame. */
lqd $lr, 16($sp) /* Restore link register. */
bi $75 /* Branch to the called function. */
|
32bitmicro/newlib-nano-1.0
| 5,458
|
newlib/libc/machine/sparc/setjmp.S
|
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Modified for incorporation into newlib by Joel Sherrill
* (joel@OARcorp.com), On-Line Applications Research, 1995.
* Did the following:
* + merged in DEFS.h
* + removed error check since it prevented using this setjmp
* to "context switch"
* + added the support for the "user label" and "register" prefix
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: $Header: /cvs/cvsfiles/devo/newlib/libc/machine/sparc/setjmp.S,v 1.1 1997/06/25 07:19:16 marka Exp $
*/
#if defined(LIBC_SCCS) && !defined(lint)
.asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93"
#endif /* LIBC_SCCS and not lint */
/*
* Recent versions of GNU cpp define variables which indicate the
* need for underscores and percents. If not using GNU cpp or
* the version does not support this, then you will obviously
* have to define these as appropriate.
*/
#ifndef __USER_LABEL_PREFIX__
#define __USER_LABEL_PREFIX__ _
#endif
#ifndef __REGISTER_PREFIX__
#define __REGISTER_PREFIX__
#endif
/* ANSI concatenation macros. */
#define CONCAT1(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
/* Use the right prefix for global labels. */
#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
/*********************************************************************
*********************************************************************
* Contents of DEFS.h *
*********************************************************************
*********************************************************************/
#ifdef PROF
#define ENTRY(x) \
.align 4; .globl SYM(x); .proc 1; SYM(x):; .data; .align 4; 1: .long 0; \
.text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
or %lo(1b),%o0,%o0; restore
#else
#define ENTRY(x) \
.align 4; .globl SYM(x); .proc 1; SYM(x):
#endif
/*********************************************************************
*********************************************************************
* END of DEFS.h *
*********************************************************************
*********************************************************************/
/*
* C library -- _setjmp, _longjmp
*
* _longjmp(a,v)
* will generate a "return(v?v:1)" from
* the last call to
* _setjmp(a)
* by unwinding the call stack.
* The previous signal state is NOT restored.
*/
/* #include "DEFS.h" */
ENTRY(setjmp)
ENTRY(_setjmp)
st %sp, [%o0] /* caller's stack pointer */
st %i7, [%o0+4] /* caller's return pc */
st %fp, [%o0+8] /* store caller's frame pointer */
st %o7, [%o0+12]
retl
clr %o0 ! return 0
ENTRY(longjmp)
ENTRY(_longjmp)
ta 0x03 /* flush registers */
addcc %o1, %g0, %g6 ! compute v ? v : 1 in a global register
be,a 0f
mov 1, %g6
0:
ld [%o0], %sp /* caller's stack pointer */
ldd [%sp], %l0
ldd [%sp+8], %l2
ldd [%sp+16], %l4
ldd [%sp+24], %l6
ldd [%sp+32], %i0
ldd [%sp+40], %i2
ldd [%sp+48], %i4
ld [%o0+4], %i7 /* caller's return pc */
ld [%o0+8], %fp /* caller's frame pointer */
ld [%o0+12], %o7
jmp %o7 + 8 ! success, return %g6
mov %g6, %o0
|
32bitmicro/newlib-nano-1.0
| 1,462
|
newlib/libc/machine/tic4x/setjmp.S
|
/* setjmp/longjmp routines.
*
* Written by Michael Hayes <m.hayes@elec.canterbury.ac.nz>.
*
* The author hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
.sect .text
.global setjmp
.global longjmp
setjmp:
pop r1
ldi sp, ar0
#ifndef _REGPARM
ldi *ar0, ar2
#endif
sti r4, *ar2++
sti r5, *ar2++
stf r6, *ar2++
stf r7, *ar2++
#ifdef _TMS320C4x
sti r8, *ar2++
#endif
sti ar3, *ar2++
sti ar4, *ar2++
sti ar5, *ar2++
sti ar6, *ar2++
sti ar7, *ar2++
bd r1
sti r1, *ar2++
sti ar0, *ar2
ldi 0, r0
longjmp:
#ifndef _REGPARM
ldi sp, ar0
ldi *-ar0(1), ar2
ldi *-ar0(2), r0
ldiz 1, r0
#else
ldi r2, r0
ldiz 1, r0
#endif
ldi *ar2++, r4
ldi *ar2++, r5
ldf *ar2++, r6
ldf *ar2++, r7
#ifdef _TMS320C4x
ldi *ar2++, r8
#endif
ldi *ar2++, ar3
ldi *ar2++, ar4
ldi *ar2++, ar5
ldi *ar2++, ar6
ldi *ar2++, ar7
ldi *ar2++, r1
ldi *ar2, sp
b r1
.end
|
32bitmicro/newlib-nano-1.0
| 2,731
|
newlib/libc/machine/necv70/fastmath.S
|
.globl _fast_sin
_fast_sin:
fsin.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_sinf
_fast_sinf:
fsin.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_cos
_fast_cos:
fcos.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_cosf
_fast_cosf:
fcos.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_tan
_fast_tan:
ftan.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_tanf
_fast_tanf:
ftan.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_fabs
_fast_fabs:
fabs.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_fabsf
_fast_fabsf:
fabs.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_sqrt
_fast_sqrt:
fsqrt.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_sqrtf
_fast_sqrtf:
fsqrt.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_acos
_fast_acos:
facos.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_acosf
_fast_acosf:
facos.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_asin
_fast_asin:
fasin.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_asinf
_fast_asinf:
fasin.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_atan
_fast_atan:
fatan.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_atanf
_fast_atanf:
fatan.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_cosh
_fast_cosh:
fcosh.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_coshf
_fast_coshf:
fcosh.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_sinh
_fast_sinh:
fsin.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_sinhf
_fast_sinhf:
fsin.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_tanh
_fast_tanh:
ftanh.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_tanhf
_fast_tanhf:
ftanh.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_atanh
_fast_atanh:
fatanh.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_atanhf
_fast_atanhf:
fatanh.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_exp2
_fast_exp2:
fexp2.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_exp2f
_fast_exp2f:
fexp2.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_exp10
_fast_exp10:
fexp10.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_exp10f
_fast_exp10f:
fexp10.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_expe
_fast_expe:
fexpe.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_expef
_fast_expef:
fexpe.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_log2
_fast_log2:
flog2.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_log2f
_fast_log2f:
flog2.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_log10
_fast_log10:
flog10.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_log10f
_fast_log10f:
flog10.s [ap],[ap]
mov.w [ap],r0
ret #0
.globl _fast_loge
_fast_loge:
floge.l [ap],[ap]
mov.d [ap],r0
ret #0
.globl _fast_logef
_fast_logef:
floge.s [ap],[ap]
mov.w [ap],r0
ret #0
|
32bitmicro/newlib-nano-1.0
| 1,098
|
newlib/libc/machine/m88k/setjmp.S
|
/* This is a simple version of setjmp and longjmp.
Ian Lance Taylor, Cygnus Support, 15 July 1993. */
/* We need to save the address of the return instruction, which is in
r1, as well as general register r14 through r25. If we are
compiling for the 88110 with the extended register file, we also
need to save registers x22 through x29. The jmp_buf should be 52
bytes long in the one case, 84 bytes in the other. */
/* int setjmp (jmp_buf); */
globl _setjmp
_setjmp:
st r1,r2,0
st.d r14,r2,4
st.d r16,r2,12
st.d r18,r2,20
st.d r20,r2,28
st.d r22,r2,36
st.d r24,r2,44
#ifdef __m88110__
/* These instructions are just a guess, and gas doesn't
support them anyhow. */
st.d x22,r2,52
st.d x24,r2,60
st.d x26,r2,68
st.d x28,r2,76
#endif
jmp r1
global _longjmp
_longjmp:
ld r1,r2,0
ld.d r14,r2,4
ld.d r16,r2,12
ld.d r18,r2,20
ld.d r20,r2,28
ld.d r22,r2,36
ld.d r24,r2,44
#ifdef __m88110__
/* These instructions are just a guess, and gas doesn't
support them anyhow. */
ld.d x22,r2,52
ld.d x24,r2,60
ld.d x26,r2,68
ld.d x28,r2,76
#endif
jmp r1
|
32bitmicro/newlib-nano-1.0
| 1,790
|
newlib/libc/machine/mn10300/memcpy.S
|
.file "memcpy.S"
.section .text
.global _memcpy
.type _memcpy,@function
_memcpy:
movm [d2,d3,a2,a3],(sp)
.Lend_of_prologue:
mov d0,d2
mov d1,a0
mov d2,a1
mov (28,sp),d1
#ifndef __OPTIMIZE_SIZE__
mov a0,d0
or d2,d0
btst 3,d0
bne .L37
cmp 15,d1
bls .L34
setlb
mov (a0),d0
mov d0,(a1)
inc4 a0
inc4 a1
mov (a0),d0
mov d0,(a1)
inc4 a0
inc4 a1
mov (a0),d0
mov d0,(a1)
inc4 a0
inc4 a1
mov (a0),d0
mov d0,(a1)
inc4 a0
inc4 a1
add -16,d1
cmp 15,d1
lhi
.L34:
cmp 3,d1
bls .L37
setlb
mov (a0),d0
mov d0,(a1)
inc4 a0
inc4 a1
add -4,d1
cmp 3,d1
lhi
.L37:
#endif
cmp 0,d1
beq .L36
setlb
movbu (a0),d0
movbu d0,(a1)
inc a0
inc a1
sub 1,d1
lne
.L36:
mov d2,a0
.Lepilogue:
ret [d2,d3,a2,a3],16
.Lend_of_memcpy:
.size _memcpy, .Lend_of_memcpy - _memcpy
.section .debug_frame,"",@progbits
.Lstart_of_debug_frame:
# Common Information Entry (CIE)
.4byte .Lend_of_CIE - .Lstart_of_CIE # CIE Length
.Lstart_of_CIE:
.4byte 0xffffffff # CIE Identifier Tag
.byte 0x1 # CIE Version
.ascii "\0" # CIE Augmentation
.uleb128 0x1 # CIE Code Alignment Factor
.sleb128 -4 # CIE Data Alignment Factor
.byte 0x32 # CIE RA Column
.byte 0xc # DW_CFA_def_cfa
.uleb128 0x9
.uleb128 0x0
.byte 0xb2 # DW_CFA_offset, column 0x32
.uleb128 0x0
.align 2
.Lend_of_CIE:
# Frame Description Entry (FDE)
.4byte .Lend_of_FDE - .Lstart_of_FDE # FDE Length
.Lstart_of_FDE:
.4byte .Lstart_of_debug_frame # FDE CIE offset
.4byte _memcpy # FDE initial location
.4byte .Lend_of_memcpy - _memcpy # FDE address range
.byte 0x4 # DW_CFA_advance_loc4
.4byte .Lend_of_prologue - _memcpy
.byte 0xe # DW_CFA_def_cfa_offset
.uleb128 0x4
.byte 0x87 # DW_CFA_offset, column 0x7
.uleb128 0x1
.align 2
.Lend_of_FDE:
|
32bitmicro/newlib-nano-1.0
| 1,328
|
newlib/libc/machine/mn10300/setjmp.S
|
.file "setjmp.S"
.section .text
.align 1
.global _setjmp
#ifdef __AM33__
#ifdef __AM33_2__
.am33_2
#else
.am33
#endif
#endif
_setjmp:
mov d0,a0
mov d2,(0,a0)
mov d3,(4,a0)
mov mdr,d1
mov d1,(8,a0)
mov a2,(12,a0)
mov a3,(16,a0)
mov sp,a1
mov a1,(20,a0)
#ifdef __AM33__
add 24,a0
mov r4,(a0+)
mov r5,(a0+)
mov r6,(a0+)
mov r7,(a0+)
#ifdef __AM33_2__
fmov fs4,(a0+)
fmov fs5,(a0+)
fmov fs6,(a0+)
fmov fs7,(a0+)
fmov fs8,(a0+)
fmov fs9,(a0+)
fmov fs10,(a0+)
fmov fs11,(a0+)
fmov fs12,(a0+)
fmov fs13,(a0+)
fmov fs14,(a0+)
fmov fs15,(a0+)
fmov fs16,(a0+)
fmov fs17,(a0+)
fmov fs18,(a0+)
fmov fs19,(a0+)
#endif
#endif
sub d0,d0
rets
.global _longjmp
_longjmp:
mov d0,a0
mov (8,a0),d2
mov d2,mdr
mov (0,a0),d2
mov (4,a0),d3
mov (12,a0),a2
mov (16,a0),a3
mov (20,a0),a1
mov a1,sp
#ifdef __AM33__
add 24,a0
mov (a0+),r4
mov (a0+),r5
mov (a0+),r6
mov (a0+),r7
#ifdef __AM33_2__
fmov (a0+),fs4
fmov (a0+),fs5
fmov (a0+),fs6
fmov (a0+),fs7
fmov (a0+),fs8
fmov (a0+),fs9
fmov (a0+),fs10
fmov (a0+),fs11
fmov (a0+),fs12
fmov (a0+),fs13
fmov (a0+),fs14
fmov (a0+),fs15
fmov (a0+),fs16
fmov (a0+),fs17
fmov (a0+),fs18
fmov (a0+),fs19
#endif
#endif
cmp 0,d1
bne L1
mov 1,d1
L1:
mov d1,d0
retf [],0
|
32bitmicro/newlib-nano-1.0
| 1,655
|
newlib/libc/machine/mn10300/strcpy.S
|
.file "strcpy.S"
.section .text
.global _strcpy
.type _strcpy,@function
_strcpy:
movm [d2,d3,a2,a3],(sp)
.Lend_of_prologue:
mov d0,d3
mov d1,a0
mov d3,a1
mov a0,d0
#ifndef __OPTIMIZE_SIZE__
or d3,d0
btst 3,d0
bne .L2
mov (a0),d0
mov -16843009,a2
mov a2,d1
add d0,d1
not d0
and d0,d1
mov -2139062144,d2
btst -2139062144,d1
bne .L2
setlb
mov (a0),d0
mov d0,(a1)
inc4 a0
inc4 a1
mov (a0),d0
mov a2,d1
add d0,d1
not d0
and d0,d1
and d2,d1
leq
.L2:
#endif
setlb
movbu (a0),d0
movbu d0,(a1)
inc a0
inc a1
cmp 0,d0
lne
mov d3,a0
.Lepilogue:
ret [d2,d3,a2,a3],16
.Lend_of_strcpy:
.size _strcpy, .Lend_of_strcpy - _strcpy
.section .debug_frame,"",@progbits
.Lstart_of_debug_frame:
# Common Information Entry (CIE)
.4byte .Lend_of_CIE - .Lstart_of_CIE # CIE Length
.Lstart_of_CIE:
.4byte 0xffffffff # CIE Identifier Tag
.byte 0x1 # CIE Version
.ascii "\0" # CIE Augmentation
.uleb128 0x1 # CIE Code Alignment Factor
.sleb128 -4 # CIE Data Alignment Factor
.byte 0x32 # CIE RA Column
.byte 0xc # DW_CFA_def_cfa
.uleb128 0x9
.uleb128 0x0
.byte 0xb2 # DW_CFA_offset, column 0x32
.uleb128 0x0
.align 2
.Lend_of_CIE:
# Frame Description Entry (FDE)
.4byte .Lend_of_FDE - .Lstart_of_FDE # FDE Length
.Lstart_of_FDE:
.4byte .Lstart_of_debug_frame # FDE CIE offset
.4byte _strcpy # FDE initial location
.4byte .Lend_of_strcpy - _strcpy # FDE address range
.byte 0x4 # DW_CFA_advance_loc4
.4byte .Lend_of_prologue - _strcpy
.byte 0xe # DW_CFA_def_cfa_offset
.uleb128 0x4
.byte 0x87 # DW_CFA_offset, column 0x7
.uleb128 0x1
.align 2
.Lend_of_FDE:
|
32bitmicro/newlib-nano-1.0
| 1,826
|
newlib/libc/machine/mn10300/memset.S
|
.file "memset.S"
.section .text
.global _memset
.type _memset,@function
_memset:
movm [d2,d3,a2,a3], (sp)
.Lend_of_prologue:
mov d0, d3
mov d1, d2
mov (28, sp),a1
mov d3, a0
#ifndef __OPTIMIZE_SIZE__
cmp 3, a1
bls .L41
btst 3, d3
bne .L41
extbu d2
mov d2, d1
asl 8, d1
or d2, d1
mov d1, d0
asl 16, d0
or d0, d1
cmp 15, a1
bls .L36
setlb
mov d1, (a0)
inc4 a0
mov d1, (a0)
inc4 a0
mov d1, (a0)
inc4 a0
mov d1, (a0)
inc4 a0
add -16, a1
cmp 15, a1
lhi
.L36:
cmp 3, a1
bls .L41
setlb
mov d1, (a0)
inc4 a0
add -4, a1
cmp 3, a1
lhi
.L41:
#endif
cmp 0, a1
beq .Lepilogue
setlb
movbu d2, (a0)
inc a0
sub 1, a1
lne
.Lepilogue:
mov d3,a0
ret [d2,d3,a2,a3], 16
.Lend_of_memset:
.size _memset, .Lend_of_memset - _memset
.section .debug_frame,"",@progbits
.Lstart_of_debug_frame:
# Common Information Entry (CIE)
.4byte .Lend_of_CIE - .Lstart_of_CIE # CIE Length
.Lstart_of_CIE:
.4byte 0xffffffff # CIE Identifier Tag
.byte 0x1 # CIE Version
.ascii "\0" # CIE Augmentation
.uleb128 0x1 # CIE Code Alignment Factor
.sleb128 -4 # CIE Data Alignment Factor
.byte 0x32 # CIE RA Column
.byte 0xc # DW_CFA_def_cfa
.uleb128 0x9
.uleb128 0x0
.byte 0xb2 # DW_CFA_offset, column 0x32
.uleb128 0x0
.align 2
.Lend_of_CIE:
# Frame Description Entry (FDE)
.4byte .Lend_of_FDE - .Lstart_of_FDE # FDE Length
.Lstart_of_FDE:
.4byte .Lstart_of_debug_frame # FDE CIE offset
.4byte _memset # FDE initial location
.4byte .Lend_of_memset - _memset # FDE address range
.byte 0x4 # DW_CFA_advance_loc4
.4byte .Lend_of_prologue - _memset
.byte 0xe # DW_CFA_def_cfa_offset
.uleb128 0x4
.byte 0x87 # DW_CFA_offset, column 0x7
.uleb128 0x1
.align 2
.Lend_of_FDE:
|
32bitmicro/newlib-nano-1.0
| 1,863
|
newlib/libc/machine/mn10300/memchr.S
|
.file "memchr.S"
.section .text
.global _memchr
.type _memchr,@function
_memchr:
movm [d2,d3,a2,a3],(sp)
.Lend_of_prologue:
mov d0,a0
mov d1,d2
mov (28,sp),a1
#ifndef __OPTIMIZE_SIZE__
cmp 3,a1
bls .L44
mov a0,d3
btst 3,d3
bne .L44
mov a0,a2
mov 0,a3
clr d1
setlb
mov a3,d0
asl 8,d0
mov d2,a3
add d0,a3
inc d1
cmp 3,d1
lls
cmp 3,a1
bls .L48
.L33:
mov (a2),d0
mov a3,d3
xor d3,d0
mov d0,d1
not d1
add -16843009,d0
and d1,d0
btst -2139062144,d0
beq .L34
mov a2,a0
clr d1
setlb
movbu (a0),d0
cmp d2,d0
beq .Lepilogue
inc a0
inc d1
cmp 3,d1
lls
.L34:
add -4,a1
inc4 a2
cmp 3,a1
bhi .L33
.L48:
mov a2,a0
.L44:
#endif
cmp 0,a1
beq .L50
setlb
movbu (a0),d0
cmp d2,d0
beq .Lepilogue
inc a0
sub 1,a1
lne
.L50:
mov 0,a0
.Lepilogue:
ret [d2,d3,a2,a3],16
.Lend_of_memchr:
.size _memchr, .Lend_of_memchr - _memchr
.section .debug_frame,"",@progbits
.Lstart_of_debug_frame:
# Common Information Entry (CIE)
.4byte .Lend_of_CIE - .Lstart_of_CIE # CIE Length
.Lstart_of_CIE:
.4byte 0xffffffff # CIE Identifier Tag
.byte 0x1 # CIE Version
.ascii "\0" # CIE Augmentation
.uleb128 0x1 # CIE Code Alignment Factor
.sleb128 -4 # CIE Data Alignment Factor
.byte 0x32 # CIE RA Column
.byte 0xc # DW_CFA_def_cfa
.uleb128 0x9
.uleb128 0x0
.byte 0xb2 # DW_CFA_offset, column 0x32
.uleb128 0x0
.align 2
.Lend_of_CIE:
# Frame Description Entry (FDE)
.4byte .Lend_of_FDE - .Lstart_of_FDE # FDE Length
.Lstart_of_FDE:
.4byte .Lstart_of_debug_frame # FDE CIE offset
.4byte _memchr # FDE initial location
.4byte .Lend_of_memchr - _memchr # FDE address range
.byte 0x4 # DW_CFA_advance_loc4
.4byte .Lend_of_prologue - _memchr
.byte 0xe # DW_CFA_def_cfa_offset
.uleb128 0x4
.byte 0x87 # DW_CFA_offset, column 0x7
.uleb128 0x1
.align 2
.Lend_of_FDE:
|
32bitmicro/newlib-nano-1.0
| 1,618
|
newlib/libc/machine/mn10300/memcmp.S
|
.file "memcmp.S"
.section .text
.global _memcmp
.type _memcmp,@function
_memcmp:
movm [d2,d3,a2,a3],(sp)
.Lend_of_prologue:
mov d0,a0
mov d1,a1
mov (28,sp),a2
#ifndef __OPTIMIZE_SIZE__
cmp 3,a2
bls .L22
mov a1,d2
or d2,d0
btst 3,d0
bne .L22
setlb
mov (a0),d1
mov (a1),d0
cmp d0,d1
bne .L22
inc4 a0
inc4 a1
add -4,a2
cmp 3,a2
lhi
.L22:
#endif
cmp 0,a2
beq .L24
setlb
movbu (a0),d3
movbu (a1),d2
cmp d2,d3
beq .L23
mov d3,d0
sub d2,d0
jmp .Lepilogue
.L23:
inc a0
inc a1
sub 1,a2
lne
.L24:
clr d0
.Lepilogue:
ret [d2,d3,a2,a3],16
.Lend_of_func:
.size _memcmp, .Lend_of_func - _memcmp
.section .debug_frame,"",@progbits
.Lstart_of_debug_frame:
# Common Information Entry (CIE)
.4byte .Lend_of_CIE - .Lstart_of_CIE # CIE Length
.Lstart_of_CIE:
.4byte 0xffffffff # CIE Identifier Tag
.byte 0x1 # CIE Version
.ascii "\0" # CIE Augmentation
.uleb128 0x1 # CIE Code Alignment Factor
.sleb128 -4 # CIE Data Alignment Factor
.byte 0x32 # CIE RA Column
.byte 0xc # DW_CFA_def_cfa
.uleb128 0x9
.uleb128 0x0
.byte 0xb2 # DW_CFA_offset, column 0x32
.uleb128 0x0
.align 2
.Lend_of_CIE:
# Frame Description Entry (FDE)
.4byte .Lend_of_FDE - .Lstart_of_FDE # FDE Length
.Lstart_of_FDE:
.4byte .Lstart_of_debug_frame # FDE CIE offset
.4byte _memcmp # FDE initial location
.4byte .Lend_of_func - _memcmp # FDE address range
.byte 0x4 # DW_CFA_advance_loc4
.4byte .Lend_of_prologue - _memcmp
.byte 0xe # DW_CFA_def_cfa_offset
.uleb128 0x4
.byte 0x87 # DW_CFA_offset, column 0x7
.uleb128 0x1
.align 2
.Lend_of_FDE:
|
32bitmicro/newlib-nano-1.0
| 1,592
|
newlib/libc/machine/mn10300/strlen.S
|
.file "strlen.S"
.section .text
.global _strlen
.type _strlen,@function
_strlen:
movm [d2,d3,a2,a3],(sp)
.Lend_of_prologue:
mov d0,a0
mov a0,a2
#ifndef __OPTIMIZE_SIZE__
btst 3,d0
bne .L21
mov (a0),d0
mov -16843009,a1
mov a1,d1
add d0,d1
not d0
and d0,d1
mov -2139062144,d2
btst -2139062144,d1
bne .L21
setlb
inc4 a0
mov (a0),d0
mov a1,d1
add d0,d1
not d0
and d0,d1
and d2,d1
leq
jmp .L21
#endif
.L19:
inc a0
.L21:
movbu (a0),d3
cmp 0,d3
bne .L19
sub a2,a0
mov a0,d0
.Lepilogue:
ret [d2,d3,a2,a3],16
.Lend_of_strlen:
.size _strlen, .Lend_of_strlen - _strlen
.section .debug_frame,"",@progbits
.Lstart_of_debug_frame:
# Common Information Entry (CIE)
.4byte .Lend_of_CIE - .Lstart_of_CIE # CIE Length
.Lstart_of_CIE:
.4byte 0xffffffff # CIE Identifier Tag
.byte 0x1 # CIE Version
.ascii "\0" # CIE Augmentation
.uleb128 0x1 # CIE Code Alignment Factor
.sleb128 -4 # CIE Data Alignment Factor
.byte 0x32 # CIE RA Column
.byte 0xc # DW_CFA_def_cfa
.uleb128 0x9
.uleb128 0x0
.byte 0xb2 # DW_CFA_offset, column 0x32
.uleb128 0x0
.align 2
.Lend_of_CIE:
# Frame Description Entry (FDE)
.4byte .Lend_of_FDE - .Lstart_of_FDE # FDE Length
.Lstart_of_FDE:
.4byte .Lstart_of_debug_frame # FDE CIE offset
.4byte _strlen # FDE initial location
.4byte .Lend_of_strlen - _strlen # FDE address range
.byte 0x4 # DW_CFA_advance_loc4
.4byte .Lend_of_prologue - _strlen
.byte 0xe # DW_CFA_def_cfa_offset
.uleb128 0x4
.byte 0x87 # DW_CFA_offset, column 0x7
.uleb128 0x1
.align 2
.Lend_of_FDE:
|
32bitmicro/newlib-nano-1.0
| 2,065
|
newlib/libc/machine/mn10300/strchr.S
|
.file "strchr.S"
.section .text
.global _strchr
.type _strchr,@function
_strchr:
movm [d2,d3,a2,a3],(sp)
add -12,sp
.Lend_of_prologue:
mov d0,a1
movbu d1,(7,sp)
#ifndef __OPTIMIZE_SIZE__
btst 3,d0
bne .L20
clr d0
setlb
mov sp,a2
mov d0,d3
add d3,a2
mov a2,a0
add 12,a0
movbu (7,sp),d3
movbu d3,(-4,a0)
inc d0
cmp 3,d0
lls
mov a1,a0
mov -16843009,a1
mov (a0),d2
mov a1,d1
add d2,d1
mov d2,d0
not d0
and d0,d1
mov -2139062144,d3
mov d3,(0,sp)
btst -2139062144,d1
bne .L27
jmp .L38
.L28:
inc4 a0
mov (a0),d2
mov a1,d1
add d2,d1
mov d2,d0
not d0
and d0,d1
mov (0,sp),d3
and d3,d1
bne .L27
.L38:
mov (8,sp),d0
xor d2,d0
mov a1,d1
add d0,d1
not d0
and d0,d1
and d3,d1
beq .L28
.L27:
mov a0,a1
.L20:
#endif
movbu (a1),d0
cmp 0,d0
beq .L32
movbu (7,sp),d1
setlb
cmp d1,d0
beq .L36
inc a1
movbu (a1),d0
cmp 0,d0
lne
.L32:
movbu (7,sp),d0
movbu (a1),d3
cmp d0,d3
beq .L36
mov 0,a0
jmp .Lepilogue
.L36:
mov a1,a0
.Lepilogue:
ret [d2,d3,a2,a3],28
.Lend_of_strchr:
.size _strchr, .Lend_of_strchr - _strchr
.section .debug_frame,"",@progbits
.Lstart_of_debug_frame:
# Common Information Entry (CIE)
.4byte .Lend_of_CIE - .Lstart_of_CIE # CIE Length
.Lstart_of_CIE:
.4byte 0xffffffff # CIE Identifier Tag
.byte 0x1 # CIE Version
.ascii "\0" # CIE Augmentation
.uleb128 0x1 # CIE Code Alignment Factor
.sleb128 -4 # CIE Data Alignment Factor
.byte 0x32 # CIE RA Column
.byte 0xc # DW_CFA_def_cfa
.uleb128 0x9
.uleb128 0x0
.byte 0xb2 # DW_CFA_offset, column 0x32
.uleb128 0x0
.align 2
.Lend_of_CIE:
# Frame Description Entry (FDE)
.4byte .Lend_of_FDE - .Lstart_of_FDE # FDE Length
.Lstart_of_FDE:
.4byte .Lstart_of_debug_frame # FDE CIE offset
.4byte _strchr # FDE initial location
.4byte .Lend_of_strchr - _strchr # FDE address range
.byte 0x4 # DW_CFA_advance_loc4
.4byte .Lend_of_prologue - _strchr
.byte 0xe # DW_CFA_def_cfa_offset
.uleb128 0x4
.byte 0x87 # DW_CFA_offset, column 0x7
.uleb128 0x1
.align 2
.Lend_of_FDE:
|
32bitmicro/newlib-nano-1.0
| 1,669
|
newlib/libc/machine/mn10300/strcmp.S
|
.file "strcmp.S"
.section .text
.global _strcmp
.type _strcmp,@function
_strcmp:
movm [d2,d3,a2,a3],(sp)
.Lend_of_prologue:
mov d0,a0
mov d1,a1
#ifndef __OPTIMIZE_SIZE__
or d1,d0
btst 3,d0
bne .L11
mov (a0),d1
mov (a1),d0
cmp d0,d1
bne .L11
mov -16843009,d3
setlb
mov (a0),d0
mov d3,d1
add d0,d1
not d0
and d0,d1
and -2139062144,d1
beq .L6
clr d0
jmp .Lepilogue
.L6:
inc4 a0
inc4 a1
mov (a0),d1
mov (a1),d0
cmp d0,d1
leq
.L11:
#endif
setlb
movbu (a1),d2
movbu (a0),d0
cmp 0,d0
beq .L9
cmp d2,d0
bne .L9
inc a0
inc a1
lra
.L9:
sub d2,d0
.Lepilogue:
ret [d2,d3,a2,a3],16
.Lend_of_strcmp:
.size _strcmp, .Lend_of_strcmp - _strcmp
.section .debug_frame,"",@progbits
.Lstart_of_debug_frame:
# Common Information Entry (CIE)
.4byte .Lend_of_CIE - .Lstart_of_CIE # CIE Length
.Lstart_of_CIE:
.4byte 0xffffffff # CIE Identifier Tag
.byte 0x1 # CIE Version
.ascii "\0" # CIE Augmentation
.uleb128 0x1 # CIE Code Alignment Factor
.sleb128 -4 # CIE Data Alignment Factor
.byte 0x32 # CIE RA Column
.byte 0xc # DW_CFA_def_cfa
.uleb128 0x9
.uleb128 0x0
.byte 0xb2 # DW_CFA_offset, column 0x32
.uleb128 0x0
.align 2
.Lend_of_CIE:
# Frame Description Entry (FDE)
.4byte .Lend_of_FDE - .Lstart_of_FDE # FDE Length
.Lstart_of_FDE:
.4byte .Lstart_of_debug_frame # FDE CIE offset
.4byte _strcmp # FDE initial location
.4byte .Lend_of_strcmp - _strcmp # FDE address range
.byte 0x4 # DW_CFA_advance_loc4
.4byte .Lend_of_prologue - _strcmp
.byte 0xe # DW_CFA_def_cfa_offset
.uleb128 0x4
.byte 0x87 # DW_CFA_offset, column 0x7
.uleb128 0x1
.align 2
.Lend_of_FDE:
|
32bitmicro/newlib-nano-1.0
| 3,291
|
newlib/libc/machine/h8300/memcpy.S
|
#include "setarch.h"
#include "defines.h"
#ifdef __H8300SX__
.global _memcpy
_memcpy:
stm.l er4-er6,@-er7
; Set up source and destination pointers for movmd.
mov.l er0,er6
mov.l er1,er5
; See whether the copy is long enough to use the movmd.l code.
; Although the code can handle anything longer than 6 bytes,
; it can be more expensive than movmd.b for small moves.
; It's better to use a higher threshold to account for this.
;
; Note that the exact overhead of the movmd.l checks depends on
; the alignments of the length and pointers. They are faster when
; er0 & 3 == er1 & 3 == er2 & 3, faster still when these values
; are 0. This threshold is a compromise between the various cases.
cmp #16,LEN(r2)
blo simple
; movmd.l only works for even addresses. If one of the addresses
; is odd and the other is not, fall back on a simple move.
bld #0,r5l
bxor #0,r6l
bcs simple
; Make the addresses even.
bld #0,r5l
bcc word_aligned
mov.b @er5+,@er6+
sub #1,LEN(r2)
word_aligned:
; See if copying one word would make the first operand longword
; aligned. Although this is only really worthwhile if it aligns
; the second operand as well, it's no worse if doesn't, so it
; hardly seems worth the overhead of a "band" check.
bld #1,r6l
bcc fast_copy
mov.w @er5+,@er6+
sub #2,LEN(r2)
fast_copy:
; Set (e)r4 to the number of longwords to copy.
mov LEN(r2),LEN(r4)
shlr #2,LEN(r4)
#ifdef __NORMAL_MODE__
; 16-bit pointers and size_ts: one movmd.l is enough. This code
; is never reached with r4 == 0.
movmd.l
and.w #3,r2
simple:
mov.w r2,r4
beq quit
movmd.b
quit:
rts/l er4-er6
#else
; Skip the first iteration if the number of longwords is divisible
; by 0x10000.
mov.w r4,r4
beq fast_loop_next
; This loop copies r4 (!= 0) longwords the first time round and 65536
; longwords on each iteration after that.
fast_loop:
movmd.l
fast_loop_next:
sub.w #1,e4
bhs fast_loop
; Mop up any left-over bytes. We could just fall through to the
; simple code after the "and" but the version below is quicker
; and only takes 10 more bytes.
and.w #3,r2
beq quit
mov.w r2,r4
movmd.b
quit:
rts/l er4-er6
simple:
; Simple bytewise copy. We need to handle all lengths, including zero.
mov.w r2,r4
beq simple_loop_next
simple_loop:
movmd.b
simple_loop_next:
sub.w #1,e2
bhs simple_loop
rts/l er4-er6
#endif
#else
.global _memcpy
_memcpy:
; MOVP @(2/4,r7),A0P ; dst
; MOVP @(4/8,r7),A1P ; src
; MOVP @(6/12,r7),A2P ; len
MOVP A0P,A3P ; keep copy of final dst
ADDP A2P,A0P ; point to end of dst
CMPP A0P,A3P ; see if anything to do
beq quit
ADDP A2P,A1P ; point to end of src
; lets see if we can do this in words
or A0L,A2L ; or in the dst address
or A3L,A2L ; or the length
or A1L,A2L ; or the src address
btst #0,A2L ; see if the lsb is zero
bne byteloop
wordloop:
#ifdef __NORMAL_MODE__
sub #2,A1P
#else
subs #2,A1P ; point to word
#endif
mov.w @A1P,A2 ; get word
mov.w A2,@-A0P ; save word
CMPP A0P,A3P ; at the front again ?
bne wordloop
rts
byteloop:
#ifdef __NORMAL_MODE__
sub #1,A1P
#else
subs #1,A1P ; point to byte
#endif
mov.b @A1P,A2L ; get byte
mov.b A2L,@-A0P ; save byte
CMPP A0P,A3P ; at the front again ?
bne byteloop
; return with A0 pointing to dst
quit: rts
#endif
|
32bitmicro/newlib-nano-1.0
| 1,037
|
newlib/libc/machine/h8300/setjmp.S
|
#include "setarch.h"
.file "setjmp.S"
.section .text
.align 2
.global _setjmp
_setjmp:
#if defined(__H8300SX__)
mov.l er7,@er0+
mov.l er6,@er0+
mov.l er5,@er0+
mov.l er4,@er0+
mov.l @sp,@er0
sub.l er0,er0
#elif defined(__H8300H__) || defined(__H8300S__)
mov.l er7,@er0
mov.l er6,@(4,er0)
mov.l er5,@(8,er0)
mov.l er4,@(12,er0)
mov.l @sp,er1
mov.l er1,@(16,er0)
sub.l er0,er0
#else
mov.w r7,@r0
mov.w r6,@(2,r0)
mov.w r5,@(4,r0)
mov.w r4,@(6,r0)
mov.w @sp,r1
mov.w r1,@(8,r0)
sub.w r0,r0
#endif
rts
.global _longjmp
_longjmp:
#if defined(__H8300H__) || defined (__H8300S__) || defined (__H8300SX__)
mov.l @er0+,er7
mov.l @er0+,er6
mov.l @er0+,er5
mov.l @er0+,er4
#if defined(__H8300SX__)
mov.l @er0,@sp
#else
mov.l @er0,er2
mov.l er2,@sp
#endif
#if (__INT_MAX__ <= 32767)
mov.w r1,r0
#else
mov.l er1,er0
#endif
bne .L1
sub er0,er0
adds #1,er0
#else
mov.w @r0+,r7
mov.w @r0+,r6
mov.w @r0+,r5
mov.w @r0+,r4
mov.w @r0,r2
mov.w r2,@sp
mov.w r1,r0
bne .L1
mov.w #1,r0
#endif
.L1:
rts
|
32bitmicro/newlib-nano-1.0
| 1,640
|
newlib/libc/machine/h8300/memset.S
|
#include "setarch.h"
#include "defines.h"
#if defined (__H8300SX__)
.global _memset
_memset:
; Use er3 is a temporary since er0 must remain unchanged on exit.
mov.l er0,er3
; Fill er1 with the byte to copy.
mov.b r1l,r1h
mov.w r1,e1
; Account for any excess bytes and words that will be copied after
; the main loop. r2 >= 0 if there is a longword to copy.
sub #4,LEN(r2)
blo longs_done
; Copy one byte if doing so will make er3 word-aligned.
; This isn't needed for correctness but it makes the main loop
; slightly faster.
bld #0,r3l
bcc word_aligned
mov.b r1l,@er3+
sub #1,LEN(r2)
blo longs_done
word_aligned:
; Likewise one word for longword alignment.
bld #1,r3l
bcc long_copy
mov.w r1,@er3+
sub #2,LEN(r2)
blo longs_done
long_copy:
; Copy longwords.
mov.l er1,@er3+
sub #4,LEN(r2)
bhs long_copy
longs_done:
; At this point, we need to copy r2 & 3 bytes. Copy a word
; if necessary.
bld #1,r2l
bcc words_done
mov.w r1,@er3+
words_done:
; Copy a byte.
bld #0,r2l
bcc bytes_done
mov.b r1l,@er3+
bytes_done:
rts
#else
; A0P pointer to cursor
; A1P thing to copy
.global _memset
_memset:
; MOVP @(2/4,r7),A2P ; dst
; MOVP @(4/8,r7),A1 ; src thing
; MOVP @(6/12,r7),A3P ; len
MOVP A2P,A2P
beq quit
; A3 points to the end of the area
MOVP A0P,A3P
ADDP A2P,A3P
; see if we can do it in words
; by oring in the start of the buffer to the end address
or A0L,A2L
btst #0,A2L
bne byteloop
; we can do it a word at a time
mov.b A1L,A1H
wordloop:
mov.w A1,@-A3P
CMPP A3P,A0P
bne wordloop
quit: rts
byteloop:
mov.b A1L,@-A3P
CMPP A3P,A0P
bne byteloop
rts
#endif
|
32bitmicro/newlib-nano-1.0
| 8,107
|
newlib/libc/machine/i960/memccpy_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "mccpy_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1989,1993 Intel Corp., all rights reserved
*/
/*
procedure memccpy (optimized assembler version for the 80960CA)
dest_addr = memccpy (dest_addr, src_addr, char, len)
copy len bytes pointed to by src_addr to the space pointed to by
dest_addr, stopping if char is copied. If char is copied,
return address of byte after char in dest string; else null.
Undefined behavior will occur if the end of the source array is in
the last two words of the program's allocated memory space. This
is so because the routine fetches ahead. Disallowing the fetch
ahead would impose a severe performance penalty.
Undefined behavior will also occur if the source and destination
strings overlap.
This program handles five cases:
1) both arguments start on a word boundary
2) neither are word aligned, but they are offset by the same amount
3) source is word aligned, destination is not
4) destination is word aligned, source is not
5) neither is word aligned, and they are offset by differing amounts
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine.
*/
#if __i960_BIG_ENDIAN__
#define MSW g6
#define LSW g7
#else
#define LSW g6
#define MSW g7
#endif
.globl _memccpy
.leafproc _memccpy, __memccpy
.align 2
_memccpy:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__memccpy:
notand g1,3,g5 # extract word addr of start of src
lda (g14),g13 # preserve return address
cmpibge.f 0,g3,Lexit_char_not_found # Lexit if # of bytes to move is <= 0
cmpo g5,g1 # check alignment of src
ld (g5),LSW # fetch word containing at least first byte
notand g0,3,g4 # extract word addr of start of dest
lda 4(g5),g5 # advance src word addr
shlo 24,g2,g2 # reduce char to single byte
bne.f Lcase_245 # branch if src is NOT word aligned
Lcase_13:
cmpobe.t g0,g4,Lcase_1_setup # branch if dest word aligned
Lcase_3: # src is word aligned; dest is not
mov LSW,MSW # make copy of first word of src
addo 4,g4,g1 # move dest word ptr to first word boundary
lda 32,g14 # initialize shift count to zero
Lcase_25:
Lcase_3_cloop_at_start: # character copying loop for start of dest str
cmpdeci 0,g3,g3 # is max_bytes exhausted?
#if __i960_BIG_ENDIAN__
lda -8(g14),g14 # augment the shift counter
#else
lda 8(g14),g14 # augment the shift counter
#endif
be.f Lexit_char_not_found # Lexit if max_bytes is exhausted
#if __i960_BIG_ENDIAN__
rotate 8,MSW,MSW # move next byte into position for extraction
#endif
shlo 24,MSW,g4
stob MSW,(g0) # store the byte in dest
cmpo g4,g2
lda 1(g0),g0 # post-increment dest ptr
#if ! __i960_BIG_ENDIAN__
shro 8,MSW,MSW # move next byte into position for extraction
#endif
be.f Lexit_char_found # Lexit if char found
cmpobne.t g1,g0,Lcase_3_cloop_at_start # branch if reached word boundary
ld (g5),MSW # fetch msw of operand for double shift
Lcase_4:
shro 8,g2,g4
or g4,g2,g1
shro 16,g1,g4
or g4,g1,g4
#if __i960_BIG_ENDIAN__
cmpobne 0,g14,Lcase_3_wloop
Lcase_3_wloop2:
cmpi g3,4 # less than four bytes to move?
lda 4(g5),g5 # post-increment src word addr
mov LSW,g1 # extract 4 bytes of src
bl.f Lcase_13_cloop_setup # branch if < four bytes left to move
scanbyte g4,g1 # branch if word has char in it
bo.f Lcase_13_cloop_setup
mov MSW,LSW # move msw to lsw
ld (g5),MSW # pre-fetch msw of operand for double shift
subi 4,g3,g3 # decrease max_byte count by the 4 bytes moved
st g1,(g0) # store 4 bytes to dest
addo 4,g0,g0 # post-increment dest ptr
b Lcase_3_wloop2
#endif
Lcase_3_wloop:
cmpi g3,4 # less than four bytes to move?
lda 4(g5),g5 # post-increment src word addr
eshro g14,g6,g1 # extract 4 bytes of src
bl.f Lcase_13_cloop_setup # branch if < four bytes left to move
scanbyte g4,g1 # branch if word has char in it
bo.f Lcase_13_cloop_setup
mov MSW,LSW # move msw to lsw
ld (g5),MSW # pre-fetch msw of operand for double shift
subi 4,g3,g3 # decrease max_byte count by the 4 bytes moved
st g1,(g0) # store 4 bytes to dest
addo 4,g0,g0 # post-increment dest ptr
b Lcase_3_wloop
Lcase_1_setup:
subo 4,g0,g0 # store is pre-incrementing; back up dest addr
shro 8,g2,g4
or g4,g2,MSW
shro 16,MSW,g4
or g4,MSW,g4
b Lcase_1
Lcase_1_wloop: # word copying loop
subi 4,g3,g3 # decrease max_byte count by the 4 bytes moved
ld (g5),LSW # pre-fetch next word of src
addo 4,g5,g5 # post-increment src addr
st g1,(g0) # store word in dest string
Lcase_1: # src and dest are word aligned
cmpi g3,4 # check for fewer than four bytes to move
addo 4,g0,g0 # pre-increment dest addr
lda (LSW),g1 # keep a copy of the src word
bl.f Lcase_13_cloop_setup # branch if less than four bytes to copy
scanbyte LSW,g4 # branch if char is not in foursome
bno.t Lcase_1_wloop
Lcase_13_cloop_setup:
cmpibe.f 0,g3,Lexit_char_not_found # Lexit if max_bytes is exhausted
Lcase_1_cloop:
#if __i960_BIG_ENDIAN__
rotate 8,g1,g1 # move next byte into position for extraction
#endif
shlo 24,g1,g4
stob g1,(g0) # store the byte in dest
cmpo g4,g2
lda 1(g0),g0 # post-increment dest byte addr
subi 1,g3,g3
be.f Lexit_char_found # Lexit if char reached
cmpi 0,g3
#if ! __i960_BIG_ENDIAN__
shro 8,g1,g1 # move next byte into position for extraction
#endif
bne.t Lcase_1_cloop # continue if len not exhausted
Lexit_char_not_found:
mov 0,g0
Lexit_char_found:
lda 0,g14
bx (g13) # g0 = dest array address; g14 = 0
Lrett:
ret
Lcase_245:
cmpo g0,g4 # check alignment of dest
ld (g5),MSW # pre-fetch second half
and 3,g1,g1 # compute shift count
shlo 3,g1,g14
#if __i960_BIG_ENDIAN__
subo g14,0,g14 # adjust shift count for big endian
#endif
be.t Lcase_4 # branch if dest is word aligned
or g4,g1,g1 # is src earlier in word, later, or sync w/ dst
cmpo g0,g1 # < indicates first word of dest has more bytes
/* than first word of source. */
eshro g14,g6,g4 # extract four bytes
lda 4(g0),g1 # move dest word addr to first word boundary
#if __i960_BIG_ENDIAN__
bge.f 1f
#else
bg.f 1f
#endif
mov MSW,LSW
lda 4(g5),g5 # move src word addr to second word boundary
1:
notand g1,3,g1
mov g4,MSW
b Lcase_25
/* end of memccpy */
|
32bitmicro/newlib-nano-1.0
| 5,853
|
newlib/libc/machine/i960/memcpy.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "memcpy.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure memmove (optimized assembler version for the 80960K series)
procedure memcpy (optimized assembler version for the 80960K series)
dest_addr = memmove (dest_addr, src_addr, len)
dest_addr = memcpy (dest_addr, src_addr, len)
copy len bytes pointed to by src_addr to the space pointed to by
dest_addr. Return the original dest_addr.
These routines will work even if the arrays overlap. The standard
requires this of memmove, but memcpy is allowed to fail if overlap
is present. Nevertheless, it is implemented the same as memmove
because the overhead is trifling.
Undefined behavior will occur if the end of the source array is in
the last two words of the program's allocated memory space. This
is so because the routine fetches ahead. Disallowing the fetch
ahead would impose a severe performance penalty.
Strategy:
Fetch the source array by words and store them by words to the
destination array, until there are fewer than three bytes left
to copy. Then, using the last word of the source (the one that
contains the remaining 0, 1, 2, or 3 bytes to be copied), store
a byte at a time until Ldone.
Tactics:
1) Do NOT try to fetch and store the words in a word aligned manner
because, in my judgement, the performance degradation experienced due
to non-aligned accesses does NOT outweigh the time and complexity added
by the preamble and convoluted body that would be necessary to assure
alignment. This is supported by the intuition that most source and
destination arrays (even more true of most big source arrays) will
be word aligned to begin with.
2) For non-overlapping arrays, rather than decrementing len to zero,
I calculate the address of the byte after the last byte of the
destination array, and quit when the destination byte pointer passes
that.
3) For overlapping arrays where the source starts at a lower address
than the destination the move is performed in reverse order.
4) Overlapping arrays where the source starts at a higher address
are treated like non-overlapping case. Where the two arrays exactly
coincide, the routine is short-circuited; no move is Ldone at all.
This costs only one cycle.
*/
.globl _memcpy, _memmove
.globl __memcpy, __memmove
.leafproc _memmove, __memmove
.leafproc _memcpy, __memcpy
.align 2
_memmove:
_memcpy:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__memmove:
__memcpy:
mov g14, g13 # preserve return address
cmpibge 0,g2,Lexit # exit if number of bytes to move is <= zero.
cmpo g0,g1 # does start of dest overlap end of src?
addo g2,g1,g3
be Lexit # no move necessary if src and dest are same
concmpo g3,g0
addo g2, g0, g6
bg Lbackwards # if overlap, then do move backwards
ld (g1), g7 # fetch first word of source
mov g0, g5
b Lwloop_b
Lwloop_a:
ld (g1), g7 # fetch ahead next word of source
st g4, (g5) # store word to dest
addo 4, g5, g5 # post-increment dest pointer
Lwloop_b: # word copying loop
addo 4, g1, g1 # pre-increment src pointer
cmpo g3, g1 # is len <= 3 ?
mov g7, g4 # keep a copy of the current word
bge Lwloop_a # loop if more than 3 bytes to move
cmpobe g6, g5, Lexit # quit if no more bytes to move
Lcloop_a: # character copying loop (len < 3)
stob g4, (g5) # store a byte
shro 8, g4, g4 # position next byte for storing
addo 1, g5, g5
cmpobne g6, g5, Lcloop_a # quit if no more bytes to move
Lexit:
mov 0, g14
bx (g13) # g0 = dest array address; g14 = 0
Lrett:
ret
Lwloop.a:
subo 4, g6, g6 # pre-decrement dest pointer
st g7, (g6) # store word to dest
Lbackwards: # word copying loop
subo 4, g3, g3 # pre-decrement src pointer
cmpo g1, g3 # is len <= 3?
ld (g3), g7 # fetch ahead next word of source
ble Lwloop.a # loop if more than 3 bytes to move
cmpobe g6, g0, Lexit # quit if no more bytes to move
Lcloop.a:
subo 1, g6, g6
rotate 8, g7, g7 # position byte for storing
stob g7, (g6) # store byte
cmpobne g6, g0, Lcloop.a # quit if no more bytes to move
b Lexit
/* end of memmove */
|
32bitmicro/newlib-nano-1.0
| 12,226
|
newlib/libc/machine/i960/memcpy_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "memcp_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1992,1993 Intel Corp., all rights reserved
*/
/*
procedure memmove (optimized assembler version for the CA)
procedure memcpy (optimized assembler version for the CA)
dest_addr = memmove (dest_addr, src_addr, len)
dest_addr = memcpy (dest_addr, src_addr, len)
copy len bytes pointed to by src_addr to the space pointed to by
dest_addr. Return the original dest_addr.
Memcpy will fail if the source and destination string overlap
(in particular, if the end of the source is overlapped by the
beginning of the destination). The behavior is undefined.
This is acceptable according to the draft C standard.
Memmove will not fail if overlap exists.
Undefined behavior will also occur if the end of the source string
(i.e. the terminating null byte) is in the last word of the program's
allocated memory space. This is so because, in several cases, the
routine will fetch ahead one word. Disallowing the fetch ahead would
impose a severe performance penalty.
This program handles five cases:
1) both arguments start on a word boundary
2) neither are word aligned, but they are offset by the same amount
3) source is word aligned, destination is not
4) destination is word aligned, source is not
5) neither is word aligned, and they are offset by differing amounts
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine. The registers are used as follows:
g0 dest ptr; not modified, so that it may be returned
g1 src ptr; shift count
g2 len
g3 src ptr (word aligned)
g4 dest ptr (word aligned)
g5 -4 for Lbackwards move
Little endian
g6 lsw of double word for extraction of 4 bytes
g7 msw of double word for extraction of 4 bytes
Big endian
g6 msw of double word for extraction of 4 bytes
g7 lsw of double word for extraction of 4 bytes
g13 return address
g14 byte extracted.
*/
#if __i960_BIG_ENDIAN__
#define MSW g6
#define LSW g7
#else
#define LSW g6
#define MSW g7
#endif
.globl _memmove, _memcpy
.globl __memmove, __memcpy
.leafproc _memmove, __memmove
.leafproc _memcpy, __memcpy
.align 2
_memcpy:
_memmove:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__memcpy:
__memmove:
cmpibge.f 0,g2,Lquick_exit # Lexit if number of bytes to move is <= zero.
cmpo g0,g1 # if dest starts earlier than src ...
lda (g14),g13 # preserve return address
addo g2,g1,g5 # compute addr of byte after last byte of src
be.f Lexit_code # no move necessary if src and dest are same
concmpo g5,g0 # ... or if dest starts after end of src ...
notand g1,3,g3 # extract word addr of start of src
bg.f Lbackwards # ... then drop thru, else do move backwards
cmpo g3,g1 # check alignment of src
ld (g3),LSW # fetch word containing at least first byte
notand g0,3,g4 # extract word addr of start of dest
lda 4(g3),g3 # advance src word addr
bne.f Lcase_245 # branch if src is NOT word aligned
Lcase_13:
cmpo g0,g4 # check alignment of dest
subo 4,g4,g4 # store is pre-incrementing; back up dest addr
be.t Lcase_1 # branch if dest word aligned
Lcase_3: # src is word aligned; dest is not
addo 8,g4,g4 # move dest word ptr to first word boundary
lda (g0),g1 # copy dest byte ptr
mov LSW,MSW # make copy of first word of src
lda 32,g14 # initialize shift count to zero (mod 32)
Lcase_25:
Lcase_3_cloop_at_start: # character copying loop for start of dest str
cmpdeci 0,g2,g2 # is max_bytes exhausted?
be.f Lexit_code # Lexit if max_bytes is exhausted
#if __i960_BIG_ENDIAN__
rotate 8,MSW,MSW # move next byte into position for extraction
subo 8,g14,g14 # augment the shift counter
stob MSW,(g1) # store the byte in dest
#else
addo 8,g14,g14 # augment the shift counter
stob MSW,(g1) # store the byte in dest
shro 8,MSW,MSW # move next byte into position for extraction
#endif
lda 1(g1),g1 # post-increment dest ptr
cmpobne.t g1,g4,Lcase_3_cloop_at_start # branch if reached word boundary
ld (g3),MSW # fetch msw of operand for double shift
Lcase_4:
Lcase_3_wloop:
cmpi g2,4 # less than four bytes to move?
lda 4(g3),g3 # post-increment src word addr
eshro g14,g6,g1 # extract 4 bytes of src
bl.f Lcase_3_cloop # branch if < four bytes left to move
mov MSW,LSW # move msw to lsw
ld (g3),MSW # pre-fetch msw of operand for double shift
subi 4,g2,g2 # decrease max_byte count by the 4 bytes moved
st g1,(g4) # store 4 bytes to dest
addo 4,g4,g4 # post-increment dest ptr
b Lcase_3_wloop
Lcase_1_wloop: # word copying loop
subi 4,g2,g2 # decrease max_byte count by the 4 bytes moved
ld (g3),LSW # pre-fetch next word of src
addo 4,g3,g3 # post-increment src addr
st g1,(g4) # store word in dest string
Lcase_1: # src and dest are word aligned
cmpi g2,4 # check for fewer than four bytes to move
addo 4,g4,g4 # pre-increment dest addr
lda (LSW),g1 # keep a copy of the src word
bge.t Lcase_1_wloop # branch if at least four bytes to copy
Lcase_3_cloop:
cmpibe.f 0,g2,Lexit_code # Lexit if max_bytes is exhausted
Lcase_1_cloop:
#if __i960_BIG_ENDIAN__
rotate 8,g1,g1 # move next byte into position for extraction
#endif
subi 1,g2,g2
stob g1,(g4) # store the byte in dest
cmpi 0,g2
lda 1(g4),g4 # post-increment dest byte addr
#if ! __i960_BIG_ENDIAN__
shro 8,g1,g1 # move next byte into position for extraction
#endif
bne.t Lcase_1_cloop # Lexit if max_bytes is exhausted
Lexit_code:
mov 0,g14 # conform to register conventions
bx (g13) # g0 = addr of dest; g14 = 0
Lrett:
ret
Lcase_245:
cmpo g0,g4 # check alignment of dest
ld (g3),MSW # pre-fetch second half
and 3,g1,g1 # compute shift count
shlo 3,g1,g14
#if __i960_BIG_ENDIAN__
subo g14,0,g14 # adjust shift count for big endian
#endif
be.t Lcase_4 # branch if dest is word aligned
or g4,g1,g1 # is src earlier in word, later, or sync w/ dst
cmpo g0,g1 # < indicates first word of dest has more bytes
lda 4(g4),g4 # move dest word addr to first word boundary
eshro g14,g6,g5 # extract four bytes
lda (g0),g1
#if __i960_BIG_ENDIAN__
bge.f 1f
#else
bg.f 1f
#endif
mov MSW,LSW
lda 4(g3),g3 # move src word addr to second word boundary
1:
mov g5,MSW
b Lcase_25
Lbackwards:
notand g5,3,MSW # extract word addr of byte after end of src
cmpo MSW,g5 # check alignment of end of src
subo 4,MSW,g3 # retreat src word addr
addo g2,g0,g1 # compute addr of byte after end of dest
notand g1,3,g4 # extract word addr of start of dest
bne.f Lcase.245 # branch if src is NOT word aligned
Lcase.13:
cmpo g1,g4 # check alignment of dest
ld (g3),MSW # fetch last word of src
subo 4,g3,g3 # retreat src word addr
be.t Lcase.1 # branch if dest word aligned
Lcase.3: # src is word aligned; dest is not
mov MSW,LSW # make copy of first word of src
lda 32,g14 # initialize shift count to zero (mod 32)
Lcase.25:
Lcase.3_cloop_at_start: # character copying loop for start of dest str
cmpdeci 0,g2,g2 # is max.bytes exhausted?
be.f Lexit_code # Lexit if max_bytes is exhausted
#if ! __i960_BIG_ENDIAN__
rotate 8,LSW,LSW # move next byte into position for storing
#endif
lda -1(g1),g1 # pre-decrement dest ptr
cmpo g1,g4 # have we reached word boundary in dest yet?
stob LSW,(g1) # store the byte in dest
#if __i960_BIG_ENDIAN__
shro 8,LSW,LSW # move next byte into position for storing
addo 8,g14,g14 # augment the shift counter
#else
subo 8,g14,g14 # augment the shift counter
#endif
bne.t Lcase.3_cloop_at_start # branch if reached word boundary?
ld (g3),LSW # fetch lsw of operand for double shift
#if __i960_BIG_ENDIAN__
cmpobne 0,g14,Lcase.3_wloop
Lcase.3_wloop2:
cmpi g2,4 # less than four bytes to move?
lda -4(g3),g3 # post-decrement src word addr
mov MSW,g1 # extract 4 bytes of src
lda (LSW),MSW # move lsw to msw
subo 4,g4,g4 # pre-decrement dest ptr
bl.f Lcase.3_cloop # branch if < four bytes left to move
ld (g3),LSW # pre-fetch lsw of operand for double shift
subi 4,g2,g2 # decrease max.byte count by the 4 bytes moved
st g1,(g4) # store 4 bytes to dest
b Lcase.3_wloop2
#endif
Lcase.4:
Lcase.3_wloop:
cmpi g2,4 # less than four bytes to move?
lda -4(g3),g3 # post-decrement src word addr
eshro g14,g6,g1 # extract 4 bytes of src
lda (LSW),MSW # move lsw to msw
subo 4,g4,g4 # pre-decrement dest ptr
bl.f Lcase.3_cloop # branch if < four bytes left to move
ld (g3),LSW # pre-fetch lsw of operand for double shift
subi 4,g2,g2 # decrease max.byte count by the 4 bytes moved
st g1,(g4) # store 4 bytes to dest
b Lcase.3_wloop
Lcase.1_wloop: # word copying loop
subi 4,g2,g2 # decrease max.byte count by the 4 bytes moved
ld (g3),MSW # pre-fetch next word of src
subo 4,g3,g3 # post-decrement src addr
st g1,(g4) # store word in dest string
Lcase.1: # src and dest are word aligned
cmpi g2,4 # check for fewer than four bytes to move
subo 4,g4,g4 # pre-decrement dest addr
lda (MSW),g1 # keep a copy of the src word
bge.t Lcase.1_wloop # branch if at least four bytes to copy
Lcase.3_cloop:
cmpibe.f 0,g2,Lexit_code # Lexit if max_bytes is exhausted
#if ! __i960_BIG_ENDIAN__
rotate 8,g1,g1 # move next byte into position for storing
#endif
lda 4(g4),g4 # pre-decremented dest addr 4 too much
Lcase.1_cloop:
subi 1,g4,g4 # pre-decrement dest byte addr
cmpi g4,g0 # has dest ptr reached beginning of dest?
stob g1,(g4) # store the byte in dest
#if __i960_BIG_ENDIAN__
shro 8,g1,g1 # move next byte into position for storing
#else
rotate 8,g1,g1 # move next byte into position for storing
#endif
bne.t Lcase.1_cloop # Lexit if move is completed
b Lexit_code
Lcase.245:
cmpo g1,g4 # check alignment of dest
ld (MSW),MSW # pre-fetch word with at least last byte
and 3,g5,g5 # compute shift count
ld (g3),LSW # pre-fetch second to last word
shlo 3,g5,g14
#if __i960_BIG_ENDIAN__
subo g14,0,g14 # adjust shift count for big endian
#endif
be.t Lcase.4 # branch if dest is word aligned
or g4,g5,g5 # is src earlier in word, later, or sync w/ dst
cmpo g1,g5 # < indicates last word of dest has less bytes
eshro g14,g6,g5 # extract four bytes
bl.t 1f
mov LSW,MSW
#if ! __i960_BIG_ENDIAN__
be.t 1f
#endif
subo 4,g3,g3 # move src word addr to second word boundary
1:
mov g5,LSW
b Lcase.25
Lquick_exit:
mov g14,g13
b Lexit_code
/* end of memmove */
|
32bitmicro/newlib-nano-1.0
| 3,435
|
newlib/libc/machine/i960/strpbrk.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
/*
* (c) copyright 1989,1993 Intel Corp., all rights reserved
*/
/*
procedure strpbrk (optimized assembler version: 80960K series, 80960CA)
char_addr = strpbrk (string, brkset_string)
Return the address of the first character in string that is NOT
in the brkset_string. Return NULL if none exists.
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine.
This routine stays out of g3 and g4 altogether. They may be used by
the strtok routine, which calls this routine in an incestuous way.
*/
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
.file "strprk.s"
.globl _strpbrk
.globl __strpbrk
.leafproc _strpbrk, __strpbrk
.align 2
_strpbrk:
#ifdef __PIC
lda Lrett-(.+8)(ip),g14
b __strpbrk
#else
lda Lrett,g14
b __strpbrk
#endif
Lrett: ret
__strpbrk:
Lnext_char_strpbrk:
addo 1,g1,g2 # g2 will be the brkset ptr
ldob (g0),g7 # fetch next character of string
ldob (g1),g6 # fetch first character of brkset
cmpobe.f 0,g7,Lexit_char_not_found # quit if at end of string
Lscan_set_strpbrk:
cmpo g6,g7 # is brkset char equal to string char?
ldob (g2),g5 # fetch next brkset char
addo 1,g2,g2 # bump brkset ptr
be.f Lexit_char_found
cmpo g6,0 # is brkset_string exhausted?
lda (g5),g6
bne.t Lscan_set_strpbrk # check next character of brkset
addo 1,g0,g0 # check next character of string
b Lnext_char_strpbrk
Lexit_char_not_found:
mov 0,g0 # return null if brkset char not found in string
Lexit_char_found:
mov g14,g13 # save return address
lda 0,g14 # conform to register conventions
bx (g13)
/* end of strpbrk */
|
32bitmicro/newlib-nano-1.0
| 6,881
|
newlib/libc/machine/i960/memcmp_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "memcm_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1992,1993 Intel Corp., all rights reserved
*/
/*
procedure memcmp (optimized assembler version for the CA)
result = memcmp (src1_addr, src2_addr, max_bytes)
compare the byte array pointed to by src1_addr to the byte array
pointed to by src2_addr. Return 0 iff the arrays are equal, -1 if
src1_addr is lexicly less than src2_addr, and 1 if it is lexicly
greater. Do not compare more than max_bytes bytes.
Undefined behavior will occur if the end of either source array
is in the last word of the program's allocated memory space. This
is so because, in several cases, memcmp will fetch ahead one word.
Disallowing the fetch ahead would impose a severe performance penalty.
This program handles five cases:
1) both arguments start on a word boundary
2) neither are word aligned, but they are offset by the same amount
3) source1 is word aligned, source2 is not
4) source2 is word aligned, source1 is not
5) neither is word aligned, and they are offset by differing amounts
At the time of this writing, only g0 thru g7 and g14 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers are sufficient to implement the routine.
The registers are used as follows:
g0 original src1 ptr; extracted word; return result
g1 src2 ptr; byt extraction mask
g2 maximum number of bytes to compare
g3 src2 word ptr
Little endian
g4 lsw of src1
g5 msw of src1
g6 src2 word
g7 src1 word ptr
Big endian
g4 msw of src1
g5 lsw of src1
g6 src1 word ptr
g7 src2 word
g13 return address
g14 shift count
*/
#if __i960_BIG_ENDIAN__
#define MSW g4
#define LSW g5
#define SRC1 g6
#define SRC2 g7
#else
#define LSW g4
#define MSW g5
#define SRC2 g6
#define SRC1 g7
#endif
.globl _memcmp
.globl __memcmp
.leafproc _memcmp, __memcmp
.align 2
_memcmp:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__memcmp:
Lrestart:
#if __i960_BIG_ENDIAN__
subo 1,g0,SRC1
notand SRC1,3,SRC1 # extract word addr of start of src1
#else
notand g0,3,SRC1 # extract word addr of start of src1
#endif
lda (g14),g13 # preserve return address
cmpibge.f 0,g2,Lequal_exit # return equality if number bytes 0
notand g1,3,g3 # extract word addr of start of src2
ld (SRC1),LSW # fetch word with at least first byte of src1
cmpo g3,g1 # check alignment of src2
ld 4(SRC1),MSW # fetch second word of src1
shlo 3,g0,g14 # compute shift count for src1
#if __i960_BIG_ENDIAN__
subo g14,0,g14 # adjust shift count for big endian.
#endif
ld (g3),SRC2 # fetch word with at least first byte of src2
eshro g14,g4,LSW # extract word of src1
lda 8(SRC1),SRC1 # advance src1 word addr
bne.f Lsrc2_unaligned # branch if src2 is NOT word aligned
mov LSW,g0 # at least src2 is word aligned
lda 0xff,g1
Lwloop: # word comparing loop
cmpo SRC2,g0 # compare src1 and src2 words
lda 4(g3),g3 # pre-increment src2 addr
mov MSW,LSW # move msw of src1 to lsw
ld (SRC1),MSW # pre-fetch next msw of src1
subi 4,g2,g2 # decrement maximum byte count
bne.f Lcloop # branch if src1 and src2 unequal
cmpi 0,g2
ld (g3),SRC2 # pre-fetch next word of src2
eshro g14,g4,g0 # extract word of src1
lda 4(SRC1),SRC1 # post-increment src1 addr
bl.t Lwloop # branch if max_bytes not reached yet
b Lequal_exit # strings were equal up through max_bytes
Lcloop_setup: # setup for coming from Lsrc2_unaligned
mov LSW,g0 # restore extracted src1 word
subo 4,g2,g2 # make up for later re-incrementing
lda 0xff,g1 # byte extraction mask
Lcloop: # character comparing loop
#if __i960_BIG_ENDIAN__
rotate 24,g1,g1 # shift mask for next byte
#endif
and SRC2,g1,g3 # extract next char of src2
and g0,g1,LSW # extract next char of src1
cmpobne.f LSW,g3,.diff # check for equality
#if ! __i960_BIG_ENDIAN__
shlo 8,g1,g1 # shift mask for next byte
#endif
subi 1,g2,g2 # decrement character counter
b Lcloop # branch if null not reached
Lequal_exit: # words are equal up thru null byte
mov 0,g14 # conform to register conventions
lda 0,g0 # return zero, indicating equality
bx (g13) # return
Lrett:
ret
.diff:
addo 4,g2,g2 # to make up for extra decrement in loop
lda 0,g14
bl Lless_than_exit
Lgreater_than_exit:
cmpibge.f 0,g2,Lequal_exit # branch if difference is beyond max_bytes
mov 1,g0
bx (g13) # g0 = 1 (src1 > src2)
Lless_than_exit:
cmpibge.f 0,g2,Lequal_exit # branch if difference is beyond max_bytes
subi 1,0,g0
bx (g13) # g0 = -1 (src1 < src2)
Lsrc2_unaligned:
notor g1,3,g14 # first step in computing new src1 ptr
ld 4(g3),SRC1 # fetch second word of src2
shlo 3,g1,MSW # compute shift count for src2
#if __i960_BIG_ENDIAN__
subo MSW,0,MSW
#endif
eshro MSW,g6,SRC2 # extract word of src2
cmpo LSW,SRC2 # compare src1 and src2 words
lda 4(g3),g1 # set new src2 ptr
bne.f Lcloop_setup # first four bytes differ
subo g14,g0,g0 # second (final) step in computing new src1 ptr
addi g14,g2,g2 # compute new max_bytes too
lda (g13),g14 # prepare return pointer for Lrestart
b Lrestart # continue with both string fetches shifted
|
32bitmicro/newlib-nano-1.0
| 5,781
|
newlib/libc/machine/i960/strncat.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strncat.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strncat (optimized assembler version for the 80960K Series)
dest_addr = strncat (dest_addr, src_addr, max_bytes)
append the null terminated string pointed to by src_addr to the null
terminated string pointed to by dest_addr. Return the original
dest_addr. If the source string is longer than max_bytes, then
append only max_bytes bytes, and tack on a null byte on the end.
This routine will fail if the source and destination string
overlap (in particular, if the end of the source is overlapped
by the beginning of the destination). The behavior is undefined.
This is acceptable according to the draft C standard.
Undefined behavior will also occur if the end of the source string
(i.e. the terminating null byte) is in the last two words of the
program's allocated memory space. This is so because strncat fetches
ahead. Disallowing the fetch ahead would impose a severe performance
penalty.
Strategy:
First, skip to the null byte in the destination string. Then
fetch the source string by words and store them by words to the
destination string, until there are fewer than three bytes left
to copy. Then, using the last word of the source (the one that
contains the remaining 0, 1, 2, or 3 bytes to be copied), store
a byte at a time until Ldone.
If, before exhausting the max_byte count, the null byte is encountered
in the source string, then just copy up thru the null byte.
Tactics:
1) Do NOT try to fetch and store the words in a word aligned manner
because, in my judgement, the performance degradation experienced due
to non-aligned accesses does NOT outweigh the time and complexity added
by the preamble and convoluted body that would be necessary to assure
alignment.
*/
.globl _strncat
.globl __strncat
.leafproc _strncat,__strncat
.align 2
_strncat:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strncat:
mov g14,g6
cmpibge 0, g2, Lno_operation # Lexit early if max_bytes <= 0
mov g0, g5
Lskip_word_loop:
ld (g5), g7 # fetch word of dest string
addo 4, g5, g5 # post-increment dest ptr
scanbyte 0, g7 # does it contain null byte?
bno Lskip_word_loop # if not, loop
subo 5, g5, g5 # adjust dest ptr
lda 0xff, g3 # byte extraction mask = 0xff;
Lskip_byte_loop:
and g7, g3, g14 # extract byte of last word of dest string
cmpo 0, g14 # is it null?
addo 1, g5, g5 # adjust dest ptr
shro 8, g7, g7 # position next byte for extraction
bne Lskip_byte_loop # loop if null not found yet
ld (g1), g7 # fetch first word of source string
Lwloop: # word copying loop
cmpo 4, g2 # max_bytes < 4 ?
addo 4, g1, g1 # post-increment source ptr
bge Lcloop.a # branch if less than 4 bytes to move
scanbyte 0, g7 # is null byte reached yet?
mov g7, g4 # keep a copy of the source word
be Lcloop # branch if null byte reached
ld (g1), g7 # pre-fetch next word of source
subo 4, g2, g2 # reduce max_byte counter
st g4, (g5) # store current word
addo 4, g5, g5 # post-increment destination ptr
b Lwloop
Lcloop.b:
addo 1, g5, g5 # post-increment destination ptr
shro 8, g7, g7 # position next byte for extraction
Lcloop: # character copying loop (max_byte > 3)
and g3, g7, g4 # extract character
cmpo 0, g4 # is it null?
stob g4, (g5) # store it
bne Lcloop.b # loop if null not encountered yet
bx (g6) # g0 = dest string address; g14 = 0
Lrett:
ret
Lcloop.c:
addo 1, g5, g5 # post-increment destination ptr
shro 8, g7, g7 # position next byte for extraction
Lcloop.a: # character copying loop (max_byte <= 3)
cmpdeco 0,g2,g2 # max_byte == 0?
and g3, g7, g4 # extract character
be Ldone # store null and Lexit if max_byte exhausted
cmpo 0, g4 # is it null?
stob g4, (g5) # store it
bne Lcloop.c # loop if null not encountered yet
Ldone: stob g14, (g5) # store trailing null
bx (g6) # g0 = dest string address; g14 = 0
Lno_operation: mov 0, g14 # conform to register conventions
bx (g6)
/* end of strncat */
|
32bitmicro/newlib-nano-1.0
| 3,917
|
newlib/libc/machine/i960/setjmp.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
/******************************************************************************/
/* */
/* setjmp(), longjmp() */
/* */
/******************************************************************************/
.file "setjmp.as"
.text
/* .link_pix */
.align 4
.globl _setjmp
_setjmp:
flushreg
andnot 0xf,pfp,g1 /* get pfp, mask out return status bits */
st g1, 0x58(g0) /* save fp of caller*/
/* save globals not killed by the calling convention */
stq g8, 0x40(g0) /* save g8-g11*/
st g12, 0x50(g0) /* save g12*/
st g14, 0x54(g0) /* save g14*/
/* save previous frame local registers */
ldq (g1), g4 /* get previous frame pfp, sp, rip, r3 */
stq g4, (g0) /* save pfp, sp, rip, r3 */
ldq 0x10(g1), g4 /* get previous frame r4-r7 */
stq g4, 0x10(g0) /* save r4-r7 */
ldq 0x20(g1), g4 /* get previous frame r8-r11 */
stq g4, 0x20(g0) /* save r8-r11 */
ldq 0x30(g1), g4 /* get previous frame r12-r15 */
stq g4, 0x30(g0) /* save r12-r15 */
mov 0, g0 /* return 0 */
ret
/*
* fake a return to the place that called the corresponding _setjmp
*/
.align 4
.globl _longjmp
_longjmp:
call 0f /* ensure there is at least one stack frame */
0:
flushreg /* do this before swapping stack */
ld 0x58(g0), pfp /* get fp of caller of setjmp */
/* restore local registers
* the following code modifies the frame of the function which originally
* called setjmp.
*/
ldq (g0), g4 /* get pfp, sp, rip, r3 */
stq g4, (pfp) /* restore pfp, sp, rip, r3 */
ldq 0x10(g0), g4 /* get r4-r7 */
stq g4, 0x10(pfp) /* restore r4-r7 */
ldq 0x20(g0), g4 /* get r8-r11 */
stq g4, 0x20(pfp) /* restore r8-r11 */
ldq 0x30(g0), g4 /* get r12-r15 */
stq g4, 0x30(pfp) /* restore r12-r15 */
/* restore global registers */
ldq 0x40(g0), g8 /* get old g8-g11 values */
ld 0x50(g0), g12 /* get old g12 value */
ld 0x54(g0), g14 /* get old g14 value */
mov g1, g0 /* get return value */
cmpo g0, 0 /* make sure it is not zero */
bne 0f
mov 1, g0 /* return 1 by default */
0:
ret /* return to caller of _setjmp */
|
32bitmicro/newlib-nano-1.0
| 6,476
|
newlib/libc/machine/i960/strcpy.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strcpy.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strcpy (optimized assembler version for the 80960K series)
procedure strcat (optimized assembler version for the 80960K series)
dest_addr = strcpy (dest_addr, src_addr)
copy the null terminated string pointed to by src_addr to
the string space pointed to by dest_addr. Return the original
dest_addr.
This routine will fail if the source and destination string
overlap (in particular, if the end of the source is overlapped
by the beginning of the destination). The behavior is undefined.
This is acceptable according to the draft C standard.
Undefined behavior will also occur if the end of the source string
(i.e. the terminating null byte) is in the last two words of the
program's allocated memory space. This is so because strcpy fetches
ahead. Disallowing the fetch ahead would impose a severe performance
penalty.
Strategy:
Fetch the source string and store the destination string by words
until the null byte is encountered. When the word with the null
byte is reached, store it by bytes up through the null byte only.
Tactics:
1) Do NOT try to fetch and store the words in a word aligned manner
because, in my judgement, the performance degradation experienced due
to non-aligned accesses does NOT outweigh the time and complexity added
by the preamble and convoluted body that would be necessary to assure
alignment. This is supported by the intuition that most source and
destination strings will be word aligned to begin with.
procedure strcat
dest_addr = strcat (dest_addr, src_addr)
Appends the string pointed to by src_addr to the string pointed
to by dest_addr. The first character of the source string is
copied to the location initially occupied by the trailing null
byte of the destination string. Thereafter, characters are copied
from the source to the destination up thru the null byte that
trails the source string.
See the strcpy routine, above, for its caveats, as they apply here too.
Strategy:
Skip to the end (null byte) of the destination string, and then drop
into the strcpy code.
Tactics:
Skipping to the null byte is Ldone by reading the destination string
in long-words and scanbyte'ing them, then examining the bytes of the
word that contains the null byte, until the address of the null byte is
known. Then we drop into the strcpy routine. It is probable (approx.
three out of four times) that the destination string as strcpy sees
it will NOT be word aligned (i.e. that the null byte won't be the
last byte of a word). But it is not worth the complication to that
routine to force word aligned memory accesses to be gaurenteed.
*/
.globl _strcpy, _strcat
.globl __strcpy, __strcat
.leafproc _strcpy,__strcpy
.leafproc _strcat,__strcat
.align 2
_strcat:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strcat:
mov g14,g13 # preserve return address
ldl (g0),g4 # fetch first two words
addo 8,g0,g2 # post-increment src word pointer
lda 0xff,g3 # byte extraction mask
Lsearch_for_word_with_null_byte:
scanbyte 0,g4 # check for null byte
mov g5,g7 # copy second word
bo.f Lsearch_for_null # branch if null found
scanbyte 0,g7 # check for null byte
ldl (g2),g4 # fetch next pair of word of src
addo 8,g2,g2 # post-increment src word pointer
bno Lsearch_for_word_with_null_byte # branch if null not found yet
subo 4,g2,g2 # back up the byte pointer
mov g7,g4 # move word with null to search word
Lsearch_for_null:
subo 9,g2,g5 # back up the byte pointer
Lsearch_for_null.a:
and g4,g3,g6 # extract byte
cmpo 0,g6 # is it null?
addo 1,g5,g5 # bump src byte ptr
shro 8,g4,g4 # shift word to position next byte
bne Lsearch_for_null.a
b Lend_of_dest_found
_strcpy:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strcpy:
mov g0, g5
Lend_of_dest_found:
ld (g1), g2 # fetch first word of source
mov g14,g6 # preserve return address
lda 0xff, g3 # byte extraction mask = 0xff;
Lwloop: # word copying loop
addo 4, g1, g1 # post-increment source ptr
scanbyte 0, g2 # does source word contain null byte?
mov g2, g4 # save a copy of the source word
be Lcloop # branch if null present
ld (g1), g2 # pre-fetch next word of source
st g4, (g5) # store current word
addo 4, g5, g5 # post-increment dest ptr
b Lwloop
Lcloop: # character copying loop
and g3, g4, g14 # extract next char
shro 8, g4, g4 # position word for next byte extraction
cmpo 0, g14 # is it null?
stob g14, (g5) # store the byte
addo 1, g5, g5 # post-increment dest ptr
bne Lcloop # quit if null encountered
bx (g6) # g0 = dest string address; g14 = 0
Lrett:
ret
|
32bitmicro/newlib-nano-1.0
| 3,179
|
newlib/libc/machine/i960/strcspn.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strcspn.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1989,1993 Intel Corp., all rights reserved
*/
/*
procedure strcspn (optimized assembler version: 80960K series, 80960CA)
len = strcspn (string, charset)
Return the number of characters in the maximum leading segment
of string which consists solely of characters NOT from charset.
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine.
*/
.globl _strcspn
.globl __strcspn
.leafproc _strcspn, __strcspn
.align 2
_strcspn:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strcspn:
mov g14,g13 # save return address
lda (g0),g3 # copy string pointer
mov 0,g14 # conform to register conventions
Lnext_char:
ldob (g3),g7 # fetch next character of string
addo 1,g1,g2 # g2 will be the charset ptr
ldob (g1),g6 # fetch first character of charset
cmpobe.f 0,g7,Lexit # quit if at end of string
Lscan_set:
cmpo g6,g7 # is charset char same as string char?
ldob (g2),g5 # fetch next charset char
addo 1,g2,g2 # bump charset ptr
be.f Lexit
cmpo g6,0 # is charset exhausted?
lda (g5),g6
bne.t Lscan_set # check next character of charset
addo 1,g3,g3 # check next character of string
b Lnext_char
Lexit:
subo g0,g3,g0 # compute string length
bx (g13)
Lrett:
ret
/* end of strcspn */
|
32bitmicro/newlib-nano-1.0
| 9,947
|
newlib/libc/machine/i960/strcpy_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strcp_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strcpy (optimized assembler version for the CA)
dest_addr = strcpy (dest_addr, src_addr)
copy the null terminated string pointed to by src_addr to
the string space pointed to by dest_addr. Return the original
dest_addr.
This routine will fail if the source and destination string
overlap (in particular, if the end of the source is overlapped
by the beginning of the destination). The behavior is undefined.
This is acceptable according to the draft C standard.
Undefined behavior will also occur if the end of the source string
(i.e. the terminating null byte) is in the last word of the program's
allocated memory space. This is so because, in several cases, strcpy
will fetch ahead one word. Disallowing the fetch ahead would impose
a severe performance penalty.
This program handles five cases:
1) both arguments start on a word boundary
2) neither are word aligned, but they are offset by the same amount
3) source is word aligned, destination is not
4) destination is word aligned, source is not
5) neither is word aligned, and they are offset by differing amounts
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine. The registers are used as follows:
g0 original dest ptr; not modified, so that it may be returned.
g1 src ptr; shift count
g2 dest ptr; 4 bytes of src
g3 src ptr (word aligned)
g4 dest ptr (word aligned)
g5 0xff -- byte extraction mask
g6 lsw of double word for extraction of 4 bytes (little endian)
msw of double word for extraction of 4 bytes (big endian)
g7 msw of double word for extraction of 4 bytes (little endian)
lsw of double word for extraction of 4 bytes (big endian)
g13 return address
g14 byte extracted. When reaches null byte, which is zero, we will
be in conformance with register conventions, and can return to
the caller with a clear conscience.
procedure strcat
dest_addr = strcat (dest_addr, src_addr)
Appends the string pointed to by src_addr to the string pointed
to by dest_addr. The first character of the source string is
copied to the location initially occupied by the trailing null
byte of the destination string. Thereafter, characters are copied
from the source to the destination up thru the null byte that
trails the source string.
*/
#if __i960_BIG_ENDIAN__
#define MSW g6
#define LSW g7
#else
#define LSW g6
#define MSW g7
#endif
.globl _strcpy, _strcat
.globl __strcpy, __strcat
.leafproc _strcpy, __strcpy
.leafproc _strcat, __strcat
.align 2
_strcat:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strcat:
notand g0,3,g4 # extract word addr of start of dest
lda (g14),g13 # preserve return address
and g0,3,LSW # extract byte offset of dest
ld (g4),MSW # fetch word containing at least first byte
shlo 3,LSW,g14 # get shift count for making mask for first word
subi 1,0,LSW # mask initially all ones
#if __i960_BIG_ENDIAN__
shro g14,LSW,LSW # get mask for bytes needed from first word
lda 0xff000000,g5 # byte extraction mask
#else
shlo g14,LSW,LSW # get mask for bytes needed from first word
lda 0xff,g5 # byte extraction mask
#endif
notor MSW,LSW,MSW # set unneeded bytes to all ones
Lsearch_for_word_with_null:
scanbyte 0,MSW # check for null byte
lda 4(g4),g4 # post-increment dest word pointer
mov MSW,LSW # keep a copy of current word
ld (g4),MSW # fetch next word of dest
bno.t Lsearch_for_word_with_null # branch if null not found yet
and g5,LSW,g14 # extract byte
cmpo 0,g14 # branch if null is first byte of word
subo 4,g4,g4 # move dest word ptr back to word with null
notand g1,3,g3 # extract word addr of start of src
lda (g4),g2 # set dest byte ptr to 1st byte of word w/ null
be.f Lcase_14
Lsearch_for_null:
#if __i960_BIG_ENDIAN__
shro 8,g5,g5 # move mask down to next byte
#else
shlo 8,g5,g5 # move mask up to next byte
#endif
lda 1(g2),g2 # move dest byte ptr to next byte
and g5,LSW,g14 # extract byte
cmpobne.t 0,g14,Lsearch_for_null # branch if null is not yet found
lda 0xff,g5 # byte extraction mask
b Lcase_235.a
_strcpy:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strcpy:
notand g0,3,g4 # extract word addr of start of dest
lda (g14),g13 # preserve return address
cmpo g0,g4 # check alignment of dest
lda 0xff,g5 # load mask for byte extraction
notand g1,3,g3 # extract word addr of start of src
bne.f Lcase_235 # branch if dest is NOT word aligned
Lcase_14:
cmpo g3,g1 # check alignment of src
ld (g3),LSW # fetch word containing at least first byte
shlo 3,g1,g1 # compute shift count
lda 4(g3),g3 # advance src word addr
#if __i960_BIG_ENDIAN__
lda 0xff,g5 # byte extraction mask
#endif
bne.f Lcase_4 # branch if src is NOT word aligned
Lcase_1: # src and dest are word aligned
subo 4,g4,g4 # store is pre-incrementing; back up dest addr
Lcase_1_wloop: # word copying loop
scanbyte 0,LSW # check for null byte in src word
lda (LSW),g2 # keep a copy of the src word
addo 4,g4,g4 # pre-increment dest addr
ld (g3),LSW # pre-fetch next word of src
addo 4,g3,g3 # post-increment src addr
bo.f Lcase_1_cloop # branch if word contains null byte
st g2,(g4) # store word in dest string
b Lcase_1_wloop
Lcase_3_cloop:
Lcase_1_cloop: # character copying loop
#if __i960_BIG_ENDIAN__
rotate 8,g2,g2 # move next byte into position for extraction
and g5,g2,g14 # extract next char
#else
and g5,g2,g14 # extract next char
shro 8,g2,g2 # move next byte into position for extraction
#endif
cmpo 0,g14 # check for null byte
stob g14,(g4) # store the byte in dest
lda 1(g4),g4 # post-increment dest byte addr
bne.t Lcase_1_cloop # branch if null not reached
Lexit_code:
bx (g13) # g0 = addr of dest; g14 = 0
Lrett:
ret
Lcase_3: # src is word aligned; dest is not
addo 4,g4,g4 # move dest word ptr to first word boundary
mov LSW,MSW # make copy of first word of src
lda 0,g1 # initialize shift count to zero
Lcase_25:
Lcase_3_cloop_at_start: # character copying loop for start of dest str
#if __i960_BIG_ENDIAN__
rotate 8,MSW,MSW # move next byte into position for extraction
and g5,MSW,g14 # extract next char
#else
and g5,MSW,g14 # extract next char
shro 8,MSW,MSW # move next byte into position for extraction
#endif
cmpo 0,g14 # check for null byte
stob g14,(g2) # store the byte in dest
lda 1(g2),g2 # post-increment dest ptr
be.f Lexit_code # branch if null byte reached
cmpo g2,g4 # have we reached word boundary in dest?
lda 8(g1),g1 # augment the shift counter
bne.t Lcase_3_cloop_at_start
Lcase_4:
ld (g3),MSW # fetch msw of operand for double shift
#if __i960_BIG_ENDIAN__
subo g1,0,g1 # Adjust shift count for big endian.
#endif
Lcase_3_wloop:
eshro g1,g6,g2 # extract 4 bytes of src
lda 4(g3),g3 # post-increment src word addr
scanbyte 0,g2 # check for null byte
lda (MSW),LSW # move msw to lsw
ld (g3),MSW # pre-fetch msw of operand for double shift
bo.f Lcase_3_cloop # branch if word contains null byte
st g2,(g4) # store 4 bytes to dest
addo 4,g4,g4 # post-increment dest ptr
b Lcase_3_wloop
Lcase_235:
lda (g0),g2 # copy dest ptr
Lcase_235.a:
cmpo g3,g1 # check alignment of src
ld (g3),LSW # fetch word containing at least first byte
and 3,g1,g14 # compute shift count
lda 4(g3),g3 # advance src word addr
shlo 3,g14,g1
be.t Lcase_3 # branch if dest is word aligned
or g4,g14,g14 # is src earlier in word, later, or sync w/ dst
ld (g3),MSW # pre-fetch second half
cmpo g2,g14 # < indicates first word of dest has more bytes
lda 4(g4),g4 # move dest word addr to first word boundary
/* than first word of source. */
#if __i960_BIG_ENDIAN__
subo g1,0,g14 # Adjust shift count for big endian.
eshro g14,g6,g14 # extract four bytes
bge.f 1f
#else
eshro g1,g6,g14 # extract four bytes
bg.f 1f
#endif
mov MSW,LSW
lda 4(g3),g3 # move src word addr to second word boundary
1:
mov g14,MSW
b Lcase_25
/* end of strcpy */
|
32bitmicro/newlib-nano-1.0
| 5,074
|
newlib/libc/machine/i960/strlen_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strle_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strlen (optimized assembler version for the CA)
src_addr = strlen (src_addr)
return the number of bytes that precede the null byte in the
string pointed to by src_addr.
Undefined behavior will occur if the end of the source string (i.e.
the terminating null byte) is in the last four words of the program's
allocated memory space. This is so because, in several cases, strlen
will fetch ahead several words. Disallowing the fetch ahead would
impose a severe performance penalty.
This program handles two cases:
1) the argument starts on a word boundary
2) the argument doesn't start on a word boundary
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine. The registers are used as follows:
g0 original src ptr; upon return it is the byte count.
g1
g2 src ptr
g3 mask
g4 even word of the source string
g5 odd word of the source string
g6 copy of even word, shift count
g7 copy of odd word
g13 return address
g14 byte extracted.
*/
.globl _strlen
.globl __strlen
.leafproc _strlen, __strlen
.align 2
_strlen:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strlen:
notand g0,3,g2 # extract word addr of start of src
lda (g14),g13 # preserve return address
and g0,3,g7 # extract byte offset of src
ld (g2),g5 # fetch word containing at least first byte
shlo 3,g7,g7 # get shift count for making mask for first word
lda 4(g2),g2 # post-increment src word pointer
subi 1,0,g3 # mask initially all ones
chkbit 2,g2 # are we on an even word boundary or an odd one?
#if __i960_BIG_ENDIAN__
shro g7,g3,g3 # get mask for bytes needed from first word
notor g5,g3,g7 # set unneeded bytes to all ones
lda 0xff000000,g3 # byte extraction mask
#else
shlo g7,g3,g3 # get mask for bytes needed from first word
notor g5,g3,g7 # set unneeded bytes to all ones
lda 0xff,g3 # byte extraction mask
#endif
bno.f Lodd_word # branch if first word is odd
mov g7,g4 # move first word to copy thereof
ld (g2),g5 # load odd word
lda 4(g2),g2 # post-increment src word pointer
Leven_word:
scanbyte 0,g4 # check for null byte
movl g4,g6 # copy both words
Lodd_word: # trickery! if we branch here, following branch
/* instruction will fall thru, as we want, */
/* effecting the load of g4 and g5 only. */
ldl (g2),g4 # fetch next pair of word of src
bo.f Lsearch_for_null # branch if null found
scanbyte 0,g7 # check for null byte
lda 8(g2),g2 # post-increment src word pointer
bno.t Leven_word # branch if null not found yet
subo 4,g2,g2 # back up the byte pointer
lda (g7),g6 # move odd word to search word
Lsearch_for_null:
subo 9,g2,g2 # back up the byte pointer
Lsearch_for_null.a:
and g6,g3,g14 # extract byte
cmpo 0,g14 # is it null?
lda 1(g2),g2 # bump src byte ptr
#if __i960_BIG_ENDIAN__
shlo 8,g6,g6 # shift word to position next byte
#else
shro 8,g6,g6 # shift word to position next byte
#endif
bne.t Lsearch_for_null.a
Lexit_code:
subo g0,g2,g0 # calculate string length
bx (g13) # g0 = addr of src; g14 = 0
Lrett:
ret
/* end of strlen */
|
32bitmicro/newlib-nano-1.0
| 2,480
|
newlib/libc/machine/i960/strdup.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strdup.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1989,1993 Intel Corp., all rights reserved
*/
/*
procedure strdup (optimized assembler version: 80960K series, 80960CA)
dest_addr = strdup (src_addr)
Allocate memory and copy thereto the string pointed to by src_addr.
Return the address of the copy, or null if unable to perform the
operation.
*/
.text
.align 2
.globl _strdup
_strdup:
mov g0,r3 # Keep a copy of the original string addr
callj _strlen # Determine how much to allocate
addo 1,g0,g0 # Add one byte for the null byte at end
callj _malloc # Allocate the storage
cmpo 0,g0
mov r3,g1 # Original string addr is now src for copy
bne.t _strcpy # Jump if allocation was successful
ret # Return the null ptr otherwise
/* end of strdup */
|
32bitmicro/newlib-nano-1.0
| 4,835
|
newlib/libc/machine/i960/memccpy.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "memccpy.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1989,1993 Intel Corp., all rights reserved
*/
/*
procedure memccpy (optimized assembler version for the 80960K series)
dest_addr = memccpy (dest_addr, src_addr, char, len)
copy len bytes pointed to by src_addr to the space pointed to by
dest_addr, stopping if char is copied. If char is copied,
return address of byte after char in dest string; else null.
Undefined behavior will occur if the end of the source array is in
the last two words of the program's allocated memory space. This
is so because the routine fetches ahead. Disallowing the fetch
ahead would impose a severe performance penalty.
Undefined behavior will also occur if the source and destination
strings overlap.
Strategy:
Fetch the source array by words and store them by words to the
destination array, until there are fewer than three bytes left
to copy. Then, using the last word of the source (the one that
contains the remaining 0, 1, 2, or 3 bytes to be copied), store
a byte at a time until Ldone.
Tactics:
1) Do NOT try to fetch and store the words in a word aligned manner
because, in my judgement, the performance degradation experienced due
to non-aligned accesses does NOT outweigh the time and complexity added
by the preamble and convoluted body that would be necessary to assure
alignment. This is supported by the intuition that most source and
destination arrays (even more true of most big source arrays) will
be word aligned to begin with.
2) Rather than decrementing len to zero,
I calculate the address of the byte after the last byte of the
destination array, and quit when the destination byte pointer passes
that.
*/
.globl _memccpy
.leafproc _memccpy, __memccpy
.align 2
_memccpy:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__memccpy:
mov g14, g13 # preserve return address
cmpibge 0,g3,Lexit_char_not_found
addo g3,g1,g3 # compute beyond end of src
ld (g1), g7 # fetch first word of source
lda 0xff,g5 # mask for char
and g5,g2,g2 # extract only char
shlo 8,g2,g6
or g2,g6,g6
shlo 16,g6,g4
or g6,g4,g6 # word of char
b Lwloop_b
Lwloop_a:
ld (g1), g7 # fetch ahead next word of source
st g4, (g0) # store word to dest
addo 4, g0, g0 # post-increment dest pointer
Lwloop_b: # word copying loop
addo 4, g1, g1 # pre-increment src pointer
cmpo g3, g1 # is len <= 3 ?
mov g7, g4 # keep a copy of the current word
bl Lcloop_setup # quit word loop if less than 4 bytes
scanbyte g6, g7 # check for char
bno Lwloop_a # continue word loop if char not found.
Lcloop_setup:
subo 4, g1, g1 # back down src pointer
cmpobe g1, g3, Lexit_char_not_found
Lcloop_a: # character copying loop (len < 3)
and g5,g4,g7 # check the byte against char
cmpo g7,g2
stob g7,(g0) # store the byte
addo 1, g0, g0
be Lexit_char_found
addo 1,g1,g1
cmpo g1,g3
shro 8,g4,g4 # position next byte
bne Lcloop_a
Lexit_char_not_found:
mov 0, g0
Lexit_char_found:
lda 0,g14
bx (g13) # g0 = dest array address; g14 = 0
Lrett:
ret
/* end of memccpy */
|
32bitmicro/newlib-nano-1.0
| 5,373
|
newlib/libc/machine/i960/memchr_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "memchr_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure memchr (optimized assembler version for the CA)
src_addr = memchr (src_addr, char, max_bytes)
searching from src_addr for max_bytes bytes, return a pointer to the
first byte that contains the indicated byte in the source string.
Return null if the byte is not found.
Undefined behavior will occur if the end of the source string (i.e.
the terminating null byte) is in the last two words of the program's
allocated memory space. This is so because, in several cases, memchr
will fetch ahead. Disallowing the fetch ahead would impose a severe
performance penalty.
This program handles two cases:
1) the argument starts on a word boundary
2) the argument doesn't start on a word boundary
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine. The registers are used as follows:
g0 src ptr; upon return it is a pointer to the matching byte, or null
g1 char to seek
g2 maximum number of bytes to check
g3 char to seek, broadcast to all four bytes
g4 word of the source string
g5 copy of the word
g6 mask to avoid unimportant bytes in first word
g7 byte extraction mask
g13 return address
g14
*/
.globl _memchr
.globl __memchr
.leafproc _memchr, __memchr
.align 2
_memchr:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__memchr:
mov g14,g13 # preserve return address
lda 0xff,g7 # byte extraction mask
and g1,g7,g1 # make char an 8-bit ordinal
lda 0,g14 # conform to register linkage standard
cmpibge.f 0,g2,Lnot_found # do nothing if max_bytes <= 0
addo g0,g2,g2 # compute ending address from start and len
and g0,3,g6 # extract byte offset of src
notand g0,3,g0 # extract word addr of start of src
shlo 8,g1,g3 # broadcast the char to four bytes
ld (g0),g4 # fetch word containing at least first byte
or g1,g3,g3
shlo 16,g3,g5
cmpo g1,g7 # is char being sought 0xff?
or g5,g3,g3
shlo 3,g6,g6 # get shift count for making mask for first word
subi 1,0,g5 # mask initially all ones
#if __i960_BIG_ENDIAN__
shro g6,g5,g5 # get mask for bytes needed from first word
#else
shlo g6,g5,g5 # get mask for bytes needed from first word
#endif
notor g4,g5,g4 # set unneeded bytes to all ones
be.f Lsearch_for_0xff # branch if seeking 0xff
Lsearch_for_word_with_char:
scanbyte g3,g4 # check for byte with char
lda 4(g0),g0 # pre-increment src word pointer
mov g4,g5 # keep a copy of word
ld (g0),g4 # fetch next word of src
bo.f Lsearch_for_char # branch if null found
cmpoble.t g0,g2,Lsearch_for_word_with_char # branch if not null
Lnot_found:
mov 0,g0 # char not found. Return null
Lexit_code:
bx (g13) # g0 = addr of char in src (or null); g14 = 0
Lrett:
ret
Lsearch_for_char:
subo 4,g0,g0 # back up the byte pointer
Lsearch_for_char.a:
cmpobe.f g0,g2,Lnot_found # quit if max_bytes exhausted
#if __i960_BIG_ENDIAN__
rotate 8,g5,g5 # shift word to position next byte
#endif
and g5,g7,g6 # extract byte
cmpo g1,g6 # is it char?
lda 1(g0),g0 # bump src byte ptr
#if ! __i960_BIG_ENDIAN__
shro 8,g5,g5 # shift word to position next byte
#endif
bne.t Lsearch_for_char.a
subo 1,g0,g0 # back up the byte pointer
b Lexit_code
Lsearch_for_0xff:
lda 0xf0f0f0f0,g6 # make first comparison mask for char=-1 case.
or g6,g5,g6
and g4,g6,g4 # make unimportant bytes of first word 0x0f
b Lsearch_for_word_with_char
/* end of memchr */
|
32bitmicro/newlib-nano-1.0
| 4,578
|
newlib/libc/machine/i960/strncmp.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strncmp.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strncmp (optimized assembler version for the 80960K Series)
result = strncmp (src1_addr, src2_addr, max_bytes)
compare the null terminated string pointed to by src1_addr to
the string pointed to by src2_addr. Return 0 iff the strings
are equal, -1 if src1_addr is lexicographically less than src2_addr,
and 1 if it is lexicographically greater. Do not compare more than
max_bytes bytes.
Undefined behavior will occur if the end of either source string
(i.e. the terminating null byte) is in the last two words of the
program's allocated memory space. This is so because strncmp
will fetch ahead. Disallowing the fetch ahead would impose
a severe performance penalty.
Strategy:
Fetch and compare the strings by words and go to a character
comparison loop as soon as a pair of words differ. If the
words are equal up through either the exhaustion of max_bytes
or the presence of the null byte, return 0 (equality). Otherwise,
the character comparator will return -1 or 1 for inequality, or
0 if the differing byte is after the null byte or after the
exhaustion of max_bytes.
Tactics:
1) Do NOT try to fetch the words in a word aligned manner because,
in my judgement, the performance degradation experienced due to
non-aligned accesses does NOT outweigh the time and complexity added
by the preamble and convoluted body that would be necessary to assure
alignment.
*/
.globl _strncmp
.globl __strncmp
.leafproc _strncmp,__strncmp
.align 2
_strncmp:
#ifndef __PIC
lda .Lrett,g14
#else
lda .Lrett-(.+8)(ip),g14
#endif
__strncmp:
mov g14,g13
ldconst 0,g14
cmpibge 0,g2,Lequal_exit # Lexit early if max_bytes <= 0
addo g2,g0,g2
.Lwloop:
cmpo g0,g2 # are max_bytes exhausted?
ld (g0), g5 # fetch word of source_1
bge Lequal_exit # Lexit (equality) if max_bytes exhausted
ld (g1), g3 # fetch word of source_2
addo 4,g0,g0 # post-increment source_1 ptr
scanbyte 0,g5 # is a null byte present?
addo 4,g1,g1 # post-increment source_1 ptr
be .Lcloop.a # perform char comparator if null byte found
cmpobe g5,g3,.Lwloop # perform char comparator if words are unequal
.Lcloop.a: subo 4,g0,g0 # adjust max_byte counter
ldconst 0xff,g4 # byte extraction mask
.Lcloop: and g4,g5,g7 # compare individual bytes
and g4,g3,g6
cmpobne g7,g6,.diff # if different, return -1 or 1
cmpo 0,g6 # they are equal. are they null?
shlo 8,g4,g4 # position mask to extract next byte
be Lequal_exit # if they are null, Lexit (equality)
addo 1,g0,g0 # is max_bytes exhausted?
cmpobl g0,g2,.Lcloop # if not, loop. if so, Lexit (equality)
Lequal_exit:
mov 0,g0
bx (g13)
.Lrett:
ret
.diff: bl .neg
mov 1,g0
bx (g13)
.neg: subi 1,0,g0
.Lexit:
bx (g13)
/* end of strncmp */
|
32bitmicro/newlib-nano-1.0
| 3,969
|
newlib/libc/machine/i960/memset.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "memset.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1989,1993 Intel Corp., all rights reserved
*/
/*
procedure memset (optimized assembler version: 80960K series, 80960CA)
dest_addr = memset (dest_addr, char, len)
Fill len bytes pointed to by dest_addr with the value of char.
Return the original address of dest_addr.
This program avoids performing unaligned accesses. It stores
from zero to seven bytes, and then stores aligned longwords,
and then stores from zero to seven bytes, as necessary to
store len bytes starting at dest_addr.
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine.
*/
.globl _memset
.globl __memset
.leafproc _memset, __memset
.align 2
_memset:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__memset:
cmpo 7,g2 # are there fewer than seven characters to move?
lda (g14),g13 # save return address
notand g0,7,g3 # test for non-aligned dest_ptr
lda 0,g14 # conform to register conventions
shlo 24,g1,g4 # prepare word of char
lda (g0),g6 # preserve dest_ptr for return
shro 8,g4,g5
bge.f Lcloop_setup
cmpo g3,g0 # is dest longword aligned
lda 7(g3),g3 # bump dest_ptr to next longword boundary
or g4,g5,g4
be.t Lwloop_setup
Lbgn_cloop:
cmpo g6,g3 # Have we reached longword boundary?
stob g1,(g6) # store one byte of char
subo 1,g2,g2 # decrement len
lda 1(g6),g6 # increment dest_ptr
bne.t Lbgn_cloop # loop if more bytes to store before longword
cmpobge.f 7,g2,Lcloop
Lwloop_setup:
shro 16,g4,g5
or g4,g5,g4
mov g4,g5 # now have a longword of char
Lwloop:
cmpo 15,g2 # Do we have to store more longwords?
stl g4,(g6) # Store longword of char
subo 8,g2,g2 # Decrement len
lda 8(g6),g6 # Increment dest_ptr
bl.t Lwloop # loop if more longwords to store
Lcloop_setup:
cmpobge.t 0,g2,Lexit
Lcloop:
cmpo 1,g2 # Is len exhausted?
stob g1,(g6) # Store byte
subo 1,g2,g2 # Decrement len
lda 1(g6),g6 # Increment dest_ptr
bne.t Lcloop # loop if more bytes to store
Lexit:
bx (g13)
Lrett:
ret
/* end of memset */
|
32bitmicro/newlib-nano-1.0
| 10,423
|
newlib/libc/machine/i960/strncat_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "sncat_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strncat (optimized assembler version for the CA)
dest_addr = strncat (dest_addr, src_addr, max_bytes)
append the null terminated string pointed to by src_addr to the null
terminated string pointed to by dest_addr. Return the original
dest_addr. If the source string is longer than max_bytes, then
append only max_bytes bytes, and tack on a null byte on the end
This routine will fail if the source and destination string
overlap (in particular, if the end of the source is overlapped
by the beginning of the destination). The behavior is undefined.
This is acceptable according to the draft C standard.
Undefined behavior will also occur if the end of the source string
(i.e. the terminating null byte) is in the last word of the program's
allocated memory space. This is so because, in several cases, strncat
will fetch ahead one word. Disallowing the fetch ahead would impose
a severe performance penalty.
This program handles five cases:
1) both arguments start on a word boundary
2) neither are word aligned, but they are offset by the same amount
3) source is word aligned, destination is not
4) destination is word aligned, source is not
5) neither is word aligned, and they are offset by differing amounts
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine. The registers are used as follows:
g0 original dest ptr; not modified, so that it may be returned.
g1 src ptr; shift count
g2 max_bytes
g3 src ptr (word aligned)
g4 dest ptr (word aligned)
g5 0xff -- byte extraction mask
Little endian:
g6 lsw of double word for extraction of 4 bytes
g7 msw of double word for extraction of 4 bytes
Big endian:
g6 msw of double word for extraction of 4 bytes
g7 lsw of double word for extraction of 4 bytes
g13 return address
g14 byte extracted.
*/
#if __i960_BIG_ENDIAN__
#define MSW g6
#define LSW g7
#else
#define LSW g6
#define MSW g7
#endif
.globl _strncat
.globl __strncat
.leafproc _strncat, __strncat
.align 2
_strncat:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strncat:
notand g0,3,g4 # extract word addr of start of dest
lda (g14),g13 # preserve return address
cmpibge.f 0,g2,Lexit_code # Lexit if number of bytes to move is <= zero.
and g0,3,LSW # extract byte offset of dest
ld (g4),MSW # fetch word containing at least first byte
shlo 3,LSW,g14 # get shift count for making mask for first word
subi 1,0,LSW # mask initially all ones
#if __i960_BIG_ENDIAN__
shro g14,LSW,LSW # get mask for bytes needed from first word
#else
shlo g14,LSW,LSW # get mask for bytes needed from first word
#endif
notor MSW,LSW,MSW # set unneeded bytes to all ones
lda 0xff,g5 # byte extraction mask
Lsearch_for_word_with_null:
scanbyte 0,MSW # check for null byte
lda 4(g4),g4 # post-increment dest word pointer
mov MSW,LSW # keep a copy of current word
ld (g4),MSW # fetch next word of dest
bno.t Lsearch_for_word_with_null # branch if null not found yet
#if __i960_BIG_ENDIAN__
shro 24,LSW,g14 # extract byte
#else
and g5,LSW,g14 # extract byte
#endif
cmpo 0,g14 # branch if null is first byte of word
subo 4,g4,g4 # move dest word ptr to word with null
notand g1,3,g3 # extract word addr of start of src
bne.t Lsearch_for_null
Lcase_14:
cmpo g1,g3 # check alignment of source
ld (g3),LSW # fetch first word of source
shlo 3,g1,g14 # compute shift count
lda 4(g3),g3 # post-increment src addr
bne.f Lcase_4 # branch if source is unaligned
Lcase_1:
Lcase_1_wloop: # word copying loop
cmpi g2,4 # check for fewer than four bytes to move
lda (LSW),g1 # keep a copy of the src word
bl.f Lcase_1_cloop # branch if fewer than four bytes to copy
scanbyte 0,g1 # check for null byte in src word
ld (g3),LSW # pre-fetch next word of src
addo 4,g3,g3 # post-increment src addr
bo.f Lcase_1_cloop # branch if word contains null byte
subi 4,g2,g2 # decrease max_byte count by the 4 bytes moved
st g1,(g4) # store word in dest string
addo 4,g4,g4 # post-increment dest addr
b Lcase_1_wloop
Lcase_3_cloop:
Lcase_1_cloop: # character copying loop (max_bytes <= 3)
cmpdeci 0,g2,g2 # is max_bytes exhausted?
#if __i960_BIG_ENDIAN__
rotate 8,g1,g1 # move next byte into position for extraction
#endif
and g5,g1,g14 # extract next char
be.f Lstore_null # if max_bytes is exhausted, store null and quit
cmpo 0,g14 # check for null byte
stob g14,(g4) # store the byte in dest
#if ! __i960_BIG_ENDIAN__
shro 8,g1,g1 # move next byte into position for extraction
#endif
lda 1(g4),g4 # post-increment dest byte addr
bne.t Lcase_1_cloop # branch if null not reached
bx (g13) # Lexit (g14 == 0)
Lstore_null:
mov 0,g14 # store null, and set g14 to zero
stob g14,(g4)
bx (g13)
Lsearch_for_null:
#if __i960_BIG_ENDIAN__
shlo 8,LSW,LSW # check next byte
shro 24,LSW,g14
#else
shlo 8,g5,g5 # move mask up to next byte
and g5,LSW,g14 # extract byte
#endif
lda 1(g4),g4 # move dest byte ptr to next byte
cmpobne.t 0,g14,Lsearch_for_null # branch if null is not yet found
Lcase_235:
cmpo g1,g3 # check alignment of src
ld (g3),LSW # pre-fetch word with start of src
and 3,g1,g1 # compute shift count
lda 0xff,g5 # load mask for byte extraction
shlo 3,g1,g14
lda 4(g3),g3 # post-increment src word counter
be.t Lcase_3 # branch if src is word aligned
and g4,3,MSW # extract byte offset for dest string
cmpo MSW,g1 # < indicates first word of dest has more bytes
/* than first word of source. */
ld (g3),MSW # fetch second word of src
#if __i960_BIG_ENDIAN__
subo g14,0,g14 # adjust shift count for big endian
#endif
eshro g14,g6,g5 # extract four bytes
#if __i960_BIG_ENDIAN__
bge.f 1f
#else
bg.f 1f
#endif
mov MSW,LSW
lda 4(g3),g3 # move src word addr to second word boundary
1:
mov g5,MSW
lda 0xff,g5
b Lcase_25
Lcase_3: # src is word aligned; dest is not
mov LSW,MSW # make copy of first word of src
lda 32,g14 # initialize shift count to zero (mod 32)
Lcase_25:
Lcase_3_cloop_at_start: # character copying loop for start of dest str
cmpdeci 0,g2,g2 # is max_bytes exhausted?
#if __i960_BIG_ENDIAN__
shro 24,MSW,g5 # extract next char
#else
and g5,MSW,g5 # extract next char
#endif
be.f Lstore_null # Lexit if max_bytes is exhausted
cmpo 0,g5 # check for null byte
stob g5,(g4) # store the byte in dest
addo 1,g4,g4 # post-increment dest ptr
lda 0xff,g5 # re-initialize byte extraction mask
notand g4,3,g1 # extract word address
be.t Lexit_code # Lexit if null byte reached
cmpo g1,g4 # have we reached word boundary in dest yet?
#if __i960_BIG_ENDIAN__
lda -8(g14),g14 # augment the shift counter
rotate 8,MSW,MSW # move next byte into position for extraction
#else
lda 8(g14),g14 # augment the shift counter
shro 8,MSW,MSW # move next byte into position for extraction
#endif
bne.t Lcase_3_cloop_at_start # branch if reached word boundary?
#if __i960_BIG_ENDIAN__
cmpo 0,g14
ld (g3),MSW # fetch msw of operand for double shift
bne Lcase_3_wloop # branch if src is still unaligned.
Lcase_3_wloop2:
cmpi g2,4 # less than four bytes to move?
mov LSW,g1 # extract 4 bytes of src
lda 4(g3),g3 # post-increment src word addr
bl.f Lcase_3_cloop # branch if < four bytes left to move
scanbyte 0,g1 # check for null byte
mov MSW,LSW # move msw to lsw
ld (g3),MSW # pre-fetch msw of operand for double shift
bo.f Lcase_3_cloop # branch if word contains null byte
subi 4,g2,g2 # decrease max_byte count by the 4 bytes moved
st g1,(g4) # store 4 bytes to dest
addo 4,g4,g4 # post-increment dest ptr
b Lcase_3_wloop2
Lcase_4:
subo g14,0,g14 # adjust shift count for big endian
#else
Lcase_4:
#endif
ld (g3),MSW # fetch msw of operand for double shift
Lcase_3_wloop:
cmpi g2,4 # less than four bytes to move?
eshro g14,g6,g1 # extract 4 bytes of src
lda 4(g3),g3 # post-increment src word addr
bl.f Lcase_3_cloop # branch if < four bytes left to move
scanbyte 0,g1 # check for null byte
mov MSW,LSW # move msw to lsw
ld (g3),MSW # pre-fetch msw of operand for double shift
bo.f Lcase_3_cloop # branch if word contains null byte
subi 4,g2,g2 # decrease max_byte count by the 4 bytes moved
st g1,(g4) # store 4 bytes to dest
addo 4,g4,g4 # post-increment dest ptr
b Lcase_3_wloop
Lexit_code:
mov 0,g14 # conform to register conventions
bx (g13) # g0 = addr of dest; g14 = 0
Lrett:
ret
/* end of strncat */
|
32bitmicro/newlib-nano-1.0
| 5,234
|
newlib/libc/machine/i960/strchr_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strch_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strchr (optimized assembler version for the CA)
src_addr = strchr (src_addr, char)
return a pointer to the first byte that contains the indicated
byte in the source string. Return null if the byte is not found.
Undefined behavior will occur if the end of the source string (i.e.
the terminating null byte) is in the last two words of the program's
allocated memory space. This is so because, in several cases, strchr
will fetch ahead. Disallowing the fetch ahead would impose a severe
performance penalty.
This program handles two cases:
1) the argument starts on a word boundary
2) the argument doesn't start on a word boundary
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine. The registers are used as follows:
g0 src ptr; upon return it is a pointer to the matching byte, or null
g1 char to seek
g2 mask to avoid unimportant bytes in first word
g3 char to seek, broadcast to all four bytes
g4 word of the source string
g5 copy of the word
g6 extracted character
g7 byte extraction mask
g13 return address
g14
*/
.globl _strchr
.globl __strchr
.leafproc _strchr, __strchr
.align 2
_strchr:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strchr:
lda 0xff,g7 # byte extraction mask
and g1,g7,g1 # make char an 8-bit ordinal
shlo 8,g1,g2 # broadcast the char to four bytes
or g1,g2,g2
shlo 16,g2,g4
cmpo g1,g7 # is char being sought 0xff?
or g4,g2,g3
lda (g14),g13 # preserve return address
notand g0,3,g5 # extract word addr of start of src
lda 0,g14 # conform to register linkage standard
and g0,3,g6 # extract byte offset of src
ld (g5),g4 # fetch word containing at least first byte
shlo 3,g6,g6 # get shift count for making mask for first word
lda 4(g5),g0 # post-increment src word pointer
subi 1,0,g5 # mask initially all ones
#if __i960_BIG_ENDIAN__
shro g6,g5,g5 # get mask for bytes needed from first word
#else
shlo g6,g5,g5 # get mask for bytes needed from first word
#endif
notor g4,g5,g4 # set unneeded bytes to all ones
be.f Lsearch_for_0xff # branch if seeking 0xff
Lsearch_for_word_with_char_or_null:
scanbyte g3,g4 # check for byte with char
lda (g4),g5 # copy word
ld (g0),g4 # fetch next word of src
bo.f Lsearch_for_char # branch if null found
scanbyte 0,g5 # check for null byte
lda 4(g0),g0 # post-increment src word pointer
bno.t Lsearch_for_word_with_char_or_null # branch if not null
Lnot_found:
mov 0,g0 # char not found. Return null
Lexit_code:
bx (g13) # g0 = addr of char in src (or null); g14 = 0
Lrett:
ret
Lsearch_for_char:
subo 5,g0,g0 # back up the byte pointer
Lsearch_for_char.a:
#if __i960_BIG_ENDIAN__
rotate 8,g5,g5 # shift word to position next byte
#endif
and g5,g7,g6 # extract byte
cmpo g1,g6 # is it char?
lda 1(g0),g0 # bump src byte ptr
#if ! __i960_BIG_ENDIAN__
shro 8,g5,g5 # shift word to position next byte
#endif
be.f Lexit_code
cmpobne.t 0,g6,Lsearch_for_char.a # quit if null comes before char
b Lnot_found
Lsearch_for_0xff:
lda 0xf0f0f0f0,g2 # make first comparison mask for char=-1 case.
or g5,g2,g2
and g4,g2,g4 # make unimportant bytes of first word 0x0f
b Lsearch_for_word_with_char_or_null
/* end of strchr */
|
32bitmicro/newlib-nano-1.0
| 8,008
|
newlib/libc/machine/i960/strcmp_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strcm_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strcmp (optimized assembler version for the CA)
result = strcmp (src1_addr, src2_addr)
compare the null terminated string pointed to by src1_addr to
the string space pointed to by src2_addr. Return 0 iff the strings
are equal, -1 if src1_addr is lexicly less than src2_addr, and 1
if it is lexicly greater.
Undefined behavior will occur if the end of either source string
(i.e. the terminating null byte) is in the last word of the program's
allocated memory space. This is so because, in several cases, strcmp
will fetch ahead one word. Disallowing the fetch ahead would impose
a severe performance penalty.
This program handles five cases:
1) both arguments start on a word boundary
2) neither are word aligned, but they are offset by the same amount
3) source1 is word aligned, source2 is not
4) source2 is word aligned, source1 is not
5) neither is word aligned, and they are offset by differing amounts
At the time of this writing, only g0 thru g7 and g14 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers are sufficient to implement the routine.
The registers are used as follows:
g0 original src1 ptr; return result
g1 src2 ptr; 0xff -- byte extraction mask
g2 src1 word ptr
g3 src2 word ptr
Little endian:
g4 lsw of src1
g5 msw of src1
g6 src2 word
g7 extracted src1
Big endian:
g4 msw of src1
g5 lsw of src1
g6 extracted src1
g7 src2 word
g13 return address
g14 shift count
*/
#if __i960_BIG_ENDIAN__
#define MSW g4
#define LSW g5
#define SRC1 g6
#define SRC2 g7
#else
#define LSW g4
#define MSW g5
#define SRC2 g6
#define SRC1 g7
#endif
.globl _strcmp
.globl __strcmp
.leafproc _strcmp, __strcmp
.align 2
_strcmp:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strcmp:
Lrestart:
notand g0,3,g2 # extract word addr of start of src1
lda (g14),g13 # preserve return address
#if __i960_BIG_ENDIAN__
cmpo g0,g2 # check alignment of src1
#endif
ld (g2),LSW # fetch word with at least first byte of src1
notand g1,3,g3 # extract word addr of start of src2
ld 4(g2),MSW # fetch second word of src1
#if __i960_BIG_ENDIAN__
bne Lsrc1_unaligned # branch if src1 is unaligned
cmpo g3,g1 # check alignment of src2
ld (g3),SRC2 # fetch word with at least first byte of src2
mov LSW,SRC1 # extract word of src1
lda 8(g2),g2 # advance src1 word addr
bne.f Lsrc2_unaligned # branch if src2 is NOT word aligned
/* src2 is word aligned */
Lwloop2: # word comparing loop
cmpo SRC2,SRC1 # compare src1 and src2 words
lda 0xff000000,g1 # byte extraction mask
mov MSW,LSW # move msw of src1 to lsw
ld (g2),MSW # pre-fetch next msw of src1
addo 4,g2,g2 # post-increment src1 addr
lda 4(g3),g3 # pre-increment src2 addr
bne.f Lcloop # branch if src1 and src2 unequal
scanbyte 0,SRC1 # check for null byte in src1 word
ld (g3),SRC2 # pre-fetch next word of src2
mov LSW,SRC1 # extract word of src1
lda 0,g0 # prepare to return zero, indicating equality
bno.t Lwloop2 # branch if null byte not encountered
/* words were equal and contained null byte */
mov 0,g14 # conform to register conventions
bx (g13) # return
Lsrc1_unaligned:
#endif
cmpo g3,g1 # check alignment of src2
ld (g3),SRC2 # fetch word with at least first byte of src2
shlo 3,g0,g14 # compute shift count for src1
#if __i960_BIG_ENDIAN__
subo g14,0,g14 # 32 - shift count for big endian.
#endif
eshro g14,g4,SRC1 # extract word of src1
lda 8(g2),g2 # advance src1 word addr
bne.f Lsrc2_unaligned # branch if src2 is NOT word aligned
/* at least src2 is word aligned */
Lwloop: # word comparing loop
cmpo SRC2,SRC1 # compare src1 and src2 words
#if __i960_BIG_ENDIAN__
lda 0xff000000,g1 # byte extraction mask
#else
lda 0xff,g1 # byte extraction mask
#endif
mov MSW,LSW # move msw of src1 to lsw
ld (g2),MSW # pre-fetch next msw of src1
addo 4,g2,g2 # post-increment src1 addr
lda 4(g3),g3 # pre-increment src2 addr
bne.f Lcloop # branch if src1 and src2 unequal
scanbyte 0,SRC1 # check for null byte in src1 word
ld (g3),SRC2 # pre-fetch next word of src2
eshro g14,g4,SRC1 # extract word of src1
lda 0,g0 # prepare to return zero, indicating equality
bno.t Lwloop # branch if null byte not encountered
/* words were equal and contained null byte */
mov 0,g14 # conform to register conventions
bx (g13) # return
Lcloop_setup: # setup for coming from Lsrc2_unaligned
mov LSW,SRC1 # restore extracted src1 word
#if __i960_BIG_ENDIAN__
lda 0xff000000,g1 # byte extraction mask
#else
lda 0xff,g1 # byte extraction mask
#endif
Lcloop: # character comparing loop
and SRC2,g1,g3 # extract next char of src2
and SRC1,g1,g0 # extract next char of src1
cmpobne.f g0,g3,.diff # check for equality
cmpo 0,g0 # check for null byte
#if __i960_BIG_ENDIAN__
shro 8,g1,g1 # shift mask for next byte
#else
shlo 8,g1,g1 # shift mask for next byte
#endif
bne.t Lcloop # branch if null not reached
/* words are equal up thru null byte */
mov 0,g14
bx (g13) # g0 = 0 (src1 == src2)
Lrett:
ret
.diff:
mov 0,g14
bl Lless_than_exit
Lgreater_than_exit:
mov 1,g0
bx (g13) # g0 = 1 (src1 > src2)
Lless_than_exit:
subi 1,0,g0
bx (g13) # g0 = -1 (src1 < src2)
Lsrc2_unaligned:
mov SRC1,LSW # retain src1 extracted word
ld 4(g3),SRC1 # fetch second word of src2
shlo 3,g1,MSW # compute shift count for src2
#if __i960_BIG_ENDIAN__
subo MSW,0,MSW # 32 - shift count for big endian.
#endif
eshro MSW,g6,SRC2 # extract word of src2
cmpo LSW,SRC2 # compare src1 and src2 words
notor g1,3,MSW # first step in computing new src1 ptr
lda 4(g3),g1 # set new src2 ptr
bne.f Lcloop_setup # first four bytes differ
scanbyte 0,LSW # check for null byte
lda (g13),g14 # prepare return pointer for Lrestart
subo MSW,g0,g0 # second (final) step in computing new src1 ptr
bno.t Lrestart # if null byte not encountered, continue
/* with both string fetches shifted such that */
/* src2 is now word aligned. */
mov 0,g14 # conform to register conventions.
lda 0,g0 # return indicator of equality.
bx (g13)
|
32bitmicro/newlib-nano-1.0
| 10,205
|
newlib/libc/machine/i960/strncpy_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "sncpy_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strncpy (optimized assembler version for the CA)
dest_addr = strncpy (dest_addr, src_addr, max_bytes)
copy the null terminated string pointed to by src_addr to
the string space pointed to by dest_addr. Return the original
dest_addr. If the source string is shorter than max_bytes,
then null-pad the destination string.
This routine will fail if the source and destination string
overlap (in particular, if the end of the source is overlapped
by the beginning of the destination). The behavior is undefined.
This is acceptable according to the draft C standard.
Undefined behavior will also occur if the end of the source string
(i.e. the terminating null byte) is in the last word of the program's
allocated memory space. This is so because, in several cases, strcpy
will fetch ahead one word. Disallowing the fetch ahead would impose
a severe performance penalty.
This program handles five cases:
1) both arguments start on a word boundary
2) neither are word aligned, but they are offset by the same amount
3) source is word aligned, destination is not
4) destination is word aligned, source is not
5) neither is word aligned, and they are offset by differing amounts
At the time of this writing, only g0 thru g7 and g13 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers, plus tricky use of g14 are sufficient
to implement the routine. The registers are used as follows:
g0 original dest ptr; not modified, so that it may be returned.
g1 src ptr; shift count
g2 max_bytes
g3 src ptr (word aligned)
g4 dest ptr (word aligned)
g5 0xff -- byte extraction mask
Little endian:
g6 lsw of double word for extraction of 4 bytes
g7 msw of double word for extraction of 4 bytes
Big endian:
g6 msw of double word for extraction of 4 bytes
g7 lsw of double word for extraction of 4 bytes
g13 return address
g14 byte extracted.
*/
#if __i960_BIG_ENDIAN__
#define MSW g6
#define LSW g7
#else
#define LSW g6
#define MSW g7
#endif
.globl _strncpy
.globl __strncpy
.leafproc _strncpy, __strncpy
.align 2
_strncpy:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strncpy:
notand g1,3,g3 # extract word addr of start of src
lda (g14),g13 # preserve return address
cmpibge.f 0,g2,Lexit_code # Lexit if number of bytes to move is <= zero.
cmpo g3,g1 # check alignment of src
ld (g3),LSW # fetch word containing at least first byte
notand g0,3,g4 # extract word addr of start of dest
lda 4(g3),g3 # advance src word addr
bne.f Lcase_245 # branch if src is NOT word aligned
Lcase_13:
cmpo g0,g4 # check alignment of dest
lda 0xff,g5 # load mask for byte extraction
subo 4,g4,g4 # store is pre-incrementing; back up dest addr
bne.f Lcase_3 # branch if dest not word aligned
Lcase_1: # src and dest are word aligned
Lcase_1_wloop: # word copying loop
cmpi g2,4 # check for fewer than four bytes to move
lda (LSW),g1 # keep a copy of the src word
addo 4,g4,g4 # pre-increment dest addr
bl.f Lcase_1_cloop.a # branch if fewer than four bytes to copy
scanbyte 0,g1 # check for null byte in src word
ld (g3),LSW # pre-fetch next word of src
subi 4,g2,g2 # decrease max_byte count by the 4 bytes moved
bo.f Lcase_1_cloop.c # branch if word contains null byte
addo 4,g3,g3 # post-increment src addr
st g1,(g4) # store word in dest string
b Lcase_1_wloop
Lcase_3_cloop.a:
Lcase_1_cloop.a: # character copying loop (max_bytes <= 3)
#if __i960_BIG_ENDIAN__
rotate 8,g1,g1 # move next byte into position for extraction
#endif
and g5,g1,g14 # extract next char
Lcase_1_cloop.b:
cmpdeci 0,g2,g2 # is max_bytes exhausted?
be.f Lexit_code # Lexit if max_bytes is exhausted
cmpo 0,g14 # check for null byte
stob g14,(g4) # store the byte in dest
#if ! __i960_BIG_ENDIAN__
shro 8,g1,g1 # move next byte into position for extraction
#endif
lda 1(g4),g4 # post-increment dest byte addr
bne.t Lcase_1_cloop.a # branch if null not reached
b Lcase_1_cloop.b
Lexit_code:
mov 0,g14 # conform to register conventions
bx (g13) # g0 = addr of dest; g14 = 0
Lrett:
ret
Lcase_1_cloop.c:
Lcase_3_cloop.c:
#if __i960_BIG_ENDIAN__
rotate 24,g5,g5 # move mask into position for testing next byte
#endif
and g5,g1,g14 # extract next char
cmpo 0,g14 # check for null byte
#if ! __i960_BIG_ENDIAN__
lda (g5),LSW # keep a copy of the current mask
shlo 8,g5,g5 # move mask into position for testing next byte
#endif
bne.t Lcase_1_cloop.c # branch if null not reached
#if __i960_BIG_ENDIAN__
subo 1,g5,g5 # null pad.
andnot g5,g1,g1 # last bytes to copy, and null pad rest of word
#else
subo 1,LSW,g5 # mask to get last bytes to copy, and null pad
and g5,g1,g1 # last bytes to copy, and null pad rest of word
#endif
st g1,(g4)
Lcase_1_zwloop: # zero word loop
cmpi g2,4 # check for fewer than four bytes to move
addo 4,g4,g4 # pre-increment dest addr
bl.f Lcase_1_cloop.b # branch if fewer than four bytes to copy
subo 4,g2,g2 # decrease max_byte count by the 4 bytes moved
st g14,(g4) # store word in dest string
b Lcase_1_zwloop
Lcase_3: # src is word aligned; dest is not
addo 8,g4,g4 # move dest word ptr to first word boundary
lda (g0),g1 # copy dest byte ptr
mov LSW,MSW # make copy of first word of src
lda 32,g14 # initialize shift count to zero (mod 32)
Lcase_25:
Lcase_3_cloop_at_start: # character copying loop for start of dest str
cmpdeci 0,g2,g2 # is max_bytes exhausted?
#if __i960_BIG_ENDIAN__
shro 24,MSW,g5 # extract next char
#else
and g5,MSW,g5 # extract next char
#endif
be.f Lexit_code # Lexit if max_bytes is exhausted
cmpo 0,g5 # check for null byte
stob g5,(g1) # store the byte in dest
addo 1,g1,g1 # post-increment dest ptr
lda 0xff,g5 # re-initialize byte extraction mask
bne.t 1f # drop thru if null byte reached (to pad)
movl 0,g6 # blank out remainder of input buffer
1:
cmpo g1,g4 # have we reached word boundary in dest yet?
#if __i960_BIG_ENDIAN__
lda -8(g14),g14 # augment the shift counter
rotate 8,MSW,MSW # move next byte into position for extraction
#else
lda 8(g14),g14 # augment the shift counter
shro 8,MSW,MSW # move next byte into position for extraction
#endif
bne.t Lcase_3_cloop_at_start # branch if reached word boundary?
ld (g3),MSW # fetch msw of operand for double shift
Lcase_4:
#if __i960_BIG_ENDIAN__
cmpobne 0,g14,Lcase_3_wloop # branch if src is still unaligned.
Lcase_3_wloop2:
cmpi g2,4 # less than four bytes to move?
lda (LSW),g1 # extract 4 bytes of src
lda 4(g3),g3 # post-increment src word addr
bl.f Lcase_3_cloop.a # branch if < four bytes left to move
scanbyte 0,g1 # check for null byte
lda (MSW),LSW # move msw to lsw
subi 4,g2,g2 # decrease max_byte count by the 4 bytes moved
ld (g3),MSW # pre-fetch msw of operand for double shift
bo.f Lcase_3_cloop.c # branch if word contains null byte
st g1,(g4) # store 4 bytes to dest
addo 4,g4,g4 # post-increment dest ptr
b Lcase_3_wloop2
#endif
Lcase_3_wloop:
cmpi g2,4 # less than four bytes to move?
eshro g14,g6,g1 # extract 4 bytes of src
lda 4(g3),g3 # post-increment src word addr
bl.f Lcase_3_cloop.a # branch if < four bytes left to move
scanbyte 0,g1 # check for null byte
lda (MSW),LSW # move msw to lsw
subi 4,g2,g2 # decrease max_byte count by the 4 bytes moved
ld (g3),MSW # pre-fetch msw of operand for double shift
bo.f Lcase_3_cloop.c # branch if word contains null byte
st g1,(g4) # store 4 bytes to dest
addo 4,g4,g4 # post-increment dest ptr
b Lcase_3_wloop
Lcase_245:
cmpo g0,g4 # check alignment of dest
ld (g3),MSW # pre-fetch second half
and 3,g1,g1 # compute shift count
lda 0xff,g5 # load mask for byte extraction
#if __i960_BIG_ENDIAN__
subo g1,4,g14 # adjust shift count for big endian.
shlo 3,g14,g14
#else
shlo 3,g1,g14
#endif
be.t Lcase_4 # branch if dest is word aligned
or g4,g1,g1 # is src earlier in word, later, or sync w/ dst
cmpo g0,g1 # < indicates first word of dest has more bytes
/* than first word of source. */
lda 4(g4),g4 # move dest word addr to first word boundary
eshro g14,g6,g5 # extract four bytes
lda (g0),g1
bg.f 1f
mov MSW,LSW
lda 4(g3),g3 # move src word addr to second word boundary
1:
mov g5,MSW
lda 0xff,g5
b Lcase_25
/* end of strncpy */
|
32bitmicro/newlib-nano-1.0
| 5,015
|
newlib/libc/machine/i960/strrchr.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strrchr.s"
#ifdef __i960_BIG_ENDIAN__
#error "This does not work in big-endian"
#endif
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strrchr (optimized assembler version for the 80960K series)
src_addr = strrchr (src_addr, char)
return a pointer to the last byte that contains the indicated
byte in the source string. Return null if the byte is not found.
Undefined behavior will occur if the end of the source string (i.e.
the terminating null byte) is in the last two words of the program's
allocated memory space. This is so because strrchr fetches ahead.
Disallowing the fetch ahead would impose a severe performance penalty.
Strategy:
Fetch the source string by words and scanbyte the words for the
char until either a word with the byte is found or the null byte is
encountered. In the former case, move through the word to find the
matching byte and save its memory address, then continue the search.
In the latter case, return the saved address, or zero (null) if none
was ever found to save.
Tactics:
1) Do NOT try to fetch the words in a word aligned manner because,
in my judgement, the performance degradation experienced due to
non-aligned accesses does NOT outweigh the time and complexity added
by the preamble that would be necessary to assure alignment. This
is supported by the intuition that most source arrays (even more
true of most big source arrays) will be word aligned to begin with.
*/
.globl _strrchr
.globl __strrchr
.leafproc _strrchr, __strrchr
.align 2
_strrchr:
#ifdef __PIC
lda Lrett-(.+8)(ip),g14
#else
lda Lrett,g14
#endif
__strrchr:
ld (g0),g4 # fetch first word
lda 0xff,g7 # byte extraction mask
and g1,g7,g1 # make char an 8-bit ordinal
shlo 8,g1,g2 # broadcast the char to four bytes
or g1,g2,g2
shlo 16,g2,g5
or g2,g5,g3
mov g14,g13 # preserve return address
addo 4,g0,g2 # post-increment src pointer
mov 1,g0 # prepare to return null pointer
mov g3,g6 # prepare to return null pointer
Lsearch_for_word_with_char_or_null:
mov g4,g5 # copy word
scanbyte 0,g5 # check for null byte
ld (g2),g4 # fetch next word of src
bo Lword_has_null # branch if null found
scanbyte g3,g5 # check for byte with char
addo 4,g2,g2 # post-increment src pointer
bno Lsearch_for_word_with_char_or_null # branch if no copy of char
mov g5,g6 # save word that has char in it (at least once)
subo 4,g2,g0 # save addr of byte after word with char
b Lsearch_for_word_with_char_or_null
Lword_has_null:
subo 4,g2,g2 # move src pointer back to word with null
Lfind_null:
addo 1,g2,g2 # advance src pointer to byte after current
and g7,g5,g14 # extract next byte
cmpo g1,g14 # is current byte char?
shro 8,g5,g5 # position next byte for extraction
bne 1f # skip if not char sought after
mov g2,g0 # save addr of byte after char
mov g3,g6 # save word of all char to short circuit search
1: cmpobne 0,g14,Lfind_null # is current byte null?
Lfind_last_char:
rotate 8,g6,g6 # position next highest byte
and g7,g6,g5 # extract byte
subo 1,g0,g0 # move pointer to that byte (or nullify)
cmpobne g5,g1,Lfind_last_char # branch if not at char
bx (g13) # g0 = addr of char in src (or null); g14 = 0
Lrett:
ret
/* end of strrchr */
|
32bitmicro/newlib-nano-1.0
| 8,544
|
newlib/libc/machine/i960/strncmp_ca.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "sncmp_ca.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strncmp (optimized assembler version for the CA)
result = strncmp (src1_addr, src2_addr, max_bytes)
compare the null terminated string pointed to by src1_addr to
the string space pointed to by src2_addr. Return 0 iff the strings
are equal, -1 if src1_addr is lexicly less than src2_addr, and 1
if it is lexicly greater. Do not compare more than max_bytes bytes.
Undefined behavior will occur if the end of either source string
(i.e. the terminating null byte) is in the last word of the program's
allocated memory space. This is so because, in several cases, strncmp
will fetch ahead one word. Disallowing the fetch ahead would impose
a severe performance penalty.
This program handles five cases:
1) both arguments start on a word boundary
2) neither are word aligned, but they are offset by the same amount
3) source1 is word aligned, source2 is not
4) source2 is word aligned, source1 is not
5) neither is word aligned, and they are offset by differing amounts
At the time of this writing, only g0 thru g7 and g14 are available
for use in this leafproc; other registers would have to be saved and
restored. These nine registers are sufficient to implement the routine.
The registers are used as follows:
g0 original src1 ptr; extracted word; return result
g1 src2 ptr; 0xff -- byte extraction mask
g2 maximum number of bytes to compare
g3 src2 word ptr
Little endian:
g4 lsw of src1
g5 msw of src1
g6 src2 word
g7 src1 word ptr
Big endian:
g4 msw of src1
g5 lsw of src1
g6 src1 word ptr
g7 src2 word
g13 return address
g14 shift count
*/
#if __i960_BIG_ENDIAN__
#define MSW g4
#define LSW g5
#define SRC1 g6
#define SRC2 g7
#else
#define LSW g4
#define MSW g5
#define SRC2 g6
#define SRC1 g7
#endif
.globl _strncmp
.globl __strncmp
.leafproc _strncmp, __strncmp
.align 2
_strncmp:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strncmp:
Lrestart:
notand g0,3,SRC1 # extract word addr of start of src1
lda (g14),g13 # preserve return address
cmpibge.f 0,g2,Lequal_exit # return equality if number of bytes to
/* compare is none. */
#if __i960_BIG_ENDIAN__
cmpo g0,SRC1 # check alignment of src1
#endif
ld (SRC1),LSW # fetch word with at least first byte of src1
notand g1,3,g3 # extract word addr of start of src2
ld 4(SRC1),MSW # fetch second word of src1
#if __i960_BIG_ENDIAN__
bne Lsrc1_unaligned # branch if src1 is unaligned
cmpo g3,g1 # check alignment of src2
ld (g3),SRC2 # fetch word with at least first byte of src2
shlo 3,g0,g14 # compute shift count for src1
subo g14,0,g14 # adjust shift count for big endian
lda 8(SRC1),SRC1 # advance src1 word addr
bne.f Lsrc2_unaligned # branch if src2 is NOT word aligned
/* src2 is word aligned */
mov LSW,g0
Lwloop2: # word comparing loop
cmpo SRC2,g0 # compare src1 and src2 words
lda 0xff000000,g1 # byte extraction mask
mov MSW,LSW # move msw of src1 to lsw
ld (SRC1),MSW # pre-fetch next msw of src1
addo 4,SRC1,SRC1 # post-increment src1 addr
lda 4(g3),g3 # pre-increment src2 addr
bne.f Lcloop # branch if src1 and src2 unequal
scanbyte 0,g0 # check for null byte in src1 word
ld (g3),SRC2 # pre-fetch next word of src2
mov LSW,g0 # extract word of src1
subi 4,g2,g2 # decrement maximum byte count
bo.f Lequal_exit # branch if null byte encountered
cmpibl.t 0,g2,Lwloop2 # branch if max_bytes not reached yet
b Lequal_exit # strings were equal up through max_bytes
Lsrc1_unaligned:
#endif
cmpo g3,g1 # check alignment of src2
ld (g3),SRC2 # fetch word with at least first byte of src2
shlo 3,g0,g14 # compute shift count for src1
#if __i960_BIG_ENDIAN__
subo g14,0,g14 # adjust shift count for big endian
#endif
eshro g14,g4,LSW # extract word of src1
lda 8(SRC1),SRC1 # advance src1 word addr
bne.f Lsrc2_unaligned # branch if src2 is NOT word aligned
/* at least src2 is word aligned */
mov LSW,g0
Lwloop: # word comparing loop
cmpo SRC2,g0 # compare src1 and src2 words
#if __i960_BIG_ENDIAN__
lda 0xff000000,g1 # byte extraction mask
#else
lda 0xff,g1 # byte extraction mask
#endif
mov MSW,LSW # move msw of src1 to lsw
ld (SRC1),MSW # pre-fetch next msw of src1
addo 4,SRC1,SRC1 # post-increment src1 addr
lda 4(g3),g3 # pre-increment src2 addr
bne.f Lcloop # branch if src1 and src2 unequal
scanbyte 0,g0 # check for null byte in src1 word
ld (g3),SRC2 # pre-fetch next word of src2
eshro g14,g4,g0 # extract word of src1
subi 4,g2,g2 # decrement maximum byte count
bo.f Lequal_exit # branch if null byte encountered
cmpibl.t 0,g2,Lwloop # branch if max_bytes not reached yet
b Lequal_exit # strings were equal up through max_bytes
Lcloop_setup: # setup for coming from Lsrc2_unaligned
mov LSW,g0 # restore extracted src1 word
#if __i960_BIG_ENDIAN__
lda 0xff000000,g1 # byte extraction mask
#else
lda 0xff,g1 # byte extraction mask
#endif
Lcloop: # character comparing loop
and SRC2,g1,g3 # extract next char of src2
and g0,g1,LSW # extract next char of src1
cmpobne.f LSW,g3,.diff # check for equality
cmpo 0,LSW # check for null byte
#if __i960_BIG_ENDIAN__
shro 8,g1,g1 # shift mask for next byte
#else
shlo 8,g1,g1 # shift mask for next byte
#endif
subi 1,g2,g2 # decrement character counter
bne.t Lcloop # branch if null not reached
/* words are equal up thru null byte */
Lequal_exit:
mov 0,g14 # conform to register conventions
lda 0,g0 # return zero, indicating equality
bx (g13) # return
Lrett:
ret
.diff:
mov 0,g14
bl Lless_than_exit
Lgreater_than_exit:
cmpibge.f 0,g2,Lequal_exit # branch if difference is beyond max_bytes
mov 1,g0
bx (g13) # g0 = 1 (src1 > src2)
Lless_than_exit:
cmpibge.f 0,g2,Lequal_exit # branch if difference is beyond max_bytes
subi 1,0,g0
bx (g13) # g0 = -1 (src1 < src2)
Lsrc2_unaligned:
notor g1,3,g14 # first step in computing new src1 ptr
ld 4(g3),SRC1 # fetch second word of src2
shlo 3,g1,MSW # compute shift count for src2
#if __i960_BIG_ENDIAN__
subo MSW,0,MSW # adjust shift count for big endian
#endif
eshro MSW,g6,SRC2 # extract word of src2
cmpo LSW,SRC2 # compare src1 and src2 words
lda 4(g3),g1 # set new src2 ptr
bne.f Lcloop_setup # first four bytes differ
scanbyte 0,LSW # check for null byte
subo g14,g0,g0 # second (final) step in computing new src1 ptr
addi g14,g2,g2 # compute new max_bytes too
lda (g13),g14 # prepare return pointer for Lrestart
bno.t Lrestart # if null byte not encountered, continue
/* with both string fetches shifted such that*/
/* src2 is now word aligned.*/
mov 0,g14 # conform to register conventions.
lda 0,g0 # return indicator of equality.
bx (g13)
|
32bitmicro/newlib-nano-1.0
| 4,835
|
newlib/libc/machine/i960/memchr.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "memchr.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure memchr (optimized assembler version for the 80960K series)
src_addr = memchr (src_addr, char, max_bytes)
searching from src_addr for a span of max_bytes bytes, return a
pointer to the first byte in the source array that contains the
indicated char. Return null if the char is not found.
Undefined behavior will occur if the last byte of the source array
is in the last two words of the program's allocated memory space.
This is so because memchr fetches ahead. Disallowing the fetch
ahead would impose a severe performance penalty.
Strategy:
Fetch the source array by words and scanbyte the words for the
char until either a word with the byte is found or max_bytes is
exhausted. In the former case, move through the word to find the
matching byte and return its memory address. In the latter case,
return zero (null).
Tactics:
1) Do NOT try to fetch the words in a word aligned manner because,
in my judgement, the performance degradation experienced due to
non-aligned accesses does NOT outweigh the time and complexity added
by the preamble that would be necessary to assure alignment. This
is supported by the intuition that most source arrays (even more
true of most big source arrays) will be word aligned to begin with.
2) Rather than decrementing max_bytes to zero, I calculate the
address of the byte after the last byte of the source array, and
quit when the source byte pointer passes that. Refining, actually
I calculate the address of the fifth byte after the last byte of
the source array, because the source byte pointer is ahead of the
actual examination point due to fetch ahead.
*/
.globl _memchr
.globl __memchr
.leafproc _memchr, __memchr
.align 2
_memchr:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__memchr:
mov g14,g13 # preserve return address
lda 0xff,g7 # byte extraction mask
and g1,g7,g1 # make char an 8-bit ordinal
mov 0,g14 # conform to register linkage standard
cmpibge 0,g2,Lnot_found # do nothing if max_bytes <= 0
addo 4,g0,g6 # post-increment src word pointer
addo g2,g6,g2 # compute ending address from start and len
ld (g0),g4 # fetch first word
shlo 8,g1,g3 # broadcast the char to four bytes
or g1,g3,g3
shlo 16,g3,g5
or g3,g5,g3
Lsearch_for_word_with_char:
mov g4,g5 # keep a copy of word
scanbyte g3,g5 # check for byte with char
ld (g6),g4 # fetch next word of src
bo Lsearch_for_char # branch if null found
addo 4,g6,g6 # post-increment src word pointer
cmpobge g2,g6,Lsearch_for_word_with_char # branch if max_bytes > 3
Lnot_found:
mov 0,g0 # char not found. Return null
bx (g13) # g0 = addr of char in src (or null); g14 = 0
Lrett:
ret
Lsearch_for_char:
cmpobe.f g6,g2,Lnot_found # quit if max_bytes exhausted
and g5,g7,g0 # extract byte
cmpo g1,g0 # is it char?
addo 1,g6,g6 # bump src byte ptr
shro 8,g5,g5 # shift word to position next byte
bne.t Lsearch_for_char
subo 5,g6,g0 # back up the byte pointer
bx (g13)
/* end of memchr */
|
32bitmicro/newlib-nano-1.0
| 4,628
|
newlib/libc/machine/i960/memcmp.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "memcmp.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure memcmp (optimized assembler version for the 80960K series)
result = memcmp (src1_addr, src2_addr, max_bytes)
compare the byte array pointed to by src1_addr to the byte array
pointed to by src2_addr. Return 0 iff the arrays are equal, -1 iff
src1_addr is lexicographically less than src2_addr, and 1 iff it is
lexicographically greater. Do not compare more than max_bytes bytes.
Undefined behavior will occur if the end of either source array
is in the last two words of the program's allocated memory space.
This is so because memcmp fetches ahead. Disallowing the fetch ahead
would impose a severe performance penalty.
Strategy:
Fetch the source strings by words and compare the words until either
a differing word is found or max_bytes is exhausted. In the former
case, move through the words to find the differing byte and return
plus or minus one, appropriately. In the latter case, return zero
(equality).
Tactics:
1) Do NOT try to fetch the words in a word aligned manner because,
in my judgement, the performance degradation experienced due to
non-aligned accesses does NOT outweigh the time and complexity added
by the preamble that would be necessary to assure alignment. This
is supported by the intuition that most source arrays (even more
true of most big source arrays) will be word aligned to begin with.
2) Rather than decrementing max_bytes to zero, I calculate the
address of the byte after the last byte of the source_1 array, and
quit when the source byte pointer passes that.
*/
.globl _memcmp
.globl __memcmp
.leafproc _memcmp,__memcmp
.align 2
_memcmp:
#ifndef __PIC
lda .Lrett,g14
#else
lda .Lrett-(.+8)(ip),g14
#endif
__memcmp:
mov g14,g13 # preserve return address
ldconst 0,g14 # conform to register conventions
cmpibge 0,g2,Lequal_exit # quit if max_bytes <= 0
addo g0,g2,g2 # calculate byte addr of byte after last in src1
.Lwloop:
cmpo g0,g2
ld (g0), g5 # fetch word of source_1
bge Lequal_exit # quit (equal) if max_bytes exhausted
ld (g1), g3 # fetch word of source_2
addo 4,g0,g0 # post-increment source_1 byte ptr
addo 4,g1,g1 # post-increment source_2 byte ptr
cmpobe g5,g3,.Lwloop # branch if source words are equal
ldconst 0xff,g4 # byte extraction mask
subo 4,g0,g0 # back up src1 pointer
.Lcloop: and g4,g5,g7 # extract and compare individual bytes
and g4,g3,g6
cmpobne g7,g6,.diff # branch if they are different
shlo 8,g4,g4 # position mask for next extraction
addo 1,g0,g0
cmpobl g0,g2,.Lcloop # quit if max_bytes is exhausted
Lequal_exit:
mov 0,g0
bx (g13)
.Lrett:
ret
.diff: bl .neg # arrays differ at current byte.
/* return 1 or -1 appropriately */
mov 1,g0
bx (g13)
.neg: subi 1,0,g0
.Lexit:
bx (g13)
/* end or memcmp */
|
32bitmicro/newlib-nano-1.0
| 4,046
|
newlib/libc/machine/i960/strlen.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strlen.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strlen (optimized assembler version for the 80960K series)
src_addr = strlen (src_addr)
return the number of bytes that precede the null byte in the
string pointed to by src_addr.
Undefined behavior will occur if the end of the source string (i.e.
the terminating null byte) is in the last four words of the program's
allocated memory space. This is so because strlen fetches ahead
several words. Disallowing the fetch ahead would impose a severe
performance penalty.
Strategy:
Fetch the source array by long-words and scanbyte the words for the
null byte until found. Examine the word in which the null byte is
found, to determine its actual position, and return the length.
Tactics:
1) Do NOT try to fetch the words in a word aligned manner because,
in my judgement, the performance degradation experienced due to
non-aligned accesses does NOT outweigh the time and complexity added
by the preamble that would be necessary to assure alignment. This
is supported by the intuition that many source strings will be word
aligned to begin with.
*/
.globl _strlen
.globl __strlen
.leafproc _strlen, __strlen
.align 2
_strlen:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strlen:
mov g14,g13 # preserve return address
ldl (g0),g4 # fetch first two words
addo 8,g0,g2 # post-increment src word pointer
lda 0xff,g3 # byte extraction mask
Lsearch_for_word_with_null_byte:
scanbyte 0,g4 # check for null byte
mov g5,g7 # copy second word
bo.f Lsearch_for_null # branch if null found
scanbyte 0,g7 # check for null byte
ldl (g2),g4 # fetch next pair of word of src
addo 8,g2,g2 # post-increment src word pointer
bno Lsearch_for_word_with_null_byte # branch if null not found yet
subo 4,g2,g2 # back up the byte pointer
mov g7,g4 # move word with null to search word
Lsearch_for_null:
subo 9,g2,g2 # back up the byte pointer
Lsearch_for_null.a:
and g4,g3,g14 # extract byte
cmpo 0,g14 # is it null?
addo 1,g2,g2 # bump src byte ptr
shro 8,g4,g4 # shift word to position next byte
bne Lsearch_for_null.a
Lexit_code:
subo g0,g2,g0 # calculate string length
bx (g13) # g0 = addr of src; g14 = 0
Lrett:
ret
/* end of strlen */
|
32bitmicro/newlib-nano-1.0
| 4,364
|
newlib/libc/machine/i960/strchr.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strchr.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strchr (optimized assembler version for the 80960K series)
src_addr = strchr (src_addr, char)
return a pointer to the first byte that contains the indicated
byte in the source string. Return null if the byte is not found.
Undefined behavior will occur if the end of the source string (i.e.
the terminating null byte) is in the last two words of the program's
allocated memory space. This is so because strchr fetches ahead.
Disallowing the fetch ahead would impose a severe performance penalty.
Strategy:
Fetch the source string by words and scanbyte the words for the
char until either a word with the byte is found or the null byte is
encountered. In the former case, move through the word to find the
matching byte and return its memory address. In the latter case,
return zero (null).
Tactics:
1) Do NOT try to fetch the words in a word aligned manner because,
in my judgement, the performance degradation experienced due to
non-aligned accesses does NOT outweigh the time and complexity added
by the preamble that would be necessary to assure alignment. This
is supported by the intuition that most source arrays (even more
true of most big source arrays) will be word aligned to begin with.
*/
.globl _strchr
.globl __strchr
.leafproc _strchr, __strchr
.align 2
_strchr:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strchr:
ld (g0),g4 # fetch first word
lda 0xff,g7 # byte extraction mask
and g1,g7,g1 # make char an 8-bit ordinal
shlo 8,g1,g2 # broadcast the char to four bytes
or g1,g2,g2
shlo 16,g2,g5
or g2,g5,g3
mov g14,g13 # preserve return address
addo 4,g0,g0 # post-increment src pointer
mov 0,g14 # conform to register linkage standard
Lsearch_for_word_with_char_or_null:
mov g4,g5 # copy word
scanbyte g3,g5 # check for byte with char
ld (g0),g4 # fetch next word of src
bo Lsearch_for_char # branch if char found
scanbyte 0,g5 # check for null byte
addo 4,g0,g0 # post-increment src pointer
bno Lsearch_for_word_with_char_or_null # branch if not null
Lnot_found:
mov 0,g0 # char not found. Return null
Lexit_code:
bx (g13) # g0 = addr of char in src (or null); g14 = 0
Lrett:
ret
Lsearch_for_char:
subo 5,g0,g0 # back up the byte pointer
Lsearch_for_char.a:
and g5,g7,g6 # extract byte
cmpo g1,g6 # is it char?
addo 1,g0,g0 # bump src byte ptr
shro 8,g5,g5 # shift word to position next byte
be Lexit_code
cmpobne 0,g6,Lsearch_for_char.a # quit if null comes before char
b Lnot_found
/* end of strchr */
|
32bitmicro/newlib-nano-1.0
| 4,396
|
newlib/libc/machine/i960/strcmp.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strcmp.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strcmp (optimized assembler version for the 80960K Series)
result = strcmp (src1_addr, src2_addr)
compare the null terminated string pointed to by src1_addr to
the string pointed to by src2_addr. Return 0 iff the strings
are equal, -1 if src1_addr is lexicographically less than src2_addr,
and 1 if it is lexicographically greater.
Undefined behavior will occur if the end of either source string
(i.e. the terminating null byte) is in the last two words of the
program's allocated memory space. This is so because strcmp fetches
ahead. Disallowing the fetch ahead would impose a severe performance
penalty.
Strategy:
Fetch the source strings by words and compare the words until either
differing words are found or the null byte is encountered. In either
case, move through the word until either the differing byte if found,
in which case return -1 or 1 appropriately; or the null byte is
encountered, in which case, return zero (equality).
Tactics:
1) Do NOT try to fetch the words in a word aligned manner because,
in my judgement, the performance degradation experienced due to
non-aligned accesses does NOT outweigh the time and complexity added
by the preamble and convoluted body that would be necessary to assure
alignment. This is supported by the intuition that many source
strings will be word aligned to begin with.
*/
.globl _strcmp
.globl __strcmp
.leafproc _strcmp,__strcmp
.align 2
_strcmp:
#ifndef __PIC
lda .Lrett,g14
#else
lda .Lrett-(.+8)(ip),g14
#endif
__strcmp:
ld (g0), g5 # fetch first word of source_1
mov g14,g7 # preserve return address
ldconst 0,g14 # conform to register conventions
ldconst 0xff,g4 # byte extraction mask
.Lwloop:
addo 4,g0,g0 # post-increment source_1 byte ptr
ld (g1), g3 # fetch word of source_2
scanbyte 0,g5 # does word have a null byte?
mov g5,g2 # save a copy of the source_1 word
be .Lcloop # branch if null byte encountered
cmpo g2,g3 # are the source words the same?
addo 4,g1,g1 # post-increment source_2 byte ptr
ld (g0), g5 # fetch ahead next word of source_1
be .Lwloop # fall thru if words are unequal
.Lcloop: and g4,g2,g5 # extract and compare individual bytes
and g4,g3,g6
cmpobne g5,g6,.diff # if they differ, go return 1 or -1
cmpo 0,g6 # they are the same. Are they null?
shlo 8,g4,g4 # position mask for next extraction
bne .Lcloop # loop if null not encountered
mov 0,g0 # return equality
bx (g7)
.Lrett:
ret
.diff: bl .neg
mov 1,g0
bx (g7)
.neg: subi 1,0,g0
.Lexit:
bx (g7)
|
32bitmicro/newlib-nano-1.0
| 5,675
|
newlib/libc/machine/i960/strncpy.S
|
/*******************************************************************************
*
* Copyright (c) 1993 Intel Corporation
*
* Intel hereby grants you permission to copy, modify, and distribute this
* software and its documentation. Intel grants this permission provided
* that the above copyright notice appears in all copies and that both the
* copyright notice and this permission notice appear in supporting
* documentation. In addition, Intel grants this permission provided that
* you prominently mark as "not part of the original" any modifications
* made to this software or documentation, and that the name of Intel
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software or the documentation without specific,
* written prior permission.
*
* Intel Corporation provides this AS IS, WITHOUT ANY WARRANTY, EXPRESS OR
* IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY
* OR FITNESS FOR A PARTICULAR PURPOSE. Intel makes no guarantee or
* representations regarding the use of, or the results of the use of,
* the software and documentation in terms of correctness, accuracy,
* reliability, currentness, or otherwise; and you rely on the software,
* documentation and results solely at your own risk.
*
* IN NO EVENT SHALL INTEL BE LIABLE FOR ANY LOSS OF USE, LOSS OF BUSINESS,
* LOSS OF PROFITS, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES
* OF ANY KIND. IN NO EVENT SHALL INTEL'S TOTAL LIABILITY EXCEED THE SUM
* PAID TO INTEL FOR THE PRODUCT LICENSED HEREUNDER.
*
******************************************************************************/
.file "strncpy.s"
#ifdef __PIC
.pic
#endif
#ifdef __PID
.pid
#endif
/*
* (c) copyright 1988,1993 Intel Corp., all rights reserved
*/
/*
procedure strncpy (optimized assembler version for the 80960K Series)
dest_addr = strncpy (dest_addr, src_addr, max_bytes)
copy the null terminated string pointed to by src_addr to the
string pointed to by dest_addr. Return the original dest_addr.
If the source string is shorter than max_bytes, then null-pad
the destination string. If it is longer than max_bytes, the
copy stops at max_bytes bytes (and no terminating null appears
in the destination string).
This routine will fail if the source and destination string
overlap (in particular, if the end of the source is overlapped
by the beginning of the destination). The behavior is undefined.
This is acceptable according to the draft C standard.
Undefined behavior will also occur if the end of the source string
(i.e. the terminating null byte) is in the last two words of the
program's allocated memory space. This is so because strncpy fetches
ahead. Disallowing the fetch ahead would impose a severe performance
penalty.
Strategy:
Fetch and store the strings by words and go to a character move loop
as soon as a null byte is encountered. If max_bytes is exhausted
first, then terminate after moving only max_bytes (with the last
0, 1, 2, or 3 bytes moved as single bytes, not as a word).
Otherwise, the character move loop moves the last bytes or the
source string, and then null-pads the destination string until
max_bytes is exhausted.
Tactics:
1) Do NOT try to fetch the words in a word aligned manner because,
in my judgement, the performance degradation experienced due to
non-aligned accesses does NOT outweigh the time and complexity added
by the preamble and convoluted body that would be necessary to assure
alignment.
2) When the null byte is encountered in a source word, null out the
higher-numbered bytes in that word, store the word in the destination,
and go to the word null-padder, which may eventually go to the byte
null-padder.
*/
.globl _strncpy
.globl __strncpy
.leafproc _strncpy,__strncpy
.align 2
_strncpy:
#ifndef __PIC
lda Lrett,g14
#else
lda Lrett-(.+8)(ip),g14
#endif
__strncpy:
mov g14, g13
cmpibge 0,g2,Lexit # quit early if max_bytes <= 0
ld (g1), g7 # fetch the first word of the source
mov g0, g5
lda 0xff, g3 # byte extraction mask
addo g1, g2, g6
addo g2, g5, g2
Lwloop: # word copying loop
addo 4, g1, g1 # post-increment source ptr
cmpo g6, g1 # max_bytes < 4 ?
mov g7, g4 # keep a copy of source word
bl Lcloop.a # if less than four bytes to go, go to char loop
scanbyte 0, g4 # null byte found?
ld (g1), g7 # pre-fetch next word of the source
be Lcloop.c # go to char loop if null encountered
st g4, (g5) # store current word
addo 4, g5, g5 # post-increment destination ptr
b Lwloop
Lcloop.a: # character copying loop (max_bytes < 3)
and g3, g4, g14 # extract byte
Lcloop.b:
cmpo g2, g5 # max_bytes <= 0 ?
shro 8, g4, g4 # position word to extract next byte
be Lexit # exit if max_bytes exhausted
cmpo 0, g14 # is it null?
stob g14, (g5) # store it
addo 1, g5, g5 # post-increment dest ptr
bne Lcloop.a # branch if we are NOT null padding
b Lcloop.b # branch if we are null padding
Lexit:
mov 0, g14
bx (g13) # g0 = dest string address; g14 = 0
Lrett:
ret
Lcloop.c: # character copying loop
and g3, g4, g14 # extract byte
cmpo 0, g14 # is it null?
mov g3, g7 # save mask
shlo 8, g3, g3 # shift mask to next byte position
bne Lcloop.c # loop until null found
subo 1, g7, g3 # mask to null pad after null byte
and g3, g4, g4 # null-out stuff after null byte
st g4, (g5) # store last part of src and first of null-pad
subo 8,g2,g6 # adjust max_byte counter
Lzwloop:
cmpo g5, g6 # max_bytes < 4 ?
addo 4, g5, g5
bg Lcloop.b # if so, goto character loop
st g14, (g5) # store four null bytes
b Lzwloop
/* end of strncpy */
|
32bitmicro/newlib-nano-1.0
| 3,945
|
newlib/libc/machine/xscale/setjmp.S
|
/* This is a simple version of setjmp and longjmp.
Nick Clifton, Cygnus Solutions, 13 June 1997. */
/* ANSI concatenation macros. */
#define CONCAT(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a##b
#ifndef __USER_LABEL_PREFIX__
#error __USER_LABEL_PREFIX__ not defined
#endif
#define SYM(x) CONCAT (__USER_LABEL_PREFIX__, x)
#ifdef __ELF__
#define TYPE(x) .type SYM(x),function
#define SIZE(x) .size SYM(x), . - SYM(x)
#else
#define TYPE(x)
#define SIZE(x)
#endif
/* Arm/Thumb interworking support:
The interworking scheme expects functions to use a BX instruction
to return control to their parent. Since we need this code to work
in both interworked and non-interworked environments as well as with
older processors which do not have the BX instruction we do the
following:
Test the return address.
If the bottom bit is clear perform an "old style" function exit.
(We know that we are in ARM mode and returning to an ARM mode caller).
Otherwise use the BX instruction to perform the function exit.
We know that we will never attempt to perform the BX instruction on
an older processor, because that kind of processor will never be
interworked, and a return address with the bottom bit set will never
be generated.
In addition, we do not actually assemble the BX instruction as this would
require us to tell the assembler that the processor is an ARM7TDMI and
it would store this information in the binary. We want this binary to be
able to be linked with binaries compiled for older processors however, so
we do not want such information stored there.
If we are running using the APCS-26 convention however, then we never
test the bottom bit, because this is part of the processor status.
Instead we just do a normal return, since we know that we cannot be
returning to a Thumb caller - the Thumb does not support APCS-26.
Function entry is much simpler. If we are compiling for the Thumb we
just switch into ARM mode and then drop through into the rest of the
function. The function exit code will take care of the restore to
Thumb mode. */
#ifdef __APCS_26__
#define RET movs pc, lr
#else
#define RET tst lr, #1; \
moveq pc, lr ; \
.word 0xe12fff1e /* bx lr */
#endif
#ifdef __thumb__
#define MODE .thumb_func
.macro PROLOGUE name
.code 16
bx pc
nop
.code 32
SYM (.arm_start_of.\name):
.endm
#else
#define MODE .code 32
.macro PROLOGUE name
.endm
#endif
.macro FUNC_START name
.text
.align 2
MODE
.globl SYM (\name)
TYPE (\name)
SYM (\name):
PROLOGUE \name
.endm
.macro FUNC_END name
RET
SIZE (\name)
.endm
/* --------------------------------------------------------------------
int setjmp (jmp_buf);
-------------------------------------------------------------------- */
FUNC_START setjmp
/* Save all the callee-preserved registers into the jump buffer. */
stmea a1!, { v1-v7, fp, ip, sp, lr }
#if 0 /* Simulator does not cope with FP instructions yet. */
#ifndef __SOFTFP__
/* Save the floating point registers. */
sfmea f4, 4, [a1]
#endif
#endif
/* When setting up the jump buffer return 0. */
mov a1, #0
FUNC_END setjmp
/* --------------------------------------------------------------------
volatile void longjmp (jmp_buf, int);
-------------------------------------------------------------------- */
FUNC_START longjmp
/* If we have stack extension code it ought to be handled here. */
/* Restore the registers, retrieving the state when setjmp() was called. */
ldmfd a1!, { v1-v7, fp, ip, sp, lr }
#if 0 /* Simulator does not cope with FP instructions yet. */
#ifndef __SOFTFP__
/* Restore floating point registers as well. */
lfmfd f4, 4, [a1]
#endif
#endif
/* Put the return value into the integer result register.
But if it is zero then return 1 instead. */
movs a1, a2
moveq a1, #1
FUNC_END longjmp
|
32bitmicro/newlib-nano-1.0
| 7,726
|
newlib/libc/machine/sh/memcpy.S
|
!
! Fast SH memcpy
!
! by Toshiyasu Morita (tm@netcom.com)
! hacked by J"orn Rernnecke (joern.rennecke@superh.com) ("o for o-umlaut)
! SH5 code Copyright 2002 SuperH Ltd.
!
! Entry: ARG0: destination pointer
! ARG1: source pointer
! ARG3: byte count
!
! Exit: RESULT: destination pointer
! any other registers in the range r0-r7: trashed
!
! Notes: Usually one wants to do small reads and write a longword, but
! unfortunately it is difficult in some cases to concatanate bytes
! into a longword on the SH, so this does a longword read and small
! writes.
!
! This implementation makes two assumptions about how it is called:
!
! 1.: If the byte count is nonzero, the address of the last byte to be
! copied is unsigned greater than the address of the first byte to
! be copied. This could be easily swapped for a signed comparison,
! but the algorithm used needs some comparison.
!
! 2.: When there are two or three bytes in the last word of an 11-or-more
! bytes memory chunk to b copied, the rest of the word can be read
! without side effects.
! This could be easily changed by increasing the minumum size of
! a fast memcpy and the amount subtracted from r7 before L_2l_loop be 2,
! however, this would cost a few extra cyles on average.
! For SHmedia, the assumption is that any quadword can be read in its
! enirety if at least one byte is included in the copy.
!
#include "asm.h"
ENTRY(memcpy)
#if __SHMEDIA__
#define LDUAQ(P,O,D0,D1) ldlo.q P,O,D0; ldhi.q P,O+7,D1
#define STUAQ(P,O,D0,D1) stlo.q P,O,D0; sthi.q P,O+7,D1
#define LDUAL(P,O,D0,D1) ldlo.l P,O,D0; ldhi.l P,O+3,D1
#define STUAL(P,O,D0,D1) stlo.l P,O,D0; sthi.l P,O+3,D1
ld.b r3,0,r63
pta/l Large,tr0
movi 25,r0
bgeu/u r4,r0,tr0
nsb r4,r0
shlli r0,5,r0
movi (L1-L0+63*32 + 1) & 0xffff,r1
sub r1, r0, r0
L0: ptrel r0,tr0
add r2,r4,r5
ptabs r18,tr1
add r3,r4,r6
blink tr0,r63
.balign 8
L1:
/* 0 byte memcpy */
blink tr1,r63
L4_7: /* 4..7 byte memcpy cntd. */
stlo.l r2, 0, r0
or r6, r7, r6
sthi.l r5, -1, r6
stlo.l r5, -4, r6
blink tr1,r63
L2_3: /* 2 or 3 byte memcpy cntd. */
st.b r5,-1,r6
blink tr1,r63
/* 1 byte memcpy */
ld.b r3,0,r0
st.b r2,0,r0
blink tr1,r63
L8_15: /* 8..15 byte memcpy cntd. */
stlo.q r2, 0, r0
or r6, r7, r6
sthi.q r5, -1, r6
stlo.q r5, -8, r6
blink tr1,r63
/* 2 or 3 byte memcpy */
ld.b r3,0,r0
ld.b r2,0,r63
ld.b r3,1,r1
st.b r2,0,r0
pta/l L2_3,tr0
ld.b r6,-1,r6
st.b r2,1,r1
blink tr0, r63
/* 4 .. 7 byte memcpy */
LDUAL (r3, 0, r0, r1)
pta L4_7, tr0
ldlo.l r6, -4, r7
or r0, r1, r0
sthi.l r2, 3, r0
ldhi.l r6, -1, r6
blink tr0, r63
/* 8 .. 15 byte memcpy */
LDUAQ (r3, 0, r0, r1)
pta L8_15, tr0
ldlo.q r6, -8, r7
or r0, r1, r0
sthi.q r2, 7, r0
ldhi.q r6, -1, r6
blink tr0, r63
/* 16 .. 24 byte memcpy */
LDUAQ (r3, 0, r0, r1)
LDUAQ (r3, 8, r8, r9)
or r0, r1, r0
sthi.q r2, 7, r0
or r8, r9, r8
sthi.q r2, 15, r8
ldlo.q r6, -8, r7
ldhi.q r6, -1, r6
stlo.q r2, 8, r8
stlo.q r2, 0, r0
or r6, r7, r6
sthi.q r5, -1, r6
stlo.q r5, -8, r6
blink tr1,r63
Large:
ld.b r2, 0, r63
pta/l Loop_ua, tr1
ori r3, -8, r7
sub r2, r7, r22
sub r3, r2, r6
add r2, r4, r5
ldlo.q r3, 0, r0
addi r5, -16, r5
movi 64+8, r27 // could subtract r7 from that.
stlo.q r2, 0, r0
sthi.q r2, 7, r0
ldx.q r22, r6, r0
bgtu/l r27, r4, tr1
addi r5, -48, r27
pta/l Loop_line, tr0
addi r6, 64, r36
addi r6, -24, r19
addi r6, -16, r20
addi r6, -8, r21
Loop_line:
ldx.q r22, r36, r63
alloco r22, 32
addi r22, 32, r22
ldx.q r22, r19, r23
sthi.q r22, -25, r0
ldx.q r22, r20, r24
ldx.q r22, r21, r25
stlo.q r22, -32, r0
ldx.q r22, r6, r0
sthi.q r22, -17, r23
sthi.q r22, -9, r24
sthi.q r22, -1, r25
stlo.q r22, -24, r23
stlo.q r22, -16, r24
stlo.q r22, -8, r25
bgeu r27, r22, tr0
Loop_ua:
addi r22, 8, r22
sthi.q r22, -1, r0
stlo.q r22, -8, r0
ldx.q r22, r6, r0
bgtu/l r5, r22, tr1
add r3, r4, r7
ldlo.q r7, -8, r1
sthi.q r22, 7, r0
ldhi.q r7, -1, r7
ptabs r18,tr1
stlo.q r22, 0, r0
or r1, r7, r1
sthi.q r5, 15, r1
stlo.q r5, 8, r1
blink tr1, r63
#else /* ! SHMEDIA, i.e. SH1 .. SH4 / SHcompact */
#ifdef __SH5__
#define DST r2
#define SRC r3
#define COUNT r4
#define TMP0 r5
#define TMP1 r6
#define RESULT r2
#else
#define DST r4
#define SRC r5
#define COUNT r6
#define TMP0 r2
#define TMP1 r3
#define RESULT r0
#endif
#ifdef __LITTLE_ENDIAN__
! Little endian version copies with increasing addresses.
mov DST,TMP1 ! Save return value
mov #11,r0 ! Check if small number of bytes
cmp/hs r0,COUNT
! COUNT becomes src end address
SL(bf, L_small, add SRC,COUNT)
mov #1,r1
tst r1,SRC ! check if source even
SL(bt, L_even, mov COUNT,r7)
mov.b @SRC+,r0 ! no, make it even.
mov.b r0,@DST
add #1,DST
L_even: tst r1,DST ! check if destination is even
add #-3,r7
SL(bf, L_odddst, mov #2,r1)
tst r1,DST ! check if destination is 4-byte aligned
mov DST,r0
SL(bt, L_al4dst, sub SRC,r0)
mov.w @SRC+,TMP0
mov.w TMP0,@DST
! add #2,DST DST is dead here.
L_al4dst:
tst r1,SRC
bt L_al4both
mov.w @SRC+,r1
swap.w r1,r1
add #-6,r0
add #-6,r7 ! r7 := src end address minus 9.
.align 2
L_2l_loop:
mov.l @SRC+,TMP0 ! Read & write two longwords per iteration
xtrct TMP0,r1
mov.l r1,@(r0,SRC)
cmp/hs r7,SRC
mov.l @SRC+,r1
xtrct r1,TMP0
mov.l TMP0,@(r0,SRC)
bf L_2l_loop
add #-2,SRC
bra L_cleanup
add #5,r0
L_al4both:
add #-4,r0
.align 2
L_al4both_loop:
mov.l @SRC+,DST ! Read longword, write longword per iteration
cmp/hs r7,SRC
SL(bf, L_al4both_loop, mov.l DST,@(r0,SRC))
bra L_cleanup
add #3,r0
L_odddst:
tst r1,SRC
SL(bt, L_al4src, add #-1,DST)
mov.w @SRC+,r0
mov.b r0,@(1,DST)
shlr8 r0
mov.b r0,@(2,DST)
add #2,DST
L_al4src:
.align 2
L_odd_loop:
mov.l @SRC+,r0 ! Read longword, write byte, word, byte per iteration
cmp/hs r7,SRC
mov.b r0,@(1,DST)
shlr8 r0
mov.w r0,@(2,DST)
shlr16 r0
mov.b r0,@(4,DST)
SL(bf, L_odd_loop, add #4,DST)
.align 2 ! avoid nop in more frequently executed code.
L_cleanup2:
mov DST,r0
sub SRC,r0
L_cleanup:
cmp/eq COUNT,SRC
bt L_ready
.align 2
L_cleanup_loop:
mov.b @SRC+,r1
cmp/eq COUNT,SRC
mov.b r1,@(r0,SRC)
bf L_cleanup_loop
L_ready:
rts
mov TMP1,RESULT
L_small:
bra L_cleanup2
add #-1,DST
#else /* ! __LITTLE_ENDIAN__ */
! Big endian version copies with decreasing addresses.
mov DST,r0
add COUNT,r0
sub DST,SRC
mov #11,r1
cmp/hs r1,COUNT
SL(bf, L_small, add #-1,SRC)
mov SRC,TMP1
add r0,TMP1
shlr TMP1
SL(bt, L_even,
mov DST,r7)
mov.b @(r0,SRC),TMP0
add #-1,TMP1
mov.b TMP0,@-r0
L_even:
tst #1,r0
add #-1,SRC
SL(bf, L_odddst, add #8,r7)
tst #2,r0
bt L_al4dst
add #-1,TMP1
mov.w @(r0,SRC),r1
mov.w r1,@-r0
L_al4dst:
shlr TMP1
bt L_al4both
mov.w @(r0,SRC),r1
swap.w r1,r1
add #4,r7
add #-4,SRC
.align 2
L_2l_loop:
mov.l @(r0,SRC),TMP0
xtrct TMP0,r1
mov.l r1,@-r0
cmp/hs r7,r0
mov.l @(r0,SRC),r1
xtrct r1,TMP0
mov.l TMP0,@-r0
bt L_2l_loop
bra L_cleanup
add #5,SRC
nop ! avoid nop in executed code.
L_al4both:
add #-2,SRC
.align 2
L_al4both_loop:
mov.l @(r0,SRC),r1
cmp/hs r7,r0
SL(bt, L_al4both_loop,
mov.l r1,@-r0)
bra L_cleanup
add #3,SRC
nop ! avoid nop in executed code.
L_odddst:
shlr TMP1
bt L_al4src
mov.w @(r0,SRC),r1
mov.b r1,@-r0
shlr8 r1
mov.b r1,@-r0
L_al4src:
add #-2,SRC
.align 2
L_odd_loop:
mov.l @(r0,SRC),TMP0
cmp/hs r7,r0
mov.b TMP0,@-r0
shlr8 TMP0
mov.w TMP0,@-r0
shlr16 TMP0
mov.b TMP0,@-r0
bt L_odd_loop
add #3,SRC
L_cleanup:
L_small:
cmp/eq DST,r0
bt L_ready
add #1,DST
.align 2
L_cleanup_loop:
mov.b @(r0,SRC),TMP0
cmp/eq DST,r0
mov.b TMP0,@-r0
bf L_cleanup_loop
L_ready:
rts
mov r0,RESULT
#endif /* ! __LITTLE_ENDIAN__ */
#endif /* ! SHMEDIA */
|
32bitmicro/newlib-nano-1.0
| 3,695
|
newlib/libc/machine/sh/setjmp.S
|
/* We want to pretend we're in SHmedia mode, even when assembling for
SHcompact. */
#if __SH5__ == 32 && ! __SHMEDIA__
# undef __SHMEDIA__
# define __SHMEDIA__ 1
#endif
#if __SHMEDIA__
.mode SHmedia
#endif
#include "asm.h"
ENTRY(setjmp)
#if __SH5__
ptabs r18, tr0
gettr tr5, r5
gettr tr6, r6
gettr tr7, r7
st.q r2, 0*8, r18
st.q r2, 1*8, r10
st.q r2, 2*8, r11
st.q r2, 3*8, r12
st.q r2, 4*8, r13
st.q r2, 5*8, r14
st.q r2, 6*8, r15
st.q r2, 7*8, r28
st.q r2, 8*8, r29
st.q r2, 9*8, r30
st.q r2, 10*8, r31
st.q r2, 11*8, r32
st.q r2, 12*8, r33
st.q r2, 13*8, r34
st.q r2, 14*8, r35
st.q r2, 15*8, r44
st.q r2, 16*8, r45
st.q r2, 17*8, r46
st.q r2, 18*8, r47
st.q r2, 19*8, r48
st.q r2, 20*8, r49
st.q r2, 21*8, r50
st.q r2, 22*8, r51
st.q r2, 23*8, r52
st.q r2, 24*8, r53
st.q r2, 25*8, r54
st.q r2, 26*8, r55
st.q r2, 27*8, r56
st.q r2, 28*8, r57
st.q r2, 29*8, r58
st.q r2, 30*8, r59
st.q r2, 31*8, r5
st.q r2, 32*8, r6
st.q r2, 33*8, r7
#if ! __SH4_NOFPU__
fst.d r2, 34*8, dr12
fst.d r2, 35*8, dr14
fst.d r2, 36*8, dr36
fst.d r2, 37*8, dr38
fst.d r2, 38*8, dr40
fst.d r2, 39*8, dr42
fst.d r2, 40*8, dr44
fst.d r2, 41*8, dr46
fst.d r2, 42*8, dr48
fst.d r2, 43*8, dr50
fst.d r2, 44*8, dr52
fst.d r2, 45*8, dr54
fst.d r2, 46*8, dr56
fst.d r2, 47*8, dr58
fst.d r2, 48*8, dr60
fst.d r2, 49*8, dr62
#endif
movi 0, r2
blink tr0, r63
#else
#if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
add #(13*4),r4
#else
add #(9*4),r4
#endif
sts.l pr,@-r4
#if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
fmov.s fr15,@-r4 ! call saved floating point registers
fmov.s fr14,@-r4
fmov.s fr13,@-r4
fmov.s fr12,@-r4
#endif
mov.l r15,@-r4 ! call saved integer registers
mov.l r14,@-r4
mov.l r13,@-r4
mov.l r12,@-r4
mov.l r11,@-r4
mov.l r10,@-r4
mov.l r9,@-r4
mov.l r8,@-r4
rts
mov #0,r0
#endif /* __SH5__ */
ENTRY(longjmp)
#if __SH5__
ld.q r2, 0*8, r18
ptabs r18, tr0
ld.q r2, 1*8, r10
ld.q r2, 2*8, r11
ld.q r2, 3*8, r12
ld.q r2, 4*8, r13
ld.q r2, 5*8, r14
ld.q r2, 6*8, r15
ld.q r2, 7*8, r28
ld.q r2, 8*8, r29
ld.q r2, 9*8, r30
ld.q r2, 10*8, r31
ld.q r2, 11*8, r32
ld.q r2, 12*8, r33
ld.q r2, 13*8, r34
ld.q r2, 14*8, r35
ld.q r2, 15*8, r44
ld.q r2, 16*8, r45
ld.q r2, 17*8, r46
ld.q r2, 18*8, r47
ld.q r2, 19*8, r48
ld.q r2, 20*8, r49
ld.q r2, 21*8, r50
ld.q r2, 22*8, r51
ld.q r2, 23*8, r52
ld.q r2, 24*8, r53
ld.q r2, 25*8, r54
ld.q r2, 26*8, r55
ld.q r2, 27*8, r56
ld.q r2, 28*8, r57
ld.q r2, 29*8, r58
ld.q r2, 30*8, r59
ld.q r2, 31*8, r5
ld.q r2, 32*8, r6
ld.q r2, 33*8, r7
ptabs r5, tr5
ptabs r6, tr6
ptabs r7, tr7
#if ! __SH4_NOFPU__
fld.d r2, 34*8, dr12
fld.d r2, 35*8, dr14
fld.d r2, 36*8, dr36
fld.d r2, 37*8, dr38
fld.d r2, 38*8, dr40
fld.d r2, 39*8, dr42
fld.d r2, 40*8, dr44
fld.d r2, 41*8, dr46
fld.d r2, 42*8, dr48
fld.d r2, 43*8, dr50
fld.d r2, 44*8, dr52
fld.d r2, 45*8, dr54
fld.d r2, 46*8, dr56
fld.d r2, 47*8, dr58
fld.d r2, 48*8, dr60
fld.d r2, 49*8, dr62
#endif
movi 1, r2
cmvne r3, r3, r2
blink tr0, r63
#else
mov.l @r4+,r8
mov.l @r4+,r9
mov.l @r4+,r10
mov.l @r4+,r11
mov.l @r4+,r12
mov.l @r4+,r13
mov.l @r4+,r14
mov.l @r4+,r15
#if defined (__SH2E__) || defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
fmov.s @r4+,fr12 ! call saved floating point registers
fmov.s @r4+,fr13
fmov.s @r4+,fr14
fmov.s @r4+,fr15
#endif
lds.l @r4+,pr
mov r5,r0
tst r0,r0
bf retr4
movt r0
retr4: rts
nop
#endif /* __SH5__ */
|
32bitmicro/newlib-nano-1.0
| 2,524
|
newlib/libc/machine/sh/strcpy.S
|
! Entry: arg0: destination
! arg1: source
! Exit: result: destination
!
! SH5 code Copyright 2002 SuperH Ltd.
#include "asm.h"
ENTRY(strcpy)
#if __SHMEDIA__
pta/l shortstring,tr1
ldlo.q r3,0,r4
ptabs r18,tr4
shlli r3,3,r7
addi r2, 8, r0
mcmpeq.b r4,r63,r6
SHHI r6,r7,r6
bnei/u r6,0,tr1 // shortstring
pta/l no_lddst, tr2
ori r3,-8,r23
sub r2, r23, r0
sub r3, r2, r21
addi r21, 8, r20
ldx.q r0, r21, r5
pta/l loop, tr0
ori r2,-8,r22
mcmpeq.b r5, r63, r6
bgt/u r22, r23, tr2 // no_lddst
// r22 < r23 : Need to do a load from the destination.
// r22 == r23 : Doesn't actually need to load from destination,
// but still can be handled here.
ldlo.q r2, 0, r9
movi -1, r8
SHLO r8, r7, r8
mcmv r4, r8, r9
stlo.q r2, 0, r9
beqi/l r6, 0, tr0 // loop
add r5, r63, r4
addi r0, 8, r0
blink tr1, r63 // shortstring
no_lddst:
// r22 > r23: note that for r22 == r23 the sthi.q would clobber
// bytes before the destination region.
stlo.q r2, 0, r4
SHHI r4, r7, r4
sthi.q r0, -1, r4
beqi/l r6, 0, tr0 // loop
add r5, r63, r4
addi r0, 8, r0
shortstring:
#ifndef __LITTLE_ENDIAN__
pta/l shortstring2,tr1
byterev r4,r4
#endif
shortstring2:
st.b r0,-8,r4
andi r4,0xff,r5
shlri r4,8,r4
addi r0,1,r0
bnei/l r5,0,tr1
blink tr4,r63 // return
.balign 8
loop:
stlo.q r0, 0, r5
ldx.q r0, r20, r4
addi r0, 16, r0
sthi.q r0, -9, r5
mcmpeq.b r4, r63, r6
bnei/u r6, 0, tr1 // shortstring
ldx.q r0, r21, r5
stlo.q r0, -8, r4
sthi.q r0, -1, r4
mcmpeq.b r5, r63, r6
beqi/l r6, 0, tr0 // loop
add r5, r63, r4
addi r0, 8, r0
blink tr1, r63 // shortstring
#else /* ! __SHMEDIA__, i.e. SH 1..4 / SHcompact */
#ifdef __SH5__
#define DST r2
#define SRC r3
#define TMP r4
#define RESULT R2
! r0,r1,r3,r4: clobbered
#else
#define DST r4
#define SRC r5
#define TMP r2
#define RESULT r0
! r1-r2,r5: clobbered
#endif
mov DST,r0
or SRC,r0
tst #3,r0
SL(bf, L_setup_char_loop, mov DST,r0)
mov.l @SRC+,r1
mov #0,TMP
cmp/str TMP,r1
SL(bt, Longword_loop_end, sub SRC,r0)
.align 2
Longword_loop:
mov.l r1,@(r0,SRC)
mov.l @SRC+,r1
cmp/str TMP,r1
bt Longword_loop_end
mov.l r1,@(r0,SRC)
mov.l @SRC+,r1
cmp/str TMP,r1
bf Longword_loop
Longword_loop_end:
add #-4,SRC
add #3,r0
.align 2
L_char_loop:
mov.b @SRC+,r1
L_char_loop_start:
tst r1,r1
SL(bf, L_char_loop, mov.b r1,@(r0,SRC))
rts
mov DST,RESULT
L_setup_char_loop:
mov.b @SRC+,r1
bra L_char_loop_start
sub SRC,r0
#endif /* ! __SHMEDIA__ */
|
32bitmicro/newlib-nano-1.0
| 3,191
|
newlib/libc/machine/sh/memset.S
|
!
! Fast SH memset
!
! by Toshiyasu Morita (tm@netcom.com)
!
! SH5 code by J"orn Rennecke (joern.rennecke@superh.com)
! Copyright 2002 SuperH Ltd.
!
#include "asm.h"
ENTRY(memset)
#if __SHMEDIA__
pta/l multiquad, tr0
ptabs r18, tr2
andi r2, -8, r25
add r2, r4, r5
addi r5, -1, r20 // calculate end address.
andi r20, -8, r20
cmveq r4, r25, r20
bne/u r25, r20, tr0 // multiquad
! This sequence could clobber volatile objects that are in the same
! quadword as a very short char array.
! ldlo.q r2, 0, r7
! shlli r4, 2, r4
! movi -1, r8
! SHHI r8, r4, r8
! SHHI r8, r4, r8
! mcmv r7, r8, r3
! stlo.q r2, 0, r3
pta/l setlongs, tr0
movi 4, r8
bgeu/u r4, r8, tr0
pta/l endset, tr0
beqi/u r4, 0, tr0
st.b r2, 0, r3
beqi/u r4, 1, tr0
nop
st.b r2, 1, r3
beqi/l r4, 2, tr0
st.b r2,2,r3
endset: blink tr2, r63
setlongs:
mshflo.b r3, r3, r3
mperm.w r3, r63, r3 // Fill pattern now in every byte of r3
stlo.l r2, 0, r3
nop
nop
sthi.l r5, -1, r3
blink tr2, r63
multiquad:
mshflo.b r3, r3, r3
mperm.w r3, r63, r3 // Fill pattern now in every byte of r3
pta/l lastquad, tr0
stlo.q r2, 0, r3
sub r20, r25, r24
movi 64, r9
beqi/u r24, 8, tr0 // lastquad
pta/l loop, tr1
addi r20, -7*8, r8 // loop end address; This might overflow, so we need
// to use a different test before we start the loop
bgeu/u r24, r9, tr1// loop
st.q r25, 8, r3
shlri r24, 4, r24
st.q r20, -8, r3
beqi/u r24, 1, tr0 // lastquad
st.q r25, 16, r3
st.q r20, -16, r3
beqi/u r24, 2, tr0 // lastquad
st.q r25, 24, r3
st.q r20, -24, r3
lastquad:
sthi.q r5, -1, r3
blink tr2,r63
loop:
alloco r25, 32
st.q r25, 8, r3
st.q r25, 16, r3
st.q r25, 24, r3
st.q r25, 32, r3
addi r25, 32, r25
bgeu/l r8, r25, tr1 // loop
st.q r20, -40, r3
st.q r20, -32, r3
st.q r20, -24, r3
st.q r20, -16, r3
st.q r20, -8, r3
sthi.q r5, -1, r3
blink tr2,r63
#else /* ! SHMEDIA, i.e. SH1 .. SH4 / SHcompact */
! Entry: r4: destination pointer
! r5: fill value
! r6: byte count
!
! Exit: r0-r3: trashed
!
! This assumes that the first four bytes of the address space (0..3) are
! reserved - usually by the linker script. Otherwise, we would had to check
! for the case of objects of the size 12..15 at address 0..3 .
#ifdef __SH5__
#define DST r2
#define VAL r3
#define CNT r4
#define TMP r5
#else
#define DST r4
#define VAL r5
#define CNT r6
#define TMP r2
#endif
mov #12,r0 ! Check for small number of bytes
cmp/gt CNT,r0
mov DST,r0
SL(bt, L_store_byte_loop_check0, add DST,CNT)
tst #3,r0 ! Align destination
SL(bt, L_dup_bytes, extu.b r5,r5)
.balignw 4,0x0009
L_align_loop:
mov.b VAL,@r0
add #1,r0
tst #3,r0
bf L_align_loop
L_dup_bytes:
swap.b VAL,TMP ! Duplicate bytes across longword
or TMP,VAL
swap.w VAL,TMP
or TMP,VAL
add #-16,CNT
.balignw 4,0x0009
L_store_long_loop:
mov.l VAL,@r0 ! Store double longs to memory
cmp/hs CNT,r0
mov.l VAL,@(4,r0)
SL(bf, L_store_long_loop, add #8,r0)
add #16,CNT
L_store_byte_loop_check0:
cmp/eq CNT,r0
bt L_exit
.balignw 4,0x0009
L_store_byte_loop:
mov.b VAL,@r0 ! Store bytes to memory
add #1,r0
cmp/eq CNT,r0
bf L_store_byte_loop
L_exit:
rts
mov r4,r0
#endif /* ! SHMEDIA */
|
32bitmicro/newlib-nano-1.0
| 1,370
|
newlib/libc/machine/sh/strlen.S
|
! Entry: arg0: string start address
! Exit: result: length
!
! Copyright 2002 SuperH Ltd.
#include "asm.h"
ENTRY(strlen)
#if __SHMEDIA__
ldlo.q r2,0,r3
ptabs/l r18,tr0
pta/l loop,tr1
andi r2,-8,r0
shlli r2,3,r1
mcmpeq.b r3,r63,r3
SHHI r3,r1,r4
beqi/u r4,0,tr1 // loop
#ifdef __LITTLE_ENDIAN__
movi -1,r2
addi r3,-1,r4
msad.ubq r3,r4,r2
#else
shlri r3,1,r3
nsb r3,r3
shlri r3,3,r2
#endif
blink tr0,r63
loop:
ldlo.q r0,8,r3
addi r0,8,r0
ldlo.q r0,8,r63
mcmpeq.b r3,r63,r3
beqi/l r3,0,tr1 // loop
sub r0,r2,r2
#ifdef __LITTLE_ENDIAN__
addi r3,-1,r4
addi r2,-1,r2
msad.ubq r3,r4,r2
#else
shlri r3,1,r3
nsb r3,r3
shlri r3,3,r3
add r2,r3,r2
#endif
blink tr0,r63
#else /* ! __SHMEDIA__, i.e. SH 1..4 / SHcompact */
#ifdef __SH5__
#define STR_INIT r2
#define STR_ORIG r0
#define STR_COPY STR_ORIG
#define MASK r1
#define TMP r3
#define RESULT r2
! r0,r1,r3: clobbered
#else
#define STR_INIT r4
#define STR_ORIG STR_INIT
#define STR_COPY STR
#define MASK r1
#define TMP r3
#define RESULT r0
! r1,r3: clobbered
#endif
#define STR RESULT
mov #3,MASK
and STR_INIT,MASK
tst MASK,MASK
SL(bf, L_char_loop, mov STR_INIT, STR_COPY)
L_word_loop:
mov.l @STR+,TMP
cmp/str MASK,TMP
bf L_word_loop
add #-4,STR
L_char_loop:
mov.b @STR+,TMP
tst TMP,TMP
bf L_char_loop
add #-1,STR
rts
sub STR_ORIG,STR
#endif /* ! __SHMEDIA__ */
|
32bitmicro/newlib-nano-1.0
| 4,092
|
newlib/libc/machine/sh/strcmp.S
|
! SH5 code Copyright 2002 SuperH Ltd.
#include "asm.h"
ENTRY(strcmp)
#if __SHMEDIA__
ld.ub r2,0,r4
pt/l quickret0,tr0
ld.ub r3,0,r5
ptabs r18,tr2
beqi/u r4,0,tr0
ld.ub r2,1,r6
bne/u r4,r5,tr0
pt/l quickret1,tr1
ld.ub r3,1,r7
beqi/u r6,0,tr1
ld.ub r2,2,r4
bne/u r6,r7,tr1
ld.ub r3,2,r5
beqi/u r4,0,tr0
ld.ub r2,3,r6
bne/u r4,r5,tr0
ld.ub r3,3,r7
beqi/u r6,0,tr1
ld.ub r2,4,r4
bne/u r6,r7,tr1
ld.ub r3,4,r5
beqi/u r4,0,tr0
ld.ub r2,5,r6
bne/u r4,r5,tr0
ld.ub r3,5,r7
beqi/u r6,0,tr1
ld.ub r2,6,r4
bne/u r6,r7,tr1
ld.ub r3,6,r5
beqi/u r4,0,tr0
ld.ub r2,7,r6
bne/u r4,r5,tr0
ld.ub r3,7,r7
beqi/u r6,0,tr1
sub r3,r2,r3
bne/u r6,r7,tr1
andi r2,-8,r2
add r3,r2,r3
ldlo.q r3,8,r23
pt r23_zero,tr0
shlli r3,3,r22
sub r63,r22,r20
movi 0x101,r6
mperm.w r6,r63,r6
SHLO r6,r22,r7
msubs.ub r7,r23,r8
pt loop,tr1
bnei/u r8,0,tr0 // r23_zero
pt found_zero,tr0
addi r3,15,r3
andi r3,-8,r3
sub r3,r2,r3
bne/l r7,r6,tr1 // loop
/* The strings are aligned to each other. */
/* It is possible to have a loop with six cycles / iteration
by re-ordering the exit conditions, but then it needs extra
time and/or code to sort out the r4 != r5 case. */
pt al_loop,tr1
pt al_found_zero,tr0
al_loop:
ld.q r2,8,r4
ldx.q r2,r3,r5
addi r2,8,r2
mcmpeq.b r63,r4,r8
pt cmp_quad,tr3
bnei/u r8,0,tr0 // al_found_zero
beq/l r4,r5,tr1 // al_loop
blink tr3,r63 // cmp_quad
.balign 8
quickret0:
sub r4,r5,r2
blink tr2,r63
quickret1:
sub r6,r7,r2
blink tr2,r63
loop:
ld.q r2,8,r4
ldx.q r2,r3,r19
addi r2,8,r2
msubs.ub r6,r4,r8
mcmpeq.b r63,r19,r9
SHHI r19,r20,r21
or r21,r23,r5
SHLO r19,r22,r23
bne/u r8,r9,tr0 // found_zero
beq/l r4,r5,tr1 // loop
cmp_quad:
#ifdef __LITTLE_ENDIAN__
byterev r4,r4
byterev r5,r5
#endif
cmpgtu r4,r5,r6
cmpgtu r5,r4,r7
sub r6,r7,r2
blink tr2,r63
found_zero:
pt zero_now,tr0
pt cmp_quad,tr1
SHHI r9,r20,r7
bne/u r8,r7,tr0 // zero_now
bne/u r4,r5,tr1 // cmp_quad
SHLO r9,r22,r8
r23_zero:
ld.q r2,8,r4
add r23,r63,r5
zero_now:
al_found_zero:
/* We konw that one of the values has at lest one zero, and r8 holds
an 0x01 or 0xff mask for every zero found in one of the operands.
If both operands have the first zero in the same place, this mask
allows us to truncate the comparison to the valid bytes in the
strings. If the first zero is in different places, it doesn't
matter if some invalid bytes are included, since the comparison
of the zero with the non-zero will determine the outcome. */
#ifdef __LITTLE_ENDIAN__
shlli r8,8,r8
addi r8,-1,r9
andc r9,r8,r8
and r8,r4,r4
and r8,r5,r5
#else
shlri r8,1,r8
nsb r8,r8
addi r8,8,r8
andi r8,56,r8
sub r63,r8,r8
shlrd r4,r8,r4
shlrd r5,r8,r5
#endif
#ifdef __LITTLE_ENDIAN__
byterev r4,r4
byterev r5,r5
#endif
cmpgtu r4,r5,r6
cmpgtu r5,r4,r7
sub r6,r7,r2
blink tr2,r63
#else /* ! __SHMEDIA__, i.e. SH 1..4 / SHcompact */
#ifdef __SH5__
#define STR1 r2
#define STR2 r3
#define RESULT r2
#define TMP r4
#else
! Entry: r4: string1
! r5: string2
! Exit: r0: result
! r1-r2,r4-r5: clobbered
#define STR1 r4
#define STR2 r5
#define RESULT r0
#define TMP r2
#endif /* __SH5__ */
mov STR1,r0
or STR2,r0
tst #3,r0
bf L_setup_char_loop
mov #0,r0
#ifdef DELAYED_BRANCHES
mov.l @STR1+,r1
.align 2
Longword_loop:
mov.l @STR2+,TMP
cmp/str r0,r1
bt Longword_loop_end
cmp/eq r1,TMP
bt.s Longword_loop
mov.l @STR1+,r1
add #-4, STR1
Longword_loop_end:
add #-4, STR1
add #-4, STR2
L_setup_char_loop:
mov.b @STR1+,r0
.align 2
L_char_loop:
mov.b @STR2+,r1
tst r0,r0
bt L_return
cmp/eq r0,r1
bt.s L_char_loop
mov.b @STR1+,r0
add #-2,STR1
mov.b @STR1,r0
#else /* ! DELAYED_BRANCHES */
.align 2
Longword_loop:
mov.l @r4+,r1
mov.l @r5+,r2
cmp/str r0,r1
bt Longword_loop_end
cmp/eq r1,r2
bt Longword_loop
Longword_loop_end:
add #-4, r4
add #-4, r5
.align 2
L_setup_char_loop:
L_char_loop:
mov.b @r4+,r0
mov.b @r5+,r1
tst r0,r0
bt L_return
cmp/eq r0,r1
bt L_char_loop
#endif
L_return:
extu.b r0,RESULT
extu.b r1,r1
rts
sub r1,RESULT
#endif /* ! __SHMEDIA__ */
|
32bitmicro/newlib-nano-1.0
| 4,945
|
newlib/libc/machine/sh/strncpy.S
|
/* Copyright 2003 SuperH Ltd. */
#include "asm.h"
#ifdef __SH5__
#if __SHMEDIA__
#ifdef __LITTLE_ENDIAN__
#define ZPAD_MASK(src, dst) addi src, -1, dst
#else
#define ZPAD_MASK(src, dst) \
byterev src, dst; addi dst, -1, dst; byterev dst, dst
#endif
/* We assume that the destination is not in the first 16 bytes of memory.
A typical linker script will put the text section first, and as
this code is longer that 16 bytes, you have to get out of your way
to put data there. */
ENTRY(strncpy)
pt L_small, tr2
ldlo.q r3, 0, r0
shlli r3, 3, r19
mcmpeq.b r0, r63, r1
SHHI r1, r19, r7
add r2, r4, r20
addi r20, -8, r5
/* If the size is greater than 8, we know we can read beyond the first
(possibly partial) quadword, and write out a full first and last
(possibly unaligned and/or overlapping) quadword. */
bge/u r2, r5, tr2 // L_small
pt L_found0, tr0
addi r2, 8, r22
bnei/u r7, 0, tr0 // L_found0
ori r3, -8, r38
pt L_end_early, tr1
sub r2, r38, r22
stlo.q r2, 0, r0
sthi.q r2, 7, r0
sub r3, r2, r6
ldx.q r22, r6, r0
/* Before each iteration, check that we can store in full the next quad we
are about to fetch. */
addi r5, -8, r36
bgtu/u r22, r36, tr1 // L_end_early
pt L_scan0, tr1
L_scan0:
addi r22, 8, r22
mcmpeq.b r0, r63, r1
stlo.q r22, -8, r0
bnei/u r1, 0, tr0 // L_found0
sthi.q r22, -1, r0
ldx.q r22, r6, r0
bgeu/l r36, r22, tr1 // L_scan0
L_end:
// At end; we might re-read a few bytes when we fetch the last quad.
// branch mispredict, so load is ready now.
mcmpeq.b r0, r63, r1
addi r22, 8, r22
bnei/u r1, 0, tr0 // L_found0
add r3, r4, r7
ldlo.q r7, -8, r1
ldhi.q r7, -1, r7
ptabs r18, tr0
stlo.q r22, -8, r0
or r1, r7, r1
mcmpeq.b r1, r63, r7
sthi.q r22, -1, r0
ZPAD_MASK (r7, r7)
and r1, r7, r1 // mask out non-zero bytes after first zero byte
stlo.q r20, -8, r1
sthi.q r20, -1, r1
blink tr0, r63
L_end_early:
/* Check if we can store the current quad in full. */
pt L_end, tr1
add r3, r4, r7
bgtu/u r5, r22, tr1 // L_end // Not really unlikely, but gap is short.
/* If not, that means we can just proceed to process the last quad.
Two pipeline stalls are unavoidable, as we don't have enough ILP. */
ldlo.q r7, -8, r1
ldhi.q r7, -1, r7
ptabs r18, tr0
or r1, r7, r1
mcmpeq.b r1, r63, r7
ZPAD_MASK (r7, r7)
and r1, r7, r1 // mask out non-zero bytes after first zero byte
stlo.q r20, -8, r1
sthi.q r20, -1, r1
blink tr0, r63
L_found0:
// r0: string to store, not yet zero-padding normalized.
// r1: result of mcmpeq.b r0, r63, r1.
// r22: store address plus 8. I.e. address where zero padding beyond the
// string in r0 goes.
// r20: store end address.
// r5: store end address minus 8.
pt L_write0_multiquad, tr0
ZPAD_MASK (r1, r1)
and r0, r1, r0 // mask out non-zero bytes after first zero byte
stlo.q r22, -8, r0
sthi.q r22, -1, r0
andi r22, -8, r1 // Check if zeros to write fit in one quad word.
bgtu/l r5, r1, tr0 // L_write0_multiquad
ptabs r18, tr1
sub r20, r22, r1
shlli r1, 2, r1 // Do shift in two steps so that 64 bit case is
SHLO r0, r1, r0 // handled correctly.
SHLO r0, r1, r0
sthi.q r20, -1, r0
blink tr1, r63
L_write0_multiquad:
pt L_write0_loop, tr0
ptabs r18, tr1
stlo.q r22, 0, r63
sthi.q r20, -1, r63
addi r1, 8, r1
bgeu/l r5, r1, tr0 // L_write0_loop
blink tr1, r63
L_write0_loop:
st.q r1, 0 ,r63
addi r1, 8, r1
bgeu/l r5, r1, tr0 // L_write0_loop
blink tr1, r63
L_small:
// r0: string to store, not yet zero-padding normalized.
// r1: result of mcmpeq.b r0, r63, r1.
// r7: nonzero indicates relevant zero found r0.
// r2: store address.
// r3: read address.
// r4: size, max 8
// r20: store end address.
// r5: store end address minus 8.
pt L_nohi, tr0
pt L_small_storelong, tr1
ptabs r18, tr2
sub r63, r4, r23
bnei/u r7, 0, tr0 // L_nohi
ori r3, -8, r7
bge/l r23, r7, tr0 // L_nohi
ldhi.q r3, 7, r1
or r0, r1, r0
mcmpeq.b r0, r63, r1
L_nohi:
ZPAD_MASK (r1, r1)
and r0, r1, r0
movi 4, r19
bge/u r4, r19, tr1 // L_small_storelong
pt L_small_end, tr0
#ifndef __LITTLE_ENDIAN__
byterev r0, r0
#endif
beqi/u r4, 0, tr0 // L_small_end
st.b r2, 0, r0
beqi/u r4, 1, tr0 // L_small_end
shlri r0, 8, r0
st.b r2, 1, r0
beqi/u r4, 2, tr0 // L_small_end
shlri r0, 8, r0
st.b r2, 2, r0
L_small_end:
blink tr2, r63
L_small_storelong:
shlli r23, 3, r7
SHHI r0, r7, r1
#ifdef __LITTLE_ENDIAN__
shlri r1, 32, r1
#else
shlri r0, 32, r0
#endif
stlo.l r2, 0, r0
sthi.l r2, 3, r0
stlo.l r20, -4, r1
sthi.l r20, -1, r1
blink tr2, r63
#else /* SHcompact */
/* This code is optimized for size. Instruction selection is SH5 specific.
SH4 should use a different version. */
ENTRY(strncpy)
mov #0, r6
cmp/eq r4, r6
bt return
mov r2, r5
add #-1, r5
add r5, r4
loop:
bt/s found0
add #1, r5
mov.b @r3+, r1
found0:
cmp/eq r5,r4
mov.b r1, @r5
bf/s loop
cmp/eq r1, r6
return:
rts
nop
#endif /* SHcompact */
#endif /* __SH5__ */
|
32bitmicro/newlib-nano-1.0
| 5,328
|
newlib/libc/machine/arm/setjmp.S
|
/* This is a simple version of setjmp and longjmp.
Nick Clifton, Cygnus Solutions, 13 June 1997. */
/* ANSI concatenation macros. */
#define CONCAT(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a##b
#ifndef __USER_LABEL_PREFIX__
#error __USER_LABEL_PREFIX__ not defined
#endif
#define SYM(x) CONCAT (__USER_LABEL_PREFIX__, x)
#ifdef __ELF__
#define TYPE(x) .type SYM(x),function
#define SIZE(x) .size SYM(x), . - SYM(x)
#else
#define TYPE(x)
#define SIZE(x)
#endif
/* Arm/Thumb interworking support:
The interworking scheme expects functions to use a BX instruction
to return control to their parent. Since we need this code to work
in both interworked and non-interworked environments as well as with
older processors which do not have the BX instruction we do the
following:
Test the return address.
If the bottom bit is clear perform an "old style" function exit.
(We know that we are in ARM mode and returning to an ARM mode caller).
Otherwise use the BX instruction to perform the function exit.
We know that we will never attempt to perform the BX instruction on
an older processor, because that kind of processor will never be
interworked, and a return address with the bottom bit set will never
be generated.
In addition, we do not actually assemble the BX instruction as this would
require us to tell the assembler that the processor is an ARM7TDMI and
it would store this information in the binary. We want this binary to be
able to be linked with binaries compiled for older processors however, so
we do not want such information stored there.
If we are running using the APCS-26 convention however, then we never
test the bottom bit, because this is part of the processor status.
Instead we just do a normal return, since we know that we cannot be
returning to a Thumb caller - the Thumb does not support APCS-26.
Function entry is much simpler. If we are compiling for the Thumb we
just switch into ARM mode and then drop through into the rest of the
function. The function exit code will take care of the restore to
Thumb mode.
For Thumb-2 do everything in Thumb mode. */
#if defined(__ARM_ARCH_6M__)
/* ARMv6-M has to be implemented in Thumb mode. */
.thumb
.thumb_func
.globl SYM (setjmp)
TYPE (setjmp)
SYM (setjmp):
/* Save registers in jump buffer. */
stmia r0!, {r4, r5, r6, r7}
mov r1, r8
mov r2, r9
mov r3, r10
mov r4, fp
mov r5, sp
mov r6, lr
stmia r0!, {r1, r2, r3, r4, r5, r6}
sub r0, r0, #40
/* Restore callee-saved low regs. */
ldmia r0!, {r4, r5, r6, r7}
/* Return zero. */
mov r0, #0
bx lr
.thumb_func
.globl SYM (longjmp)
TYPE (longjmp)
SYM (longjmp):
/* Restore High regs. */
add r0, r0, #16
ldmia r0!, {r2, r3, r4, r5, r6}
mov r8, r2
mov r9, r3
mov r10, r4
mov fp, r5
mov sp, r6
ldmia r0!, {r3} /* lr */
/* Restore low regs. */
sub r0, r0, #40
ldmia r0!, {r4, r5, r6, r7}
/* Return the result argument, or 1 if it is zero. */
mov r0, r1
bne 1f
mov r0, #1
1:
bx r3
#else
#ifdef __APCS_26__
#define RET movs pc, lr
#elif defined(__thumb2__)
#define RET bx lr
#else
#define RET tst lr, #1; \
moveq pc, lr ; \
.word 0xe12fff1e /* bx lr */
#endif
#ifdef __thumb2__
.macro COND where when
i\where \when
.endm
#else
.macro COND where when
.endm
#endif
#if defined(__thumb2__)
.syntax unified
.macro MODE
.thumb
.thumb_func
.endm
.macro PROLOGUE name
.endm
#elif defined(__thumb__)
#define MODE .thumb_func
.macro PROLOGUE name
.code 16
bx pc
nop
.code 32
SYM (.arm_start_of.\name):
.endm
#else /* Arm */
#define MODE .code 32
.macro PROLOGUE name
.endm
#endif
.macro FUNC_START name
.text
.align 2
MODE
.globl SYM (\name)
TYPE (\name)
SYM (\name):
PROLOGUE \name
.endm
.macro FUNC_END name
RET
SIZE (\name)
.endm
/* --------------------------------------------------------------------
int setjmp (jmp_buf);
-------------------------------------------------------------------- */
FUNC_START setjmp
/* Save all the callee-preserved registers into the jump buffer. */
#ifdef __thumb2__
mov ip, sp
stmea a1!, { v1-v7, fp, ip, lr }
#else
stmea a1!, { v1-v7, fp, ip, sp, lr }
#endif
#if 0 /* Simulator does not cope with FP instructions yet. */
#ifndef __SOFTFP__
/* Save the floating point registers. */
sfmea f4, 4, [a1]
#endif
#endif
/* When setting up the jump buffer return 0. */
mov a1, #0
FUNC_END setjmp
/* --------------------------------------------------------------------
volatile void longjmp (jmp_buf, int);
-------------------------------------------------------------------- */
FUNC_START longjmp
/* If we have stack extension code it ought to be handled here. */
/* Restore the registers, retrieving the state when setjmp() was called. */
#ifdef __thumb2__
ldmfd a1!, { v1-v7, fp, ip, lr }
mov sp, ip
#else
ldmfd a1!, { v1-v7, fp, ip, sp, lr }
#endif
#if 0 /* Simulator does not cope with FP instructions yet. */
#ifndef __SOFTFP__
/* Restore floating point registers as well. */
lfmfd f4, 4, [a1]
#endif
#endif
/* Put the return value into the integer result register.
But if it is zero then return 1 instead. */
movs a1, a2
#ifdef __thumb2__
it eq
#endif
moveq a1, #1
FUNC_END longjmp
#endif
|
32bitmicro/newlib-nano-1.0
| 2,142
|
newlib/libc/machine/m68hc11/setjmp.S
|
/* setjmp/longjmp routines for M68HC11 & M68HC12.
* Copyright (C) 1999, 2000, 2001, 2002 Stephane Carrez (stcarrez@nerim.fr)
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#if __INT__ == 32
# define val 4
# define INT32(X) X
#else
# define val 2
# define INT32(X)
#endif
#ifdef mc6811
# define REG(X) *X
#else
# define REG(X) X
#endif
.sect .text
.global setjmp
.global longjmp
#ifdef mc6811
setjmp:
xgdx
tsy
ldd 0,y
std 0,x
sty 2,x
ldd REG(_.frame)
std 4,x
ldd REG(_.d1)
std 6,x
ldd REG(_.d2)
std 8,x
ldd REG(_.d3)
std 10,x
ldd REG(_.d4)
std 12,x
ldd REG(_.d5)
std 14,x
ldd REG(_.d6)
std 16,x
ldd REG(_.d7)
std 18,x
ldd REG(_.d8)
std 20,x
INT32( ldx #0)
clra
clrb
rts
#else
setjmp:
xgdx
movw 0,sp,2,x+
sts 2,x+
movw _.frame,2,x+
movw _.d1,2,x+
movw _.d2,2,x+
movw _.d3,2,x+
movw _.d4,2,x+
movw _.d5,2,x+
movw _.d6,2,x+
movw _.d7,2,x+
movw _.d8,2,x+
INT32( ldx #0)
clra
clrb
rts
#endif
#ifdef mc6811
longjmp:
xgdx
tsy
ldd val,y
bne do_jump
ldd #1
do_jump:
xgdy
ldd 4,x
std REG(_.frame)
ldd 6,x
std REG(_.d1)
ldd 8,x
std REG(_.d2)
ldd 10,x
std REG(_.d3)
ldd 12,x
std REG(_.d4)
ldd 14,x
std REG(_.d5)
ldd 16,x
std REG(_.d6)
ldd 18,x
std REG(_.d7)
ldd 20,x
std REG(_.d8)
ldd 0,x
ldx 2,x
txs
std 0,x
INT32( ldx #0)
xgdy
rts
#else
longjmp:
xgdx
ldy val,sp
bne do_jump
ldy #1
do_jump:
ldd 4,x+
movw 2,x+,_.frame
movw 0,x,_.d1
movw 2,x,_.d2
movw 4,x,_.d3
movw 6,x,_.d4
movw 8,x,_.d5
movw 10,x,_.d6
movw 12,x,_.d7
movw 14,x,_.d8
ldx -4,x
txs
std 0,x
INT32( ldx #0)
xgdy
rts
#endif
|
32bitmicro/newlib-nano-1.0
| 3,119
|
newlib/libc/machine/cr16/setjmp.S
|
##############################################################################
# setjmp.S -- CR16 setjmp routine #
# #
# Copyright (c) 2004 National Semiconductor Corporation #
# #
# The authors hereby grant permission to use, copy, modify, distribute, #
# and license this software and its documentation for any purpose, provided #
# that existing copyright notices are retained in all copies and that this #
# notice is included verbatim in any distributions. No written agreement, #
# license, or royalty fee is required for any of the authorized uses. #
# Modifications to this software may be copyrighted by their authors #
# and need not follow the licensing terms described here, provided that #
# the new terms are clearly indicated on the first page of each file where #
# they apply. #
# #
# C library -- setjmp, longjmp #
# longjmp(a,v) #
# will generate a "return(v)" #
# from the last call to #
# setjmp(a) #
# by restoring r7-ra, sp, #
# and pc from 'a' #
# and doing a return. (Makes sure that longjmp never returns 0). #
##############################################################################
.text
.file "setjmp.s"
.align 4
.globl _setjmp
.align 4
_setjmp:
#r3, r2: .blkw
storw r7, 0(r3,r2)
addd $2, (r3,r2)
storw r8, 0(r3,r2)
addd $2, (r3,r2)
storw r9, 0(r3,r2)
addd $2, (r3,r2)
storw r10, 0(r3,r2)
addd $2, (r3,r2)
storw r11, 0(r3,r2)
addd $2, (r3,r2)
stord (r12), 0(r3,r2)
addd $4, (r3,r2)
stord (r13), 0(r3,r2)
addd $4, (r3,r2)
stord (ra), 0(r3,r2)
addd $4, (r3,r2)
stord (sp), 0(r3,r2)
movd $0,(r1,r0)
jump (ra)
.globl _longjmp
_longjmp:
#r3, r2: .blkw # pointer save area
#r5, r4: .blkw # ret vlaue
loadw 0(r3,r2), r7
addd $2, (r3,r2)
loadw 0(r3,r2), r8
addd $2, (r3,r2)
loadw 0(r3,r2), r9
addd $2, (r3,r2)
loadw 0(r3,r2), r10
addd $2, (r3,r2)
loadw 0(r3,r2), r11
addd $2, (r3,r2)
loadd 0(r3,r2), (r12)
addd $4, (r3,r2)
loadd 0(r3,r2), (r13)
addd $4, (r3,r2)
loadd 0(r3,r2), (ra)
addd $4, (r3,r2)
loadd 0(r3,r2), (sp)
#ifdef __INT32__
movd (r5,r4), (r1,r0)
cmpd $0, (r5,r4)
bne end1
movd $1, (r1,r0)
#else
movw r4, r0
cmpw $0, r4
bne end1
movw $1, r0
#endif
end1:
jump (ra)
.align 4
|
32bitmicro/newlib-nano-1.0
| 2,255
|
newlib/libc/machine/x86_64/memcpy.S
|
/*
* ====================================================
* Copyright (C) 2007 by Ellips BV. All rights reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#include "x86_64mach.h"
.global SYM (memcpy)
SOTYPE_FUNCTION(memcpy)
SYM (memcpy):
movq rdi, rax /* Store destination in return value */
cmpq $16, rdx
jb byte_copy
movq rdi, r8 /* Align destination on quad word boundary */
andq $7, r8
jz quadword_aligned
movq $8, rcx
subq r8, rcx
subq rcx, rdx
rep movsb
quadword_aligned:
cmpq $256, rdx
jb quadword_copy
pushq rax
pushq r12
pushq r13
pushq r14
movq rdx, rcx /* Copy 128 bytes at a time with minimum cache polution */
shrq $7, rcx
.p2align 4
loop:
prefetchnta 768 (rsi)
prefetchnta 832 (rsi)
movq (rsi), rax
movq 8 (rsi), r8
movq 16 (rsi), r9
movq 24 (rsi), r10
movq 32 (rsi), r11
movq 40 (rsi), r12
movq 48 (rsi), r13
movq 56 (rsi), r14
movntiq rax, (rdi)
movntiq r8 , 8 (rdi)
movntiq r9 , 16 (rdi)
movntiq r10, 24 (rdi)
movntiq r11, 32 (rdi)
movntiq r12, 40 (rdi)
movntiq r13, 48 (rdi)
movntiq r14, 56 (rdi)
movq 64 (rsi), rax
movq 72 (rsi), r8
movq 80 (rsi), r9
movq 88 (rsi), r10
movq 96 (rsi), r11
movq 104 (rsi), r12
movq 112 (rsi), r13
movq 120 (rsi), r14
movntiq rax, 64 (rdi)
movntiq r8 , 72 (rdi)
movntiq r9 , 80 (rdi)
movntiq r10, 88 (rdi)
movntiq r11, 96 (rdi)
movntiq r12, 104 (rdi)
movntiq r13, 112 (rdi)
movntiq r14, 120 (rdi)
leaq 128 (rsi), rsi
leaq 128 (rdi), rdi
dec rcx
jnz loop
sfence
movq rdx, rcx
andq $127, rcx
rep movsb
popq r14
popq r13
popq r12
popq rax
ret
byte_copy:
movq rdx, rcx
rep movsb
ret
quadword_copy:
movq rdx, rcx
shrq $3, rcx
.p2align 4
rep movsq
movq rdx, rcx
andq $7, rcx
rep movsb /* Copy the remaining bytes */
ret
|
32bitmicro/newlib-nano-1.0
| 1,083
|
newlib/libc/machine/x86_64/setjmp.S
|
/*
* ====================================================
* Copyright (C) 2007 by Ellips BV. All rights reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
** jmp_buf:
** rbx rbp r12 r13 r14 r15 rsp rip
** 0 8 16 24 32 40 48 56
*/
#include "x86_64mach.h"
.global SYM (setjmp)
.global SYM (longjmp)
SOTYPE_FUNCTION(setjmp)
SOTYPE_FUNCTION(longjmp)
SYM (setjmp):
movq rbx, 0 (rdi)
movq rbp, 8 (rdi)
movq r12, 16 (rdi)
movq r13, 24 (rdi)
movq r14, 32 (rdi)
movq r15, 40 (rdi)
leaq 8 (rsp), rax
movq rax, 48 (rdi)
movq (rsp), rax
movq rax, 56 (rdi)
movq $0, rax
ret
SYM (longjmp):
movq rsi, rax /* Return value */
movq 8 (rdi), rbp
__CLI
movq 48 (rdi), rsp
pushq 56 (rdi)
movq 0 (rdi), rbx
movq 16 (rdi), r12
movq 24 (rdi), r13
movq 32 (rdi), r14
movq 40 (rdi), r15
__STI
ret
|
32bitmicro/newlib-nano-1.0
| 1,774
|
newlib/libc/machine/x86_64/memset.S
|
/*
* ====================================================
* Copyright (C) 2007 by Ellips BV. All rights reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#include "x86_64mach.h"
.global SYM (memset)
SOTYPE_FUNCTION(memset)
SYM (memset):
movq rdi, r9 /* Save return value */
movq rsi, rax
movq rdx, rcx
cmpq $16, rdx
jb byte_set
movq rdi, r8 /* Align on quad word boundary */
andq $7, r8
jz quadword_aligned
movq $8, rcx
subq r8, rcx
subq rcx, rdx
rep stosb
movq rdx, rcx
quadword_aligned:
movabs $0x0101010101010101, r8
movzbl sil, eax
imul r8, rax
cmpq $256, rdx
jb quadword_set
shrq $7, rcx /* Store 128 bytes at a time with minimum cache polution */
.p2align 4
loop:
movntiq rax, (rdi)
movntiq rax, 8 (rdi)
movntiq rax, 16 (rdi)
movntiq rax, 24 (rdi)
movntiq rax, 32 (rdi)
movntiq rax, 40 (rdi)
movntiq rax, 48 (rdi)
movntiq rax, 56 (rdi)
movntiq rax, 64 (rdi)
movntiq rax, 72 (rdi)
movntiq rax, 80 (rdi)
movntiq rax, 88 (rdi)
movntiq rax, 96 (rdi)
movntiq rax, 104 (rdi)
movntiq rax, 112 (rdi)
movntiq rax, 120 (rdi)
leaq 128 (rdi), rdi
dec rcx
jnz loop
sfence
movq rdx, rcx
andq $127, rcx
rep stosb
movq r9, rax
ret
byte_set:
rep stosb
movq r9, rax
ret
quadword_set:
shrq $3, rcx
.p2align 4
rep stosq
movq rdx, rcx
andq $7, rcx
rep stosb /* Store the remaining bytes */
movq r9, rax
ret
|
32bitmicro/newlib-nano-1.0
| 2,078
|
newlib/libc/machine/mep/setjmp.S
|
#
# Setjmp/longjmp for MeP
#
# DJ Delorie, Red Hat Inc.
#
# 19 32-bit words in the jmpbuf:
# $0
# $1
# ...
# $15
# $pc
# $hi
# $lo
#
# Note that $0 is saved but not restored. It can't be restored
# as it's the return value of setjmp, but we save it in case
# some application wants to see it in the jmp_buf. Ideally,
# we should not need to save anything that is call-clobbered,
# but you never know what the user is going to tell gcc with -f
# options.
.noregerr
.text
.globl setjmp
.type setjmp,@function
setjmp:
# $1 is the address of the buffer. We return 0 in $0.
sw $0, ($1)
sw $1, 4($1)
sw $2, 8($1)
sw $3, 12($1)
sw $4, 16($1)
sw $5, 20($1)
sw $6, 24($1)
sw $7, 28($1)
sw $8, 32($1)
sw $9, 36($1)
sw $10, 40($1)
sw $11, 44($1)
sw $12, 48($1)
sw $13, 52($1)
sw $14, 56($1)
sw $15, 60($1)
ldc $0, $lp
sw $0, 64($1)
ldc $0, $opt
sra $0, 24
and3 $0, $0, 3
beqz $0, sj_skip_hilo
ldc $0, $hi
sw $0, 68($1)
ldc $0, $lo
sw $0, 72($1)
sj_skip_hilo:
mov $0, 0
ret
.globl longjmp
.type longjmp,@function
longjmp:
# $1 is the address of the buffer. $2 is the value setjmp
# returns. We do not faithfully restore $0 or $lp, because
# the act of calling setjmp clobbered those anyway.
bnez $2, rv_not_zero
mov $2, 1
rv_not_zero:
# We restore $sp first so we can save the return value there,
# otherwise we'd need to have another unrestored register.
lw $15, 60($1)
add3 $sp, $sp, -4
sw $2, ($sp)
# Now restore the general registers.
lw $2, 8($1)
lw $3, 12($1)
lw $4, 16($1)
lw $5, 20($1)
lw $6, 24($1)
lw $7, 28($1)
lw $8, 32($1)
lw $9, 36($1)
lw $10, 40($1)
lw $11, 44($1)
lw $12, 48($1)
lw $13, 52($1)
lw $14, 56($1)
# We restore $pc's value to $lp so that we can just ret later.
lw $0, 64($1)
stc $0, $lp
ldc $0, $opt
sra $0, 24
and3 $0, $0, 3
beqz $0, lj_skip_hilo
lw $0, 68($1)
stc $0, $hi
lw $0, 72($1)
stc $0, $lo
lj_skip_hilo:
# Restore $1
lw $1, 8($1)
# Get the return value off the stack, and restore the stack.
lw $0, ($sp)
add3 $sp, $sp, 4
ret
|
32bitmicro/newlib-nano-1.0
| 2,140
|
newlib/libc/machine/bfin/setjmp.S
|
/*
* setjmp for the Blackfin processor
*
* Copyright (C) 2006 Analog Devices, Inc.
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#define _ASM
#define _SETJMP_H
.text;
.align 4;
.globl _setjmp;
.type _setjmp, STT_FUNC;
_setjmp:
[--SP] = P0; /* Save P0 */
P0 = R0;
R0 = [SP++];
[P0 + 0x00] = R0; /* Save saved P0 */
[P0 + 0x04] = P1;
[P0 + 0x08] = P2;
[P0 + 0x0C] = P3;
[P0 + 0x10] = P4;
[P0 + 0x14] = P5;
[P0 + 0x18] = FP; /* Frame Pointer */
[P0 + 0x1C] = SP; /* Stack Pointer */
[P0 + 0x20] = P0; /* Data Registers */
[P0 + 0x24] = R1;
[P0 + 0x28] = R2;
[P0 + 0x2C] = R3;
[P0 + 0x30] = R4;
[P0 + 0x34] = R5;
[P0 + 0x38] = R6;
[P0 + 0x3C] = R7;
R0 = ASTAT;
[P0 + 0x40] = R0;
R0 = LC0; /* Loop Counters */
[P0 + 0x44] = R0;
R0 = LC1;
[P0 + 0x48] = R0;
R0 = A0.W; /* Accumulators */
[P0 + 0x4C] = R0;
R0 = A0.X;
[P0 + 0x50] = R0;
R0 = A1.W;
[P0 + 0x54] = R0;
R0 = A1.X;
[P0 + 0x58] = R0;
R0 = I0; /* Index Registers */
[P0 + 0x5C] = R0;
R0 = I1;
[P0 + 0x60] = R0;
R0 = I2;
[P0 + 0x64] = R0;
R0 = I3;
[P0 + 0x68] = R0;
R0 = M0; /* Modifier Registers */
[P0 + 0x6C] = R0;
R0 = M1;
[P0 + 0x70] = R0;
R0 = M2;
[P0 + 0x74] = R0;
R0 = M3;
[P0 + 0x78] = R0;
R0 = L0; /* Length Registers */
[P0 + 0x7c] = R0;
R0 = L1;
[P0 + 0x80] = R0;
R0 = L2;
[P0 + 0x84] = R0;
R0 = L3;
[P0 + 0x88] = R0;
R0 = B0; /* Base Registers */
[P0 + 0x8C] = R0;
R0 = B1;
[P0 + 0x90] = R0;
R0 = B2;
[P0 + 0x94] = R0;
R0 = B3;
[P0 + 0x98] = R0;
R0 = RETS;
[P0 + 0x9C] = R0;
R0 = 0;
RTS;
.size _setjmp, .-_setjmp;
|
32bitmicro/newlib-nano-1.0
| 2,327
|
newlib/libc/machine/bfin/longjmp.S
|
/*
* longjmp for the Blackfin processor
*
* Copyright (C) 2006 Analog Devices, Inc.
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#define _ASM
#define _SETJMP_H
.text;
.align 4;
.globl _longjmp;
.type _longjmp, STT_FUNC;
_longjmp:
P0 = R0;
R0 = [P0 + 0x00];
[--SP] = R0; /* Put P0 on the stack */
P1 = [P0 + 0x04];
P2 = [P0 + 0x08];
P3 = [P0 + 0x0C];
P4 = [P0 + 0x10];
P5 = [P0 + 0x14];
FP = [P0 + 0x18];
R0 = [SP++]; /* Grab P0 from old stack */
SP = [P0 + 0x1C]; /* Update Stack Pointer */
[--SP] = R0; /* Put P0 on new stack */
[--SP] = R1; /* Put VAL arg on new stack */
R0 = [P0 + 0x20]; /* Data Registers */
R1 = [P0 + 0x24];
R2 = [P0 + 0x28];
R3 = [P0 + 0x2C];
R4 = [P0 + 0x30];
R5 = [P0 + 0x34];
R6 = [P0 + 0x38];
R7 = [P0 + 0x3C];
R0 = [P0 + 0x40];
ASTAT = R0;
R0 = [P0 + 0x44]; /* Loop Counters */
LC0 = R0;
R0 = [P0 + 0x48];
LC1 = R0;
R0 = [P0 + 0x4C]; /* Accumulators */
A0.W = R0;
R0 = [P0 + 0x50];
A0.X = R0;
R0 = [P0 + 0x54];
A1.W = R0;
R0 = [P0 + 0x58];
A1.X = R0;
R0 = [P0 + 0x5C]; /* Index Registers */
I0 = R0;
R0 = [P0 + 0x60];
I1 = R0;
R0 = [P0 + 0x64];
I2 = R0;
R0 = [P0 + 0x68];
I3 = R0;
R0 = [P0 + 0x6C]; /* Modifier Registers */
M0 = R0;
R0 = [P0 + 0x70];
M1 = R0;
R0 = [P0 + 0x74];
M2 = R0;
R0 = [P0 + 0x78];
M3 = R0;
R0 = [P0 + 0x7C]; /* Length Registers */
L0 = R0;
R0 = [P0 + 0x80];
L1 = R0;
R0 = [P0 + 0x84];
L2 = R0;
R0 = [P0 + 0x88];
L3 = R0;
R0 = [P0 + 0x8C]; /* Base Registers */
B0 = R0;
R0 = [P0 + 0x90];
B1 = R0;
R0 = [P0 + 0x94];
B2 = R0;
R0 = [P0 + 0x98];
B3 = R0;
R0 = [P0 + 0x9C]; /* Return Address (PC) */
RETS = R0;
R0 = [SP++];
P0 = [SP++];
CC = R0 == 0;
IF !CC JUMP 1f;
R0 = 1;
1:
RTS;
.size _longjmp, .-_longjmp;
|
32bitmicro/newlib-nano-1.0
| 3,956
|
newlib/libc/machine/tic6x/setjmp.S
|
;******************************************************************************
;* SETJMP v7.2.0I10181 *
;* *
;* Copyright (c) 1996-2010 Texas Instruments Incorporated *
;* http://www.ti.com/ *
;* *
;* Redistribution and use in source and binary forms, with or without *
;* modification, are permitted provided that the following conditions *
;* are met: *
;* *
;* Redistributions of source code must retain the above copyright *
;* notice, this list of conditions and the following disclaimer. *
;* *
;* Redistributions in binary form must reproduce the above copyright *
;* notice, this list of conditions and the following disclaimer in *
;* the documentation and/or other materials provided with the *
;* distribution. *
;* *
;* Neither the name of Texas Instruments Incorporated nor the names *
;* of its contributors may be used to endorse or promote products *
;* derived from this software without specific prior written *
;* permission. *
;* *
;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
;* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
;* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
;* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
;* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
;* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
;* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
;* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
;* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
;* *
;******************************************************************************
.text
.globl setjmp
.type setjmp,%function
setjmp:
MV .L2X A4, B4
|| STW .D1T2 B3, *+A4(48)
STW .D1T1 A10, *+A4(0)
|| STW .D2T2 B10, *+B4(4)
|| RET .S2 B3
STW .D1T1 A11, *+A4(8)
|| STW .D2T2 B11, *+B4(12)
STW .D1T1 A12, *+A4(16)
|| STW .D2T2 B12, *+B4(20)
STW .D1T1 A13, *+A4(24)
|| STW .D2T2 B13, *+B4(28)
STW .D1T1 A14, *+A4(32)
|| STW .D2T2 B14, *+B4(36)
STW .D1T1 A15, *+A4(40)
|| STW .D2T2 B15, *+B4(44)
|| ZERO .S1 A4
.size setjmp, . - setjmp
.globl longjmp
.type longjmp,%function
longjmp:
LDW .D1T1 *+A4(48), A3
MV .L2X A4, B6
|| MV .S1 A4, A6
|| MV .D2 B4, B2
LDW .D1T1 *+A6(0), A10
|| LDW .D2T2 *+B6(4), B10
|| [B2] MV .L1X B4, A4
|| [!B2] MVK .S1 1, A4
LDW .D1T1 *+A6(8), A11
|| LDW .D2T2 *+B6(12), B11
LDW .D1T1 *+A6(16), A12
|| LDW .D2T2 *+B6(20), B12
LDW .D1T1 *+A6(24), A13
|| LDW .D2T2 *+B6(28), B13
LDW .D1T1 *+A6(32), A14
|| LDW .D2T2 *+B6(36), B14
LDW .D1T1 *+A6(40), A15
|| LDW .D2T2 *+B6(44), B15
|| RET .S2X A3
NOP 5
.size longjmp, . - longjmp
|
32bitmicro/newlib-nano-1.0
| 1,917
|
newlib/libc/machine/mips/setjmp.S
|
/* This is a simple version of setjmp and longjmp for MIPS 32 and 64.
Ian Lance Taylor, Cygnus Support, 13 May 1993. */
#ifdef __mips16
/* This file contains 32 bit assembly code. */
.set nomips16
#endif
#define GPR_LAYOUT \
GPR_OFFSET ($16, 0); \
GPR_OFFSET ($17, 1); \
GPR_OFFSET ($18, 2); \
GPR_OFFSET ($19, 3); \
GPR_OFFSET ($20, 4); \
GPR_OFFSET ($21, 5); \
GPR_OFFSET ($22, 6); \
GPR_OFFSET ($23, 7); \
GPR_OFFSET ($29, 8); \
GPR_OFFSET ($30, 9); \
GPR_OFFSET ($31, 10)
#define NUM_GPRS_SAVED 11
#ifdef __mips_hard_float
#define FPR_LAYOUT \
FPR_OFFSET ($f20, 0); \
FPR_OFFSET ($f21, 1); \
FPR_OFFSET ($f22, 2); \
FPR_OFFSET ($f23, 3); \
FPR_OFFSET ($f24, 4); \
FPR_OFFSET ($f25, 5); \
FPR_OFFSET ($f26, 6); \
FPR_OFFSET ($f27, 7); \
FPR_OFFSET ($f28, 8); \
FPR_OFFSET ($f29, 9); \
FPR_OFFSET ($f30, 10); \
FPR_OFFSET ($f31, 11)
#else
#define FPR_LAYOUT
#endif
#ifdef __mips64
#define BYTES_PER_WORD 8
#define LOAD_GPR ld
#define LOAD_FPR ldc1
#define STORE_GPR sd
#define STORE_FPR sdc1
#else
#define BYTES_PER_WORD 4
#define LOAD_GPR lw
#define LOAD_FPR lwc1
#define STORE_GPR sw
#define STORE_FPR swc1
#endif
#define GPOFF(INDEX) (INDEX * BYTES_PER_WORD)
#define FPOFF(INDEX) ((INDEX + NUM_GPRS_SAVED) * BYTES_PER_WORD)
/* int setjmp (jmp_buf); */
.globl setjmp
.ent setjmp
setjmp:
.frame $sp,0,$31
#define GPR_OFFSET(REG, INDEX) STORE_GPR REG,GPOFF(INDEX)($4)
#define FPR_OFFSET(REG, INDEX) STORE_FPR REG,FPOFF(INDEX)($4)
GPR_LAYOUT
FPR_LAYOUT
#undef GPR_OFFSET
#undef FPR_OFFSET
move $2,$0
j $31
.end setjmp
/* volatile void longjmp (jmp_buf, int); */
.globl longjmp
.ent longjmp
longjmp:
.frame $sp,0,$31
#define GPR_OFFSET(REG, INDEX) LOAD_GPR REG,GPOFF(INDEX)($4)
#define FPR_OFFSET(REG, INDEX) LOAD_FPR REG,FPOFF(INDEX)($4)
GPR_LAYOUT
FPR_LAYOUT
#undef GPR_OFFSET
#undef FPR_OFFSET
bne $5,$0,1f
li $5,1
1:
move $2,$5
j $31
.end longjmp
|
32bitmicro/newlib-nano-1.0
| 2,619
|
newlib/libc/machine/h8500/psi.S
|
/* convert psi to si inplace
Note that `fp' below isn't a segment register.
It's r6, the frame pointer. */
#if __CODE__==32
#define RET prts
#else
#define RET rts
#endif
#define EXTPSISI_SN(r_msw,r_lsw,sp) ; \
.global __extpsisi##r_msw ; \
__extpsisi##r_msw: ; \
mov r_msw,r_lsw ; \
stc sp,r_msw ; \
RET
EXTPSISI_SN(r2,r3,dp)
EXTPSISI_SN(r4,r5,ep)
#define ADDPSI_AR_RN(sr,an,r_msw,r_lsw) \
.global __addpsi##an##r_msw ; \
__addpsi##an##r_msw: ; \
stc sr,@-sp ; \
add an,r_lsw ; \
addx @sp+,r_msw ; \
RET
ADDPSI_AR_RN(dp,r2,r0,r1)
ADDPSI_AR_RN(dp,r2,r3,r4)
ADDPSI_AR_RN(ep,r4,r0,r1)
ADDPSI_AR_RN(ep,r4,r1,r2)
ADDPSI_AR_RN(ep,r4,r3,r4)
ADDPSI_AR_RN(ep,r4,r5,fp)
ADDPSI_AR_RN(tp,fp,r0,r1)
#define ADDPSI_RN_AR(r_msw,r_lsw,sr,an,t_msw,t_lsw) \
.global __addpsi##r_msw##an ; \
__addpsi##r_msw##an: ; \
mov.w t_msw,@-sp ; \
mov.w t_lsw,@-sp ; \
stc sr,t_msw ; \
mov an,t_lsw ; \
add r_lsw,t_lsw ; \
addx r_msw,t_msw ; \
ldc t_msw,sr ; \
mov.w t_lsw,an ; \
mov.w @sp+,t_lsw ; \
mov.w @sp+,t_msw ; \
RET
ADDPSI_RN_AR(r0,r1,dp,r2,r4,r5)
ADDPSI_RN_AR(r0,r1,ep,r4,r2,r3)
#define EXTPSIHI_RN_RN(rm,r_msw,r_lsw) ; \
.global __extpsihi##rm##r_msw ; \
__extpsihi##rm##r_msw: ; \
mov rm,r_lsw ; \
clr.w r_msw ; \
RET
EXTPSIHI_RN_RN(r3,r0,r1)
EXTPSIHI_RN_RN(r4,r0,r1)
EXTPSIHI_RN_RN(r5,r0,r1)
EXTPSIHI_RN_RN(r2,r0,r1)
/* ifdefed out, because gcc doesn't like the # character in the above
macro. The macro expands into an assembly languange comment anyways,
so it serves no useful purpose. */
#if 0
#define EXTPSIHI_RN_SN(rm,r_msw,r_lsw) ; \
.global __extpsihi##rm##r_lsw ; \
__extpsihi##rm##r_lsw: ; \
mov rm,r_lsw ; \
ldc \#0,r_msw ; \
RET
EXTPSIHI_RN_SN(r0,dp,r2)
EXTPSIHI_RN_SN(r0,ep,r4)
EXTPSIHI_RN_SN(r1,dp,r2)
EXTPSIHI_RN_SN(r1,ep,r4)
EXTPSIHI_RN_SN(r3,dp,r2)
EXTPSIHI_RN_SN(r3,ep,r4)
EXTPSIHI_RN_SN(r5,dp,r2)
EXTPSIHI_RN_SN(r5,ep,r4)
EXTPSIHI_RN_SN(r2,ep,r4)
#endif
#define EXTPSISI_RN(r_msw,r_lsw) ; \
.global __extpsisi##r_msw ; \
__extpsisi##r_msw: ; \
RET
EXTPSISI_RN(r0,r1)
#define ADDPSI_SA_SB(sa,ra,sb,rb) ; \
.global __addpsi##ra##rb ; \
__addpsi##ra##rb: ; \
mov.w r0,@-sp ; \
mov.w r1,@-sp ; \
stc sa,r0 ; \
stc sb,r1 ; \
add.w ra,rb ; \
addx r0,r1 ; \
ldc r1,sb ; \
mov.w @sp+,r1 ; \
mov.w @sp+,r0 ; \
RET
ADDPSI_SA_SB(dp,r2,ep,r4)
ADDPSI_SA_SB(ep,r4,dp,r2)
ADDPSI_SA_SB(tp,fp,dp,r2)
ADDPSI_SA_SB(tp,fp,ep,r4)
ADDPSI_SA_SB(dp,r2,dp,r2)
.global __addpsir0r0
__addpsir0r0:
add.w r1,r1
addx r0,r0
RET
|
32bitmicro/newlib-nano-1.0
| 7,262
|
newlib/libc/machine/powerpc/setjmp.S
|
/* This is a simple version of setjmp and longjmp for the PowerPC.
Ian Lance Taylor, Cygnus Support, 9 Feb 1994.
Modified by Jeff Johnston, Red Hat Inc. 2 Oct 2001. */
#include "ppc-asm.h"
FUNC_START(setjmp)
#ifdef __ALTIVEC__
addi 3,3,15 # align Altivec to 16 byte boundary
rlwinm 3,3,0,0,27
#else
addi 3,3,7 # align to 8 byte boundary
rlwinm 3,3,0,0,28
#endif
#if __SPE__
/* If we are E500, then save 64-bit registers. */
evstdd 1,0(3) # offset 0
evstdd 2,8(3) # offset 8
evstdd 13,16(3) # offset 16
evstdd 14,24(3) # offset 24
evstdd 15,32(3) # offset 32
evstdd 16,40(3) # offset 40
evstdd 17,48(3) # offset 48
evstdd 18,56(3) # offset 56
evstdd 19,64(3) # offset 64
evstdd 20,72(3) # offset 72
evstdd 21,80(3) # offset 80
evstdd 22,88(3) # offset 88
evstdd 23,96(3) # offset 96
evstdd 24,104(3) # offset 104
evstdd 25,112(3) # offset 112
evstdd 26,120(3) # offset 120
evstdd 27,128(3) # offset 128
evstdd 28,136(3) # offset 136
evstdd 29,144(3) # offset 144
evstdd 30,152(3) # offset 152
evstdd 31,160(3) # offset 160
/* Add 164 to r3 to account for the amount of data we just
stored. Note that we are not adding 168 because the next
store instruction uses an offset of 4. */
addi 3,3,164
#else
stw 1,0(3) # offset 0
stwu 2,4(3) # offset 4
stwu 13,4(3) # offset 8
stwu 14,4(3) # offset 12
stwu 15,4(3) # offset 16
stwu 16,4(3) # offset 20
stwu 17,4(3) # offset 24
stwu 18,4(3) # offset 28
stwu 19,4(3) # offset 32
stwu 20,4(3) # offset 36
stwu 21,4(3) # offset 40
stwu 22,4(3) # offset 44
stwu 23,4(3) # offset 48
stwu 24,4(3) # offset 52
stwu 25,4(3) # offset 56
stwu 26,4(3) # offset 60
stwu 27,4(3) # offset 64
stwu 28,4(3) # offset 68
stwu 29,4(3) # offset 72
stwu 30,4(3) # offset 76
stwu 31,4(3) # offset 80
#endif
/* From this point on until the end of this function, add 84
to the offset shown if __SPE__. This difference comes from
the fact that we save 21 64-bit registers instead of 21
32-bit registers above. */
mflr 4
stwu 4,4(3) # offset 84
mfcr 4
stwu 4,4(3) # offset 88
# one word pad to get floating point aligned on 8 byte boundary
/* Check whether we need to save FPRs. Checking __NO_FPRS__
on its own would be enough for GCC 4.1 and above, but older
compilers only define _SOFT_FLOAT, so check both. */
#if !defined (__NO_FPRS__) && !defined (_SOFT_FLOAT)
stfdu 14,8(3) # offset 96
stfdu 15,8(3) # offset 104
stfdu 16,8(3) # offset 112
stfdu 17,8(3) # offset 120
stfdu 18,8(3) # offset 128
stfdu 19,8(3) # offset 136
stfdu 20,8(3) # offset 144
stfdu 21,8(3) # offset 152
stfdu 22,8(3) # offset 160
stfdu 23,8(3) # offset 168
stfdu 24,8(3) # offset 176
stfdu 25,8(3) # offset 184
stfdu 26,8(3) # offset 192
stfdu 27,8(3) # offset 200
stfdu 28,8(3) # offset 208
stfdu 29,8(3) # offset 216
stfdu 30,8(3) # offset 224
stfdu 31,8(3) # offset 232
#endif
/* This requires a total of 21 * 4 + 18 * 8 + 4 + 4 + 4
bytes == 60 * 4 bytes == 240 bytes. */
#ifdef __ALTIVEC__
/* save Altivec vrsave and vr20-vr31 registers */
mfspr 4,256 # vrsave register
stwu 4,16(3) # offset 248
addi 3,3,8
stvx 20,0,3 # offset 256
addi 3,3,16
stvx 21,0,3 # offset 272
addi 3,3,16
stvx 22,0,3 # offset 288
addi 3,3,16
stvx 23,0,3 # offset 304
addi 3,3,16
stvx 24,0,3 # offset 320
addi 3,3,16
stvx 25,0,3 # offset 336
addi 3,3,16
stvx 26,0,3 # offset 352
addi 3,3,16
stvx 27,0,3 # offset 368
addi 3,3,16
stvx 28,0,3 # offset 384
addi 3,3,16
stvx 29,0,3 # offset 400
addi 3,3,16
stvx 30,0,3 # offset 416
addi 3,3,16
stvx 31,0,3 # offset 432
/* This requires a total of 240 + 8 + 8 + 12 * 16 == 448 bytes. */
#endif
li 3,0
blr
FUNC_END(setjmp)
FUNC_START(longjmp)
#ifdef __ALTIVEC__
addi 3,3,15 # align Altivec to 16 byte boundary
rlwinm 3,3,0,0,27
#else
addi 3,3,7 # align to 8 byte boundary
rlwinm 3,3,0,0,28
#endif
#if __SPE__
/* If we are E500, then restore 64-bit registers. */
evldd 1,0(3) # offset 0
evldd 2,8(3) # offset 8
evldd 13,16(3) # offset 16
evldd 14,24(3) # offset 24
evldd 15,32(3) # offset 32
evldd 16,40(3) # offset 40
evldd 17,48(3) # offset 48
evldd 18,56(3) # offset 56
evldd 19,64(3) # offset 64
evldd 20,72(3) # offset 72
evldd 21,80(3) # offset 80
evldd 22,88(3) # offset 88
evldd 23,96(3) # offset 96
evldd 24,104(3) # offset 104
evldd 25,112(3) # offset 112
evldd 26,120(3) # offset 120
evldd 27,128(3) # offset 128
evldd 28,136(3) # offset 136
evldd 29,144(3) # offset 144
evldd 30,152(3) # offset 152
evldd 31,160(3) # offset 160
/* Add 164 to r3 to account for the amount of data we just
loaded. Note that we are not adding 168 because the next
load instruction uses an offset of 4. */
addi 3,3,164
#else
lwz 1,0(3) # offset 0
lwzu 2,4(3) # offset 4
lwzu 13,4(3) # offset 8
lwzu 14,4(3) # offset 12
lwzu 15,4(3) # offset 16
lwzu 16,4(3) # offset 20
lwzu 17,4(3) # offset 24
lwzu 18,4(3) # offset 28
lwzu 19,4(3) # offset 32
lwzu 20,4(3) # offset 36
lwzu 21,4(3) # offset 40
lwzu 22,4(3) # offset 44
lwzu 23,4(3) # offset 48
lwzu 24,4(3) # offset 52
lwzu 25,4(3) # offset 56
lwzu 26,4(3) # offset 60
lwzu 27,4(3) # offset 64
lwzu 28,4(3) # offset 68
lwzu 29,4(3) # offset 72
lwzu 30,4(3) # offset 76
lwzu 31,4(3) # offset 80
#endif
/* From this point on until the end of this function, add 84
to the offset shown if __SPE__. This difference comes from
the fact that we restore 21 64-bit registers instead of 21
32-bit registers above. */
lwzu 5,4(3) # offset 84
mtlr 5
lwzu 5,4(3) # offset 88
mtcrf 255,5
# one word pad to get floating point aligned on 8 byte boundary
/* Check whether we need to restore FPRs. Checking
__NO_FPRS__ on its own would be enough for GCC 4.1 and
above, but older compilers only define _SOFT_FLOAT, so
check both. */
#if !defined (__NO_FPRS__) && !defined (_SOFT_FLOAT)
lfdu 14,8(3) # offset 96
lfdu 15,8(3) # offset 104
lfdu 16,8(3) # offset 112
lfdu 17,8(3) # offset 120
lfdu 18,8(3) # offset 128
lfdu 19,8(3) # offset 136
lfdu 20,8(3) # offset 144
lfdu 21,8(3) # offset 152
lfdu 22,8(3) # offset 160
lfdu 23,8(3) # offset 168
lfdu 24,8(3) # offset 176
lfdu 25,8(3) # offset 184
lfdu 26,8(3) # offset 192
lfdu 27,8(3) # offset 200
lfdu 28,8(3) # offset 208
lfdu 29,8(3) # offset 216
lfdu 30,8(3) # offset 224
lfdu 31,8(3) # offset 232
#endif
#ifdef __ALTIVEC__
/* restore Altivec vrsave and v20-v31 registers */
lwzu 5,16(3) # offset 248
mtspr 256,5 # vrsave
addi 3,3,8
lvx 20,0,3 # offset 256
addi 3,3,16
lvx 21,0,3 # offset 272
addi 3,3,16
lvx 22,0,3 # offset 288
addi 3,3,16
lvx 23,0,3 # offset 304
addi 3,3,16
lvx 24,0,3 # offset 320
addi 3,3,16
lvx 25,0,3 # offset 336
addi 3,3,16
lvx 26,0,3 # offset 352
addi 3,3,16
lvx 27,0,3 # offset 368
addi 3,3,16
lvx 28,0,3 # offset 384
addi 3,3,16
lvx 29,0,3 # offset 400
addi 3,3,16
lvx 30,0,3 # offset 416
addi 3,3,16
lvx 31,0,3 # offset 432
#endif
mr. 3,4
bclr+ 4,2
li 3,1
blr
FUNC_END(longjmp)
|
32bitmicro/newlib-nano-1.0
| 6,544
|
newlib/libc/sys/d10v/trap.S
|
#include "sys/syscall.h"
#define SYSCALL(name) \
.global name ; \
name: ; \
ldi r4, SYS ## name ; \
bra __trap0
.text
.stabs "trap.S",100,0,0,__trap0
.stabs "int:t(0,1)=r(0,1);-65536;65535;",128,0,0,0
.stabs "long int:t(0,2)=r(0,1);0020000000000;0017777777777;",128,0,0,0
.stabs "_trap0:F(0,1)",36,0,1,__trap0
.stabs "arg1:P(0,1)",64,0,1,0
.stabs "arg2:P(0,1)",64,0,1,1
.stabs "arg3:P(0,1)",64,0,1,2
.stabs "arg4:P(0,1)",64,0,1,3
.stabs "number:P(0,1)",64,0,1,4
.global __trap0
.type __trap0,@function
__trap0:
trap 15 /* trap 15 returns result in r0, error code in r4 */
cmpeqi r4,0 /* is error code zero? */
brf0t ret /* yes, skip setting errno */
#if __INT__==32
st r4,@(errno+2,r14) /* no, set errno */
srai r4,15 /* sign extend high word */
st r4,@(errno,r14)
#else
st r4,@(errno,r14) /* no, set errno */
#endif
ret:
jmp r13 /* return to caller */
.Ltrap0:
.size __trap0,.Ltrap0-__trap0
.stabs "",36,0,0,.Ltrap0-__trap0
#define CONCAT(a,b) a ## b
#define STRING(a) #a
#define XSTRING(a) STRING(a)
#define XSTRING2(a,b) XSTRING(CONCAT(a,b))
#if __INT__==32
#define _read _read16
#define _lseek _lseek16
#define _write _write16
#define _close _close16
#define _open _open16
#define _creat _creat16
#define _exit _exit16
#define _stat _stat16
#define _chmod _chmod16
#define _chown _chown16
#define _fork _fork16
#define _wait _wait16
#define _execve _execve16
#define _execv _execv16
#define _pipe _pipe16
#define _kill _kill16
#define _getpid _getpid16
#endif
/* Until the assembler allows semicolon as a statement separator, */
/* we cannot use the SYSCALL macro. So expand it manually for now. */
/* #SYSCALL(_read) */
/* #SYSCALL(_lseek) */
/* #SYSCALL(_write) */
/* #SYSCALL(_close) */
/* #SYSCALL(_open) */
/* #SYSCALL(_creat) */
/* #SYSCALL(_exit) */
/* #SYSCALL(_stat) */
/* #SYSCALL(_chmod) */
/* #SYSCALL(_chown) */
/* #SYSCALL(_fork) */
/* #SYSCALL(_wait) */
/* #SYSCALL(_execve) */
/* #SYSCALL(_execv) */
/* #SYSCALL(_pipe) */
/* #SYSCALL(_getpid) */
/* #SYSCALL(_kill) */
.global _read
.type _read,@function
.stabs XSTRING2(_read,:F(0,1)),36,0,2,_read
.stabs "fd:P(0,1)",64,0,1,0
.stabs "ptr:P(0,1)",64,0,1,1
.stabs "len:P(0,1)",64,0,1,2
_read:
ldi r4, SYS_read
bra __trap0
.Lread:
.size _read,.-_read
.stabs "",36,0,0,.Lread-_read
.global _lseek
.type _lseek,@function
.stabs XSTRING2(_lseek,:F(0,1)),36,0,3,_lseek
.stabs "fd:P(0,1)",64,0,1,0
.stabs "offset:P(0,1)",64,0,1,2
.stabs "whence:p(0,1)",160,0,1,0
_lseek:
ldi r4, SYS_lseek
bra __trap0
.Llseek:
.size _lseek,.Llseek-_lseek
.stabs "",36,0,0,.Llseek-_lseek
.global _write
.type _write,@function
.stabs XSTRING2(_write,:F(0,1)),36,0,4,_write
.stabs "fd:P(0,1)",64,0,1,0
.stabs "ptr:P(0,1)",64,0,1,1
.stabs "len:P(0,1)",64,0,1,2
_write:
ldi r4, SYS_write
bra __trap0
.Lwrite:
.size _write,.Lwrite-_write
.stabs "",36,0,0,.Lwrite-_write
.global _close
.type _close,@function
.stabs XSTRING2(_close,:F(0,1)),36,0,5,_close
.stabs "fd:P(0,1)",64,0,1,0
_close:
ldi r4, SYS_close
bra __trap0
.Lclose:
.size _close,.Lclose-_close
.stabs "",36,0,0,.Lclose-_close
.global _open
.type _open,@function
.stabs XSTRING2(_open,:F(0,1)),36,0,6,_open
.stabs "name:P(0,1)",64,0,1,0
.stabs "flags:P(0,1)",64,0,1,1
.stabs "mode:P(0,1)",64,0,1,2
_open:
ldi r4, SYS_open
bra __trap0
.Lopen:
.size _open,.Lopen-_open
.stabs "",36,0,0,.Lopen-_open
.global _creat
.type _creat,@function
.stabs XSTRING2(_creat,:F(0,1)),36,0,7,_creat
.stabs "name:P(0,1)",64,0,1,0
.stabs "mode:P(0,1)",64,0,1,1
_creat:
ldi r4, SYS_creat
bra __trap0
.Lcreat:
.size _creat,.Lcreat-_creat
.stabs "",36,0,0,.Lcreat-_creat
.global _exit
.type _exit,@function
.stabs XSTRING2(_exit,:F(0,1)),36,0,8,_exit
.stabs "status:P(0,1)",64,0,1,0
_exit:
ldi r4, SYS_exit
bra __trap0
.Lexit:
.size _exit,.Lexit-_exit
.stabs "",36,0,0,.Lexit-_exit
.global _stat
.type _stat,@function
.stabs XSTRING2(_stat,:F(0,1)),36,0,9,_stat
.stabs "name:P(0,1)",64,0,1,0
.stabs "packet:P(0,1)",64,0,1,1
_stat:
ldi r4, SYS_stat
bra __trap0
.Lstat:
.size _stat,.Lstat-_stat
.stabs "",36,0,0,.Lstat-_stat
.global _chmod
.type _chmod,@function
.stabs XSTRING2(_chmod,:F(0,1)),36,0,10,_chmod
.stabs "name:P(0,1)",64,0,1,0
.stabs "mode:P(0,1)",64,0,1,1
_chmod:
ldi r4, SYS_chmod
bra __trap0
.Lchmod:
.size _chmod,.Lchmod-_chmod
.stabs "",36,0,0,.Lchmod-_chmod
.global _chown
.type _chown,@function
.stabs XSTRING2(_chown,:F(0,1)),36,0,11,_chown
.stabs "name:P(0,1)",64,0,1,0
.stabs "uid:P(0,1)",64,0,1,1
.stabs "gid:P(0,1)",64,0,1,2
_chown:
ldi r4, SYS_chown
bra __trap0
.Lchown:
.size _chown,.Lchown-_chown
.stabs "",36,0,0,.Lchown-_chown
.global _fork
.type _fork,@function
.stabs XSTRING2(_fork,:F(0,1)),36,0,12,_fork
_fork:
ldi r4, SYS_fork
bra __trap0
.Lfork:
.size _fork,.Lfork-_fork
.stabs "",36,0,0,.Lfork-_fork
.global _wait
.type _wait,@function
.stabs "status:P(0,1)",64,0,1,0
.stabs XSTRING2(_wait,:F(0,1)),36,0,13,_wait
_wait:
ldi r4, SYS_wait
bra __trap0
.Lwait:
.size _wait,.Lwait-_wait
.stabs "",36,0,0,.Lwait-_wait
.global _execve
.type _execve,@function
.stabs "name:P(0,1)",64,0,1,0
.stabs "argv:P(0,1)",64,0,1,1
.stabs "envp:P(0,1)",64,0,1,2
.stabs XSTRING2(_execve,:F(0,1)),36,0,14,_execve
_execve:
ldi r4, SYS_execve
bra __trap0
.Lexecve:
.size _execve,.Lexecve-_execve
.stabs "",36,0,0,.Lexecve-_execve
.global _execv
.type _execv,@function
.stabs XSTRING2(_execv,:F(0,1)),36,0,15,_execv
.stabs "name:P(0,1)",64,0,1,0
.stabs "argv:P(0,1)",64,0,1,1
_execv:
ldi r4, SYS_execv
bra __trap0
.Lexecv:
.size _execv,.Lexecv-_execv
.stabs "",36,0,0,.Lexecv-_execv
.global _pipe
.type _pipe,@function
.stabs XSTRING2(_pipe,:F(0,1)),36,0,16,_pipe
.stabs "fds:P(0,1)",64,0,1,0
_pipe:
ldi r4, SYS_pipe
bra __trap0
.Lpipe:
.size _pipe,.Lpipe-_pipe
.stabs "",36,0,0,.Lpipe-_pipe
.global time
.type time,@function
.stabs XSTRING2(time,:F(0,1)),36,0,17,time
.stabs "ptr:P(0,1)",64,0,1,0
time:
ldi r4, SYS_time
bra __trap0
.Ltime:
.size time,.Ltime-time
.stabs "",36,0,0,.Ltime-time
.global _kill
.type _kill,@function
.stabs XSTRING2(_kill,:F(0,1)),36,0,18,_kill
.stabs "pid:P(0,1)",64,0,1,0
.stabs "sig:P(0,1)",64,0,1,1
_kill:
ldi r4, SYS_kill
bra __trap0
.Lkill:
.size _kill,.Lkill-_kill
.stabs "",36,0,0,.Lkill-_kill
.global _getpid
.type _getpid,@function
.stabs XSTRING2(_getpid,:F(0,1)),36,0,19,_getpid
_getpid:
ldi r4, SYS_getpid
bra __trap0
.Lgetpid:
.size _getpid,.Lgetpid-_getpid
.stabs "",36,0,0,.Lgetpid-_getpid
|
32bitmicro/newlib-nano-1.0
| 1,486
|
newlib/libc/sys/d10v/crt0.S
|
.text
.global _start
.type _start,@function
.stabs "crt0.S",100,0,0,_start
.stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0
.stabs "_start:F(0,1)",36,0,1,_start
_start:
; R14 always contains memory base address (0)
ldi r14,0
; Set the USER and SYSTEM stack pointers.
ldi r0, 0 ; zero arguments
ldi r1, 0
mvtc r0, psw ; select SPI and set it
ldi sp, _stack
ldi r10, 0x8000 ; select SPU/FP and set it
mvtc r10, psw || ldi r11, 0; clear stack frame
ldi sp, _stack - 0x200
ldi r13, 0
; Clear the BSS. Do it in two parts for efficiency: longwords first
; for most of it, then the remaining 0 to 3 bytes.
ldi r2, __bss_start ; R2 = start of BSS
ldi r3, _end ; R3 = end of BSS + 1
sub r3, r2 ; R3 = BSS size in bytes
mv r4, r3
srli r4, 2 ; R4 = BSS size in longwords (rounded down)
loop1:
cmpeqi r4, 0 ; more longords to zero out?
brf0t.s endloop1 ; nope
st2w r0, @r2+ ; yep, zero out another longword
subi r4, 1 ; decrement count
bra.l loop1 ; go do some more
endloop1:
and3 r4, r3, 3 ; get no. of remaining BSS bytes to clear
loop2:
cmpeqi r4, 0 ; more bytes to zero out?
brf0t.s endloop2 ; nope
stb r0, @r2 ; yep, zero out another byte
addi r2, 1 ; bump address
subi r4, 1 ; decrement count
bra.s loop2 ; go do some more
endloop2:
; Call main, then stop simulator
st r11, @-sp
st r13, @-sp
mv r11, sp
bl main
bl exit
stop
.Lstart:
.size _start,.Lstart-_start
.stabs "",36,0,0,.Lstart-_start
.section .stack
_stack: .long 1
|
32bitmicro/newlib-nano-1.0
| 133,709
|
newlib/libc/sys/rdos/rdos.S
|
/*#######################################################################
# RDOS operating system
# Copyright (C) 1988-2006, Leif Ekblad
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# The author of this program may be contacted at leif@rdos.net
#
# rdos.S
# GCC based interface to RDOS kernel
#
##########################################################################*/
#include "user.def"
.macro UserGate nr
.byte 0x9A
.long \nr
.word 2
.endm
/*##########################################################################
#
# Name : RdosSwapShort
#
# Purpose....: Byte reverse a short int
#
# Returns....: Result
#
##########################################################################*/
.global RdosSwapShort
RdosSwapShort:
pushl %ebp
movl %esp,%ebp
movw 8(%ebp),%ax
xchgb %ah,%al
leave
ret
/*##########################################################################
#
# Name : RdosSwapLong
#
# Purpose....: Byte reverse a long int
#
# Returns....: Result
#
##########################################################################*/
.global RdosSwapLong
RdosSwapLong:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
xchgb %ah,%al
roll $16,%eax
xchgb %ah,%al
leave
ret
/*##########################################################################
#
# Name : LocalToNetworkLong
#
# Purpose....: Convert a local long to network format
#
# Returns....: Network format
#
##########################################################################*/
.global LocalToNetworkLong
LocalToNetworkLong:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
xchgb %ah,%al
roll $16,%eax
xchgb %ah,%al
leave
ret
/*##########################################################################
#
# Name : NetworkToLocalLong
#
# Purpose....: Convert a network long to local format
#
# Returns....: Local format
#
##########################################################################*/
.global NetworkToLocalLong
NetworkToLocalLong:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
xchgb %ah,%al
roll $16,%eax
xchgb %ah,%al
leave
ret
/*##########################################################################
#
# Name : RdosGetThreadHandle
#
# Purpose....: Get current thread handle
#
# Returns....: Thread ID
#
##########################################################################*/
.global RdosGetThreadHandle
RdosGetThreadHandle:
pushl %ebp
movl %esp,%ebp
UserGate get_thread_nr
movzx %ax,%eax
leave
ret
/*##########################################################################
#
# Name : RdosGetThreadState
#
# Purpose....: Get thread state
#
# Parameters.: Thread #
# State buffer
#
##########################################################################*/
.global RdosGetThreadState
RdosGetThreadState:
pushl %ebp
movl %esp,%ebp
push %edi
movl 8(%ebp),%eax
movl 12(%ebp),%edx
UserGate get_thread_state_nr
jc rgtsFail
movl $1,%eax
jmp rgtsDone
rgtsFail:
xorl %eax,%eax
rgtsDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosSuspendThread
#
# Purpose....: Suspend thread
#
# Parameters.: Thread #
#
##########################################################################*/
.global RdosSuspendThread
RdosSuspendThread:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
UserGate suspend_thread_nr
jc rsfFail
movl $1,%eax
jmp rsfDone
rsfFail:
xorl %eax,%eax
rsfDone:
leave
ret
/*##########################################################################
#
# Name : RdosExec
#
# Purpose....: Execute a program
#
# Parameters.: Program
# Commandline
#
##########################################################################*/
.global RdosExec
RdosExec:
pushl %ebp
movl %esp,%ebp
pushl %esi
pushl %edi
movl 8(%ebp),%esi
movl 12(%ebp),%edi
UserGate load_exe_nr
UserGate get_exit_code_nr
popl %edi
popl %esi
leave
ret
/*##########################################################################
#
# Name : RdosSpawn
#
# Purpose....: Create new process and run a program
#
# Parameters.: Program
# Commandline
# StartDir
#
##########################################################################*/
.global RdosSpawn
RdosSpawn:
pushl %ebp
movl %esp,%ebp
pushl %fs
pushl %ebx
pushl %edx
pushl %esi
pushl %edi
movw %ds,%dx
movw %dx,%fs
xorl %edx,%edx
movl 8(%ebp),%esi
movl 12(%ebp),%edi
movl 16(%ebp),%ebx
UserGate spawn_exe_nr
jc rsFail
movzx %dx,%eax
jmp rsDone
rsFail:
xorl %eax,%eax
rsDone:
popl %edi
popl %esi
popl %edx
popl %ebx
popw %fs
leave
ret
/*##########################################################################
#
# Name : RdosCpuReset
#
# Purpose....: Cpu reset
#
##########################################################################*/
.global RdosCpuReset
RdosCpuReset:
pushl %ebp
movl %esp,%ebp
UserGate cpu_reset_nr
leave
ret
/*##########################################################################
#
# Name : RdosGetVersion
#
# Purpose....: Get RDOS version
#
# Parameters.: &major
# &minor
# &release
#
##########################################################################*/
.global RdosGetVersion
RdosGetVersion:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ecx
pushl %edx
pushl %edi
UserGate get_version_nr
movzx %dx,%edx
movl 8(%ebp),%edi
movl %edx,(%edi)
movzx %ax,%eax
movl 12(%ebp),%edi
movl %eax,(%edi)
movzx %cx,%eax
movl 16(%ebp),%edi
movl %eax,(%edi)
popl %edi
popl %edx
popl %ecx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosAllocateMem
#
# Purpose....: Allocate memory
#
# Parameters.: Bytes to allocate
#
# Returns....: Memory pointer
#
##########################################################################*/
.global RdosAllocateMem
RdosAllocateMem:
pushl %ebp
movl %esp,%ebp
pushl %edx
movl 8(%ebp),%eax
UserGate allocate_app_mem_nr
movl %edx,%eax
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosFreeMem
#
# Purpose....: Free memory
#
# Parameters.: Memory pointer
#
##########################################################################*/
.global RdosFreeMem
RdosFreeMem:
pushl %ebp
movl %esp,%ebp
pushl %edx
movl 8(%ebp),%edx
UserGate free_app_mem_nr
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosAppDebug
#
# Purpose....: App debug
#
##########################################################################*/
.global RdosAppDebug
RdosAppDebug:
pushl %ebp
movl %esp,%ebp
UserGate app_debug_nr
leave
ret
/*##########################################################################
#
# Name : RdosWaitMilli
#
# Purpose....: Wait a number of milliseconds
#
# Parameters.: Milliseconds to wait
#
##########################################################################*/
.global RdosWaitMilli
RdosWaitMilli:
pushl %ebp
movl %esp,%ebp
pushl %eax
movl 8(%ebp),%eax
UserGate wait_milli_nr
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosCreateSection
#
# Purpose....: Create section
#
# Returns....: Section handle
#
##########################################################################*/
.global RdosCreateSection
RdosCreateSection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
UserGate create_user_section_nr
movzx %bx,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDeleteSection
#
# Purpose....: Delete section
#
# Parameters.: Section handle
#
##########################################################################*/
.global RdosDeleteSection
RdosDeleteSection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate delete_user_section_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosEnterSection
#
# Purpose....: Enter section
#
# Parameters.: Section handle
#
##########################################################################*/
.global RdosEnterSection
RdosEnterSection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate enter_user_section_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosLeaveSection
#
# Purpose....: Leave section
#
# Parameters.: Section handle
#
##########################################################################*/
.global RdosLeaveSection
RdosLeaveSection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate leave_user_section_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateWait
#
# Purpose....: Create wait object
#
# Returns....: Wait handle
#
##########################################################################*/
.global RdosCreateWait
RdosCreateWait:
pushl %ebp
movl %esp,%ebp
pushl %ebx
UserGate create_wait_nr
movzx %bx,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseWait
#
# Purpose....: Close wait
#
# Parameters.: Wait handle
#
##########################################################################*/
.global RdosCloseWait
RdosCloseWait:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_wait_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCheckWait
#
# Purpose....: Check wait state
#
# Parameters.: Wait handle
#
# Returns....: Signalled ID or 0
#
##########################################################################*/
.global RdosCheckWait
RdosCheckWait:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
UserGate is_wait_idle_nr
movl %ecx,%eax
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosWaitForever
#
# Purpose....: Wait forever
#
# Parameters.: Wait handle
#
# Returns....: Signalled ID or 0
#
##########################################################################*/
.global RdosWaitForever
RdosWaitForever:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
UserGate wait_no_timeout_nr
jc rwfFail
movl %ecx,%eax
jmp rwfDone
rwfFail:
xorl %eax,%eax
rwfDone:
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosWaitTimeout
#
# Purpose....: Wait with timeout
#
# Parameters.: Wait handle
# Timeout in ms
#
# Returns....: Signalled ID or 0
#
##########################################################################*/
.global RdosWaitTimeout
RdosWaitTimeout:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movl 12(%ebp),%eax
movl $1193,%edx
mull %edx
pushl %edx
pushl %eax
UserGate get_system_time_nr
popl %ebx
addl %ebx,%eax
popl %ebx
adcl %ebx,%edx
movw 8(%ebp),%bx
UserGate wait_timeout_nr
jc rwtFail
movl %ecx,%eax
jmp rwtDone
rwtFail:
xorl %eax,%eax
rwtDone:
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosStopWait
#
# Purpose....: Stop wait
#
# Parameters.: Wait handle
#
##########################################################################*/
.global RdosStopWait
RdosStopWait:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate stop_wait_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosRemoveWait
#
# Purpose....: Remove wait object from wait handle
#
# Parameters.: Wait handle
# ID
#
##########################################################################*/
.global RdosRemoveWait
RdosRemoveWait:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
movl 12(%ebp),%ecx
UserGate remove_wait_nr
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateSignal
#
# Purpose....: Create signal object
#
# Returns....: Signal handle
#
##########################################################################*/
.global RdosCreateSignal
RdosCreateSignal:
pushl %ebp
movl %esp,%ebp
pushl %ebx
UserGate create_signal_nr
movzx %bx,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosResetSignal
#
# Purpose....: Reset signal
#
# Parameters.: Signal handle
#
##########################################################################*/
.global RdosResetSignal
RdosResetSignal:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate reset_signal_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosIsSignalled
#
# Purpose....: Check if signalled
#
# Parameters.: Signal handle
#
# Returns....: TRUE if signalled
#
##########################################################################*/
.global RdosIsSignalled
RdosIsSignalled:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate is_signalled_nr
jc risdFree
movl $1,%eax
jmp risdDone
risdFree:
xorl %eax,%eax
risdDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetSignal
#
# Purpose....: Set signal
#
# Parameters.: Signal handle
#
##########################################################################*/
.global RdosSetSignal
RdosSetSignal:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate set_signal_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosFreeSignal
#
# Purpose....: Free signal handle
#
# Parameters.: Signal handle
#
##########################################################################*/
.global RdosFreeSignal
RdosFreeSignal:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate free_signal_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddWaitForSignal
#
# Purpose....: Add signal object to wait handle
#
# Parameters.: Wait handle
# Signal handle
# ID
#
##########################################################################*/
.global RdosAddWaitForSignal
RdosAddWaitForSignal:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
movw 12(%ebp),%ax
movl 16(%ebp),%ecx
UserGate add_wait_for_signal_nr
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddWaitForKeyboard
#
# Purpose....: Add keyboard to wait handle
#
# Parameters.: Wait handle
# ID
#
##########################################################################*/
.global RdosAddWaitForKeyboard
RdosAddWaitForKeyboard:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
movl 12(%ebp),%ecx
UserGate add_wait_for_keyboard_nr
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddWaitForMouse
#
# Purpose....: Add mouse to wait handle
#
# Parameters.: Wait handle
# ID
#
##########################################################################*/
.global RdosAddWaitForMouse
RdosAddWaitForMouse:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
movl 12(%ebp),%ecx
UserGate add_wait_for_mouse_nr
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddWaitForCom
#
# Purpose....: Add com object to wait handle
#
# Parameters.: Wait handle
# Com handle
# ID
#
##########################################################################*/
.global RdosAddWaitForCom
RdosAddWaitForCom:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
movw 12(%ebp),%ax
movl 16(%ebp),%ecx
UserGate add_wait_for_com_nr
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddWaitForAdc
#
# Purpose....: Add ADC object to wait handle
#
# Parameters.: Wait handle
# Adc handle
# ID
#
##########################################################################*/
.global RdosAddWaitForAdc
RdosAddWaitForAdc:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
movw 12(%ebp),%ax
movl 16(%ebp),%ecx
UserGate add_wait_for_adc_nr
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetTextMode
#
# Purpose....: Set text mode
#
##########################################################################*/
.global RdosSetTextMode
RdosSetTextMode:
pushl %ebp
movl %esp,%ebp
movw $3,%ax
UserGate set_video_mode_nr
leave
ret
/*##########################################################################
#
# Name : RdosSetVideoMode
#
# Purpose....: Set video mode
#
# Parameters.: &xres
# &yres
# &linesize
# &LFB
#
# Returns....: Bitmap handle
#
##########################################################################*/
.global RdosSetVideoMode
RdosSetVideoMode:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movl 8(%ebp),%edi
movw (%edi),%ax
movl 12(%ebp),%edi
movw (%edi),%cx
movl 16(%ebp),%edi
movw (%edi),%dx
UserGate get_video_mode_nr
jc set_video_fail
UserGate set_video_mode_nr
jc set_video_fail
pushl %edi
movl 8(%ebp),%edi
movzx %ax,%eax
movl %eax,(%edi)
movl 12(%ebp),%edi
movzx %cx,%ecx
movl %ecx,(%edi)
movl 16(%ebp),%edi
movzx %dx,%edx
movl %edx,(%edi)
movl 20(%ebp),%edi
movzx %si,%esi
movl %esi,(%edi)
popl %edi
movl 24(%ebp),%eax
movl %edi,(%eax)
movzx %bx,%eax
jmp set_video_done
set_video_fail:
xorl %eax,%eax
movl 8(%ebp),%edi
movl %eax,(%edi)
movl 12(%ebp),%edi
movl %eax,(%edi)
movl 16(%ebp),%edi
movl %eax,(%edi)
movl 20(%ebp),%edi
movl %eax,(%edi)
movl 24(%ebp),%edi
movl %eax,(%edi)
set_video_done:
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetClipRect
#
# Purpose....: Set clip rectangle
#
# Parameters.: Bitmap handle
# xmin, xmax, ymin, ymax
#
##########################################################################*/
.global RdosSetClipRect
RdosSetClipRect:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
movw 20(%ebp),%si
movw 24(%ebp),%di
UserGate set_clip_rect_nr
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosClearClipRect
#
# Purpose....: Clear clip rectangle
#
# Parameters.: Bitmap handle
#
##########################################################################*/
.global RdosClearClipRect
RdosClearClipRect:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate clear_clip_rect_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetDrawColor
#
# Purpose....: Set draw color
#
# Parameters.: Bitmap handle
# Color
#
##########################################################################*/
.global RdosSetDrawColor
RdosSetDrawColor:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
movw 8(%ebp),%bx
movl 12(%ebp),%eax
UserGate set_drawcolor_nr
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosSetLGOP
#
# Purpose....: Set draw color
#
# Parameters.: Bitmap handle
# LGOP
#
##########################################################################*/
.global RdosSetLGOP
RdosSetLGOP:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
movw 8(%ebp),%bx
movw 12(%ebp),%ax
UserGate set_lgop_nr
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosSetHollowStyle
#
# Purpose....: Set hollow fill style
#
# Parameters.: Bitmap handle
#
##########################################################################*/
.global RdosSetHollowStyle
RdosSetHollowStyle:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate set_hollow_style_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetFilledStyle
#
# Purpose....: Set filled fill style
#
# Parameters.: Bitmap handle
#
##########################################################################*/
.global RdosSetFilledStyle
RdosSetFilledStyle:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate set_filled_style_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosOpenFont
#
# Purpose....: Open a font
#
# Parameters.: height
#
# Returns....: Font handle
#
##########################################################################*/
.global RdosOpenFont
RdosOpenFont:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%ax
UserGate open_font_nr
movzx %bx,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseFont
#
# Purpose....: Close font handle
#
# Parameters.: Font handle
#
##########################################################################*/
.global RdosCloseFont
RdosCloseFont:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_font_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetStringMetrics
#
# Purpose....: Get string metrics for text using font
#
# Parameters.: Font handle
# String
# &width
# &height
#
##########################################################################*/
.global RdosGetStringMetrics
RdosGetStringMetrics:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %edi
movw 8(%ebp),%bx
movl 12(%ebp),%edi
UserGate get_string_metrics_nr
movl 16(%ebp),%edi
movzx %cx,%ecx
movl %ecx,(%edi)
movl 20(%ebp),%edi
movzx %dx,%edx
movl %edx,(%edi)
popl %edi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetFont
#
# Purpose....: Set font
#
# Parameters.: Bitmap handle
# Font handle
#
##########################################################################*/
.global RdosSetFont
RdosSetFont:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
movw 8(%ebp),%bx
movw 12(%ebp),%ax
UserGate set_font_nr
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosGetPixel
#
# Purpose....: Get pixel
#
# Parameters.: Bitmap handle
# x, y
#
##########################################################################*/
.global RdosGetPixel
RdosGetPixel:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
UserGate get_pixel_nr
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetPixel
#
# Purpose....: Set pixel
#
# Parameters.: Bitmap handle
# x, y
#
##########################################################################*/
.global RdosSetPixel
RdosSetPixel:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
UserGate set_pixel_nr
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosBlit
#
# Purpose....: Blit
#
# Parameters.: SrcHandle
# DestHandle
# width, height
# SrcX, SrcY
# DestX, DestY
#
##########################################################################*/
.global RdosBlit
RdosBlit:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
;
movw 8(%ebp),%ax
movw 12(%ebp),%bx
movw 16(%ebp),%cx
movw 20(%ebp),%dx
movw 28(%ebp),%si
shll $16,%esi
movw 24(%ebp),%si
movw 36(%ebp),%di
shll $16,%edi
movw 32(%ebp),%di
UserGate blit_nr
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosDrawMask
#
# Purpose....: Draw mask
#
# Parameters.: Bitmap handle
# mask
# RowSize
# width, height
# SrcX, SrcY
# DestX, DestY
#
##########################################################################*/
.global RdosDrawMask
RdosDrawMask:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
;
movw 8(%ebp),%bx
movl 12(%ebp),%edi
movw 16(%ebp),%ax
movw 24(%ebp),%si
shll $16,%esi
movw 20(%ebp),%si
movw 32(%ebp),%cx
shll $16,%ecx
movw 28(%ebp),%cx
movw 40(%ebp),%dx
shll $16,%edx
movw 36(%ebp),%dx
UserGate draw_mask_nr
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosDrawLine
#
# Purpose....: Draw a line
#
# Parameters.: Bitmap handle
# x1, y1
# x2, y2
#
##########################################################################*/
.global RdosDrawLine
RdosDrawLine:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
;
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
movw 20(%ebp),%si
movw 24(%ebp),%di
UserGate draw_line_nr
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDrawString
#
# Purpose....: Draw a string
#
# Parameters.: Bitmap handle
# x, y
# string
#
##########################################################################*/
.global RdosDrawString
RdosDrawString:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %edi
;
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
movl 20(%ebp),%edi
UserGate draw_string_nr
popl %edi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDrawRect
#
# Purpose....: Draw a rect
#
# Parameters.: Bitmap handle
# x, y
# width, height
#
##########################################################################*/
.global RdosDrawRect
RdosDrawRect:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
movw 20(%ebp),%si
movw 24(%ebp),%di
UserGate draw_rect_nr
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDrawEllipse
#
# Purpose....: Draw an ellipse
#
# Parameters.: Bitmap handle
# x, y
# width, height
#
##########################################################################*/
.global RdosDrawEllipse
RdosDrawEllipse:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
movw 20(%ebp),%si
movw 24(%ebp),%di
UserGate draw_ellipse_nr
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateBitmap
#
# Purpose....: Create a bitmap
#
# Parameters.: BitsPerPixel
# width, height
#
# Returns....: Bitmap handle
#
##########################################################################*/
.global RdosCreateBitmap
RdosCreateBitmap:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movw 8(%ebp),%ax
movw 12(%ebp),%cx
movw 16(%ebp),%dx
UserGate create_bitmap_nr
movzx %bx,%eax
;
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDuplicateBitmapHandle
#
# Purpose....: Duplicate bitmap handle for use in another thread / object
#
# Parameters.: Bitmap handle
#
# Returns....: Bitmap handle
#
##########################################################################*/
.global RdosDuplicateBitmapHandle
RdosDuplicateBitmapHandle:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate dup_bitmap_handle_nr
movzx %bx,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseBitmap
#
# Purpose....: Close bitmap handle
#
# Parameters.: Bitmap handle
#
##########################################################################*/
.global RdosCloseBitmap
RdosCloseBitmap:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_bitmap_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateStringBitmap
#
# Purpose....: Create bitmap from string & font
#
# Parameters.: Font
# string
#
# Returns....: Bitmap handle
#
##########################################################################*/
.global RdosCreateStringBitmap
RdosCreateStringBitmap:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movw 8(%ebp),%bx
movl 12(%ebp),%edi
UserGate create_string_bitmap_nr
movzx %bx,%eax
;
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetBitmapInfo
#
# Purpose....: Get info about bitmap
#
# Parameters.: Bitmap handle
# &BitsPerPixel
# &width, &height
# &linesize
# &LFB
#
##########################################################################*/
.global RdosGetBitmapInfo
RdosGetBitmapInfo:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movw 8(%ebp),%bx
UserGate get_bitmap_info_nr
jc gbiFail
pushl %edi
movl 12(%ebp),%edi
movzx %al,%eax
movl %eax,(%edi)
movl 16(%ebp),%edi
movzx %cx,%ecx
movl %ecx,(%edi)
movl 20(%ebp),%edi
movzx %dx,%edx
movl %edx,(%edi)
movl 24(%ebp),%edi
movzx %si,%esi
movl %esi,(%edi)
popl %edi
movl 28(%ebp),%eax
movl %edi,(%eax)
jmp gbiDone
gbiFail:
xorl %eax,%eax
movl 12(%ebp),%edi
movl %eax,(%edi)
movl 16(%ebp),%edi
movl %eax,(%edi)
movl 20(%ebp),%edi
movl %eax,(%edi)
movl 24(%ebp),%edi
movl %eax,(%edi)
movl 28(%ebp),%edi
movl %eax,(%edi)
gbiDone:
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosCreateSprite
#
# Purpose....: Create a sprite
#
# Parameters.: dest
# bitmap
# mask
# LGOP
#
# Returns....: Sprite handle
#
##########################################################################*/
.global RdosCreateSprite
RdosCreateSprite:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
movw 20(%ebp),%ax
UserGate create_sprite_nr
movzx %bx,%eax
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseSprite
#
# Purpose....: Close sprite handle
#
# Parameters.: Sprite handle
#
##########################################################################*/
.global RdosCloseSprite
RdosCloseSprite:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_sprite_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosShowSprite
#
# Purpose....: Show sprite
#
# Parameters.: Sprite handle
#
##########################################################################*/
.global RdosShowSprite
RdosShowSprite:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate show_sprite_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosHideSprite
#
# Purpose....: Hide sprite
#
# Parameters.: Sprite handle
#
##########################################################################*/
.global RdosHideSprite
RdosHideSprite:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate hide_sprite_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosMoveSprite
#
# Purpose....: Move sprite
#
# Parameters.: Sprite handle
# x, y
#
##########################################################################*/
.global RdosMoveSprite
RdosMoveSprite:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movw 8(%ebp),%bx
movw 12(%ebp),%cx
movw 16(%ebp),%dx
UserGate move_sprite_nr
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetForeColor
#
# Purpose....: Set text-mode fore color
#
# Parameters.: palette index
#
##########################################################################*/
.global RdosSetForeColor
RdosSetForeColor:
pushl %ebp
movl %esp,%ebp
pushl %eax
movb 8(%ebp),%al
UserGate set_forecolor_nr
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosSetBackColor
#
# Purpose....: Set text-mode back color
#
# Parameters.: palette index
#
##########################################################################*/
.global RdosSetBackColor
RdosSetBackColor:
pushl %ebp
movl %esp,%ebp
pushl %eax
movb 8(%ebp),%al
UserGate set_backcolor_nr
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosGetSysTime
#
# Purpose....: Get system time
#
# Parameters.: &year, &month, &day
# &hour, &min, &sec, &ms
#
##########################################################################*/
.global RdosGetSysTime
RdosGetSysTime:
pushl %ebp
movl %esp,%ebp
pushal
UserGate get_system_time_nr
pushl %eax
UserGate binary_to_time_nr
pushl %edx
movl 8(%ebp),%esi
movzx %dx,%edx
movl %edx,(%esi)
movl 12(%ebp),%esi
movzx %ch,%edx
movl %edx,(%esi)
movl 16(%ebp),%esi
movzx %cl,%edx
movl %edx,(%esi)
movl 20(%ebp),%esi
movzx %bh,%edx
movl %edx,(%esi)
movl 24(%ebp),%esi
movzx %bl,%edx
movl %edx,(%esi)
movl 28(%ebp),%esi
movzx %ah,%edx
movl %edx,(%esi)
popl %edx
UserGate time_to_binary_nr
movl %eax,%ebx
popl %eax
subl %ebx,%eax
xorl %edx,%edx
movl $1192,%ebx
divl %ebx
movl 32(%ebp),%esi
movzx %ax,%eax
movl %eax,(%esi)
popal
leave
ret
/*##########################################################################
#
# Name : RdosGetTime
#
# Purpose....: Get time
#
# Parameters.: &year, &month, &day
# &hour, &min, &sec, &ms
#
##########################################################################*/
.global RdosGetTime
RdosGetTime:
pushl %ebp
movl %esp,%ebp
pushal
UserGate get_time_nr
pushl %eax
UserGate binary_to_time_nr
pushl %edx
movl 8(%ebp),%esi
movzx %dx,%edx
movl %edx,(%esi)
movl 12(%ebp),%esi
movzx %ch,%edx
movl %edx,(%esi)
movl 16(%ebp),%esi
movzx %cl,%edx
movl %edx,(%esi)
movl 20(%ebp),%esi
movzx %bh,%edx
movl %edx,(%esi)
movl 24(%ebp),%esi
movzx %bl,%edx
movl %edx,(%esi)
movl 28(%ebp),%esi
movzx %ah,%edx
movl %edx,(%esi)
popl %edx
UserGate time_to_binary_nr
movl %eax,%ebx
popl %eax
subl %ebx,%eax
xorl %edx,%edx
movl $1192,%ebx
divl %ebx
movl 32(%ebp),%esi
movzx %ax,%eax
movl %eax,(%esi)
popal
leave
ret
/*##########################################################################
#
# Name : RdosSetTime
#
# Purpose....: Set time
#
# Parameters.: year, month, day
# hour, min, sec, ms
#
##########################################################################*/
.global RdosSetTime
RdosSetTime:
pushl %ebp
movl %esp,%ebp
pushal
movw 8(%ebp),%dx
movb 12(%ebp),%ch
movb 16(%ebp),%cl
movb 20(%ebp),%bh
movb 24(%ebp),%bl
movb 28(%ebp),%ah
UserGate time_to_binary_nr
movl %edx,%edi
movl %eax,%esi
movl 32(%ebp),%eax
movl $1192,%edx
mull %edx
addl %eax,%esi
adcl $0,%edi
UserGate get_system_time_nr
subl %eax,%esi
sbbl %edx,%edi
movl %esi,%eax
movl %edi,%edx
UserGate update_time_nr
popal
leave
ret
/*##########################################################################
#
# Name : RdosTicsToRecord
#
# Purpose....: Convert tics to record format
#
# Parameters.: MSB, LSB
# &year, &month, &day
# &hour, &min, &sec, &ms
#
##########################################################################*/
.global RdosTicsToRecord
RdosTicsToRecord:
pushl %ebp
movl %esp,%ebp
pushal
movl 8(%ebp),%edx
movl 12(%ebp),%eax
addl $596,%eax
adcl $0,%edx
UserGate binary_to_time_nr
pushl %edx
movl 16(%ebp),%esi
movzx %dx,%edx
movl %edx,(%esi)
movl 20(%ebp),%esi
movzx %ch,%edx
movl %edx,(%esi)
movl 24(%ebp),%esi
movzx %cl,%edx
movl %edx,(%esi)
movl 28(%ebp),%esi
movzx %bh,%edx
movl %edx,(%esi)
movl 32(%ebp),%esi
movzx %bl,%edx
movl %edx,(%esi)
movl 36(%ebp),%esi
movzx %ah,%edx
movl %edx,(%esi)
popl %edx
UserGate time_to_binary_nr
movl %eax,%ebx
movl 12(%ebp),%eax
subl %edx,%eax
xorl %edx,%edx
movl $1192,%ebx
divl %ebx
movl 40(%ebp),%esi
cmpw %ax,1000
jne rttrSaveMs
decw %ax
rttrSaveMs:
movzx %ax,%eax
movl %eax,(%esi)
popal
leave
ret
/*##########################################################################
#
# Name : RdosRecordToTics
#
# Purpose....: Convert from record format to tics
#
# Parameters.: &MSB, &LSB
# year, month, day
# hour, min, sec, ms
#
##########################################################################*/
.global RdosRecordToTics
RdosRecordToTics:
pushl %ebp
movl %esp,%ebp
pushal
movl 40(%ebp),%eax
movl $1192,%edx
mull %edx
pushl %eax
movw 16(%ebp),%dx
movb 20(%ebp),%ch
movb 24(%ebp),%cl
movb 28(%ebp),%bh
movb 32(%ebp),%bl
movb 36(%ebp),%ah
UserGate time_to_binary_nr
popl %ebx
addl %ebx,%eax
adcl $0,%edx
movl 8(%ebp),%esi
movl %edx,(%esi)
movl 12(%ebp),%esi
movl %eax,(%esi)
popal
leave
ret
/*##########################################################################
#
# Name : RdosDecodeMsbTics
#
# Purpose....: Decode MSB tics
#
# Parameters.: MSB
# &day, &hour
#
##########################################################################*/
.global RdosDecodeMsbTics
RdosDecodeMsbTics:
pushl %ebp
movl %esp,%ebp
pushal
movl 8(%ebp),%eax
xorl %edx,%edx
movl $24,%ecx
divl %ecx
movl 12(%ebp),%ebx
movl %eax,(%ebx)
movl 16(%ebp),%ebx
movl %edx,(%ebx)
popal
leave
ret
/*##########################################################################
#
# Name : RdosDecodeLsbTics
#
# Purpose....: Decode LSB tics
#
# Parameters.: LSB
# &min, &sec, &ms, &us
#
##########################################################################*/
.global RdosDecodeLsbTics
RdosDecodeLsbTics:
pushl %ebp
movl %esp,%ebp
pushal
movl 8(%ebp),%eax
movl $60,%edx
mull %edx
movl 12(%ebp),%ebx
movl %edx,(%ebx)
movl $60,%edx
mull %edx
movl 16(%ebp),%ebx
movl %edx,(%ebx)
movl $1000,%edx
mull %edx
movl 20(%ebp),%ebx
movl %edx,(%ebx)
movl $1000,%edx
mull %edx
movl 24(%ebp),%ebx
movl %edx,(%ebx)
popal
leave
ret
/*##########################################################################
#
# Name : RdosDayOfWeek
#
# Purpose....: Get day of week
#
# Parameters.: year, month, day
#
# Returns....: day of week
#
##########################################################################*/
.global RdosDayOfWeek
RdosDayOfWeek:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movl 8(%ebp),%edx
movb 12(%ebp),%ch
movb 16(%ebp),%cl
xorw %bx,%bx
xorb %ah,%ah
UserGate adjust_time_nr
pushw %dx
movl $365,%eax
imulw %dx
pushw %dx
pushw %ax
popl %ebx
popw %dx
UserGate passed_days_nr
decw %dx
shrw $2,%dx
incw %dx
addw %dx,%ax
addl %ebx,%eax
xorl %edx,%edx
addl $5,%eax
movl $7,%ebx
divl %ebx
movzx %dl,%eax
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetTics
#
# Purpose....: Get system tics
#
# Parameters.: &MSB, &LSB
#
##########################################################################*/
.global RdosGetTics
RdosGetTics:
pushl %ebp
movl %esp,%ebp
pushl %edx
pushl %esi
UserGate get_time_nr
movl 8(%ebp),%esi
movl %edx,(%esi)
movl 12(%ebp),%esi
movl %eax,(%esi)
popl %esi
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosAddTics
#
# Purpose....: Add tics to binary time
#
# Parameters.: &MSB, &LSB
# tics
#
##########################################################################*/
.global RdosAddTics
RdosAddTics:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 16(%ebp),%eax
movl 12(%ebp),%ebx
addl %eax,(%ebx)
movl 8(%ebp),%ebx
adcl $0,(%ebx)
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddMilli
#
# Purpose....: Add milliseconds to binary time
#
# Parameters.: &MSB, &LSB
# milli
#
##########################################################################*/
.global RdosAddMilli
RdosAddMilli:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 16(%ebp),%eax
movl $1193,%edx
mull %edx
movl 12(%ebp),%ebx
addl %eax,(%ebx)
movl 8(%ebp),%ebx
adcl %edx,(%ebx)
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddSec
#
# Purpose....: Add milliseconds to binary time
#
# Parameters.: &MSB, &LSB
# sec
#
##########################################################################*/
.global RdosAddSec
RdosAddSec:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 16(%ebp),%eax
movl $1193000,%edx
mull %edx
movl 12(%ebp),%ebx
addl %eax,(%ebx)
movl 8(%ebp),%ebx
adcl %edx,(%ebx)
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddMin
#
# Purpose....: Add minutes to binary time
#
# Parameters.: &MSB, &LSB
# min
#
##########################################################################*/
.global RdosAddMin
RdosAddMin:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 16(%ebp),%eax
movl $71582760,%edx
mull %edx
movl 12(%ebp),%ebx
addl %eax,(%ebx)
movl 8(%ebp),%ebx
adcl %edx,(%ebx)
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddHour
#
# Purpose....: Add hour to binary time
#
# Parameters.: &MSB, &LSB
# hour
#
##########################################################################*/
.global RdosAddHour
RdosAddHour:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 16(%ebp),%eax
movl 8(%ebp),%ebx
adc %eax,(%ebx)
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddDay
#
# Purpose....: Add days to binary time
#
# Parameters.: &MSB, &LSB
# days
#
##########################################################################*/
.global RdosAddDay
RdosAddDay:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 16(%ebp),%eax
movl $24,%edx
mull %edx
movl 8(%ebp),%ebx
adc %eax,(%ebx)
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSyncTime
#
# Purpose....: Synchronize time with NTP
#
# Parameters.: IP
#
##########################################################################*/
.global RdosSyncTime
RdosSyncTime:
pushl %ebp
movl %esp,%ebp
pushal
movl 8(%ebp),%edx
UserGate sync_time_nr
jc RdosSyncTimeFail
movl $1,%eax
jmp RdosSyncTimeDone
RdosSyncTimeFail:
xorl %eax,%eax
RdosSyncTimeDone:
popal
leave
ret
/*##########################################################################
#
# Name : RdosOpenCom
#
# Purpose....: Open com-port
#
# Parameters.: ID
# baudrate
# parity
# data bits
# stop bits
# SendBufferSize
# RecBufferSize
#
# Returns...: Com handle
#
##########################################################################*/
.global RdosOpenCom
RdosOpenCom:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movb 8(%ebp),%al
movb 20(%ebp),%ah
movb 24(%ebp),%bl
movb 16(%ebp),%bh
movl 12(%ebp),%ecx
movw 28(%ebp),%si
movw 32(%ebp),%di
UserGate open_com_nr
movzx %bx,%eax
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseCom
#
# Purpose....: Close com-port
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosCloseCom
RdosCloseCom:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_com_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosFlushCom
#
# Purpose....: Flush com-port
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosFlushCom
RdosFlushCom:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate flush_com_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosReadCom
#
# Purpose....: Read com-port
#
# Parameters.: Com handle
#
# Returns....: Character
#
##########################################################################*/
.global RdosReadCom
RdosReadCom:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate read_com_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosWriteCom
#
# Purpose....: Write com-port
#
# Parameters.: Com handle
# char
#
# Returns....: 0 for success
#
##########################################################################*/
.global RdosWriteCom
RdosWriteCom:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
movb 12(%ebp),%al
UserGate write_com_nr
movzx %al,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosWaitForSendCompletedCom
#
# Purpose....: Wait until send buffer is empty
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosWaitForSendCompletedCom
RdosWaitForSendCompletedCom:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate wait_for_send_completed_com_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosEnableCts
#
# Purpose....: Enable CTS signal
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosEnableCts
RdosEnableCts:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate enable_cts_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDisableCts
#
# Purpose....: Disable CTS signal
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosDisableCts
RdosDisableCts:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate disable_cts_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosEnableAutoRts
#
# Purpose....: Enable auto RTS signal generation for RS485
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosEnableAutoRts
RdosEnableAutoRts:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate enable_auto_rts_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDisableAutoRts
#
# Purpose....: Disable auto RTS signal generation for RS485
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosDisableAutoRts
RdosDisableAutoRts:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate disable_auto_rts_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetDtr
#
# Purpose....: Set DTR active
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosSetDtr
RdosSetDtr:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate set_dtr_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosResetDtr
#
# Purpose....: Set DTR inactive
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosResetDtr
RdosResetDtr:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate reset_dtr_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetRts
#
# Purpose....: Set RTS active
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosSetRts
RdosSetRts:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate set_rts_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosResetRts
#
# Purpose....: Set RTS inactive
#
# Parameters.: Com handle
#
##########################################################################*/
.global RdosResetRts
RdosResetRts:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate reset_rts_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetReceiveBufferSpace
#
# Purpose....: Get receive buffer free space
#
# Parameters.: Com handle
#
# Returns....: Free bytes
#
##########################################################################*/
.global RdosGetReceiveBufferSpace
RdosGetReceiveBufferSpace:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_com_receive_space_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetSendBufferSpace
#
# Purpose....: Get send buffer free space
#
# Parameters.: Com handle
#
# Returns....: Free bytes
#
##########################################################################*/
.global RdosGetSendBufferSpace
RdosGetSendBufferSpace:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_com_send_space_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosOpenFile
#
# Purpose....: Open file
#
# Parameters.: Filename
# Access
#
# Returns...: File handle
#
##########################################################################*/
.global RdosOpenFile
RdosOpenFile:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
movb 12(%ebp),%cl
UserGate open_file_nr
jc OpenFileFailed
movzx %bx,%eax
jmp OpenFileDone
OpenFileFailed:
xorl %eax,%eax
OpenFileDone:
popl %edi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateFile
#
# Purpose....: Create file
#
# Parameters.: Filename
# Attribute
#
# Returns...: File handle
#
##########################################################################*/
.global RdosCreateFile
RdosCreateFile:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
movw 12(%ebp),%cx
UserGate create_file_nr
jc CreateFileFailed
movzx %bx,%eax
jmp CreateFileDone
CreateFileFailed:
xorl %eax,%eax
CreateFileDone:
popl %edi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseFile
#
# Purpose....: Close file
#
# Parameters.: File handle
#
##########################################################################*/
.global RdosCloseFile
RdosCloseFile:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_file_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosIsDevice
#
# Purpose....: Check if file is device
#
# Parameters.: TRUE if device
#
##########################################################################*/
.global RdosIsDevice
RdosIsDevice:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_ioctl_data_nr
testw $0x8000,%dx
jz ridFail
movl $1,%eax
jmp ridDone
ridFail:
xorl %eax,%eax
ridDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDuplFile
#
# Purpose....: Duplicate file handle
#
# Parameters.: File handle
#
# Returns....: File handle
#
##########################################################################*/
.global RdosDuplFile
RdosDuplFile:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate dupl_file_nr
jc DuplFileFailed
movzx %bx,%eax
jmp DuplFileDone
DuplFileFailed:
xorl %eax,%eax
DuplFileDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetFileSize
#
# Purpose....: Get file size
#
# Parameters.: File handle
#
# Returns....: Size
#
##########################################################################*/
.global RdosGetFileSize
RdosGetFileSize:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_file_size_nr
jnc GetFileSizeDone
GetFileSizeFail:
xorl %eax,%eax
GetFileSizeDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetFileSize
#
# Purpose....: Set file size
#
# Parameters.: File handle
# Size
#
##########################################################################*/
.global RdosSetFileSize
RdosSetFileSize:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
movw 8(%ebp),%bx
movl 12(%ebp),%eax
UserGate set_file_size_nr
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosGetFilePos
#
# Purpose....: Get file position
#
# Parameters.: File handle
#
# Returns....: Position
#
##########################################################################*/
.global RdosGetFilePos
RdosGetFilePos:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_file_pos_nr
jnc GetFilePosDone
GetFilePosFail:
xorl %eax,%eax
GetFilePosDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetFilePos
#
# Purpose....: Set file position
#
# Parameters.: File handle
# Position
#
##########################################################################*/
.global RdosSetFilePos
RdosSetFilePos:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
movw 8(%ebp),%bx
movl 12(%ebp),%eax
UserGate set_file_pos_nr
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosGetFileTime
#
# Purpose....: Get file time & date
#
# Parameters.: File handle
# &MSB, &LSB
#
##########################################################################*/
.global RdosGetFileTime
RdosGetFileTime:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movw 8(%ebp),%bx
UserGate get_file_time_nr
jc GetFileTimeDone
movl 12(%ebp),%edi
movl %edx,(%edi)
movl 16(%ebp),%edi
movl %eax,(%edi)
GetFileTimeDone:
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetFileTime
#
# Purpose....: Set file time & date
#
# Parameters.: File handle
# MSB, LSB
#
##########################################################################*/
.global RdosSetFileTime
RdosSetFileTime:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
pushl %edx
movw 8(%ebp),%bx
movl 12(%ebp),%edx
movl 16(%ebp),%eax
UserGate set_file_time_nr
popl %edx
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosReadFile
#
# Purpose....: Read from file
#
# Parameters.: File handle
# buffer
# count
#
# Returns....: Read count
#
##########################################################################*/
.global RdosReadFile
RdosReadFile:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edi
movw 8(%ebp),%bx
movl 12(%ebp),%edi
movl 16(%ebp),%ecx
UserGate read_file_nr
popl %edi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosWriteFile
#
# Purpose....: Write to file
#
# Parameters.: File handle
# buffer
# count
#
# Returns....: Written count
#
##########################################################################*/
.global RdosWriteFile
RdosWriteFile:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edi
movw 8(%ebp),%bx
movl 12(%ebp),%edi
movl 16(%ebp),%ecx
UserGate write_file_nr
popl %edi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateMapping
#
# Purpose....: Create file mapping
#
# Parameters.: Size
#
# Returns...: Filemap handle
#
##########################################################################*/
.global RdosCreateMapping
RdosCreateMapping:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%eax
UserGate create_mapping_nr
movzx %bx,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateNamedMapping
#
# Purpose....: Create named file mapping
#
# Parameters.: Name
# Size
#
# Returns...: Filemap handle
#
##########################################################################*/
.global RdosCreateNamedMapping
RdosCreateNamedMapping:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movl 8(%ebp),%edi
movl 12(%ebp),%eax
UserGate create_named_mapping_nr
movzx %bx,%eax
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateNamedFileMapping
#
# Purpose....: Create file named file mapping
#
# Parameters.: Name
# Size
# File handle
#
# Returns...: Filemap handle
#
##########################################################################*/
.global RdosCreateNamedFileMapping
RdosCreateNamedFileMapping:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movl 8(%ebp),%edi
movl 12(%ebp),%eax
movw 16(%ebp),%bx
UserGate create_named_file_mapping_nr
movzx %bx,%eax
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosOpenNamedMapping
#
# Purpose....: Open named file mapping
#
# Parameters.: Name
#
# Returns...: Filemap handle
#
##########################################################################*/
.global RdosOpenNamedMapping
RdosOpenNamedMapping:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movl 8(%ebp),%edi
UserGate open_named_mapping_nr
movzx %bx,%eax
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSyncMapping
#
# Purpose....: Sync file mapping
#
# Parameters.: Filemap handle
#
##########################################################################*/
.global RdosSyncMapping
RdosSyncMapping:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate sync_mapping_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseMapping
#
# Purpose....: Close file mapping
#
# Parameters.: Filemap handle
#
##########################################################################*/
.global RdosCloseMapping
RdosCloseMapping:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_mapping_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosMapView
#
# Purpose....: Map view of file into memory
#
# Parameters.: Filemap handle
# Offset
# Address
# Size
#
##########################################################################*/
.global RdosMapView
RdosMapView:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edi
movw 8(%ebp),%bx
movl 12(%ebp),%eax
movl 16(%ebp),%edi
movl 20(%ebp),%ecx
UserGate map_view_nr
popl %edi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosUnmapView
#
# Purpose....: Unmap view of file
#
# Parameters.: Filemap handle
#
##########################################################################*/
.global RdosUnmapView
RdosUnmapView:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate unmap_view_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetCurDrive
#
# Purpose....: Set current drive
#
# Parameters.: Drive
#
##########################################################################*/
.global RdosSetCurDrive
RdosSetCurDrive:
pushl %ebp
movl %esp,%ebp
movb 8(%ebp),%al
UserGate set_cur_drive_nr
jc rscdrFail
movl $1,%eax
jmp rscdrDone
rscdrFail:
xorl %eax,%eax
rscdrDone:
leave
ret
/*##########################################################################
#
# Name : RdosGetCurDrive
#
# Purpose....: Get current drive
#
# Returns....: Drive
#
##########################################################################*/
.global RdosGetCurDrive
RdosGetCurDrive:
pushl %ebp
movl %esp,%ebp
xorl %eax,%eax
UserGate get_cur_drive_nr
movzx %al,%eax
leave
ret
/*##########################################################################
#
# Name : RdosSetCurDir
#
# Purpose....: Set current directory
#
# Parameters.: Pathname
#
##########################################################################*/
.global RdosSetCurDir
RdosSetCurDir:
pushl %ebp
movl %esp,%ebp
pushl %edi
movl 8(%ebp),%edi
UserGate set_cur_dir_nr
jc rscdFail
movl $1,%eax
jmp rscdDone
rscdFail:
xorl %eax,%eax
rscdDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosGetCurDir
#
# Purpose....: Get current directory
#
# Parameters.: Drive
# Pathname
#
##########################################################################*/
.global RdosGetCurDir
RdosGetCurDir:
pushl %ebp
movl %esp,%ebp
pushl %edi
movb 8(%ebp),%al
movl 12(%ebp),%edi
UserGate get_cur_dir_nr
jc rgcdFail
movl $1,%eax
jmp rgcdDone
rgcdFail:
xorl %eax,%eax
rgcdDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosMakeDir
#
# Purpose....: Create directory
#
# Parameters.: Pathname
#
##########################################################################*/
.global RdosMakeDir
RdosMakeDir:
pushl %ebp
movl %esp,%ebp
pushl %edi
movl 8(%ebp),%edi
UserGate make_dir_nr
jc mdFail
movl $1,%eax
jmp mdDone
mdFail:
xorl %eax,%eax
mdDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosRemoveDir
#
# Purpose....: Remove directory
#
# Parameters.: Pathname
#
##########################################################################*/
.global RdosRemoveDir
RdosRemoveDir:
pushl %ebp
movl %esp,%ebp
pushl %edi
movl 8(%ebp),%edi
UserGate remove_dir_nr
jc rdFail
movl $1,%eax
jmp rdDone
rdFail:
xorl %eax,%eax
rdDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosRenameFile
#
# Purpose....: Rename file
#
# Parameters.: ToName
# FromName
#
##########################################################################*/
.global RdosRenameFile
RdosRenameFile:
pushl %ebp
movl %esp,%ebp
pushl %esi
pushl %edi
movl 8(%ebp),%edi
movl 12(%ebp),%esi
UserGate rename_file_nr
jc rfFail
mov $1,%eax
jmp rfDone
rfFail:
xorl %eax,%eax
rfDone:
popl %edi
popl %esi
leave
ret
/*##########################################################################
#
# Name : RdosDeleteFile
#
# Purpose....: Delete file
#
# Parameters.: Pathname
#
##########################################################################*/
.global RdosDeleteFile
RdosDeleteFile:
pushl %ebp
movl %esp,%ebp
pushl %edi
movl 8(%ebp),%edi
UserGate delete_file_nr
jc dfFail
mov $1,%eax
jmp dfDone
dfFail:
xorl %eax,%eax
dfDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosGetFileAttribute
#
# Purpose....: Get file attribute
#
# Parameters.: Pathname
# &Attrib
#
##########################################################################*/
.global RdosGetFileAttribute
RdosGetFileAttribute:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
UserGate get_file_attribute_nr
jc gfaFail
movl 12(%ebp),%edi
movzx %cx,%ecx
movl %ecx,(%edi)
movl $1,%eax
jmp gfaDone
gfaFail:
xorl %eax,%eax
gfaDone:
popl %edi
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosSetFileAttribute
#
# Purpose....: Set file attribute
#
# Parameters.: Pathname
# Attrib
#
##########################################################################*/
.global RdosSetFileAttribute
RdosSetFileAttribute:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
movw 12(%ebp),%cx
UserGate set_file_attribute_nr
jc sfaFail
movl $1,%eax
jmp sfaDone
sfaFail:
xorl %eax,%eax
sfaDone:
popl %edi
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosOpenDir
#
# Purpose....: Open directory
#
# Parameters.: Pathname
#
# Returns....: Dir handle
#
##########################################################################*/
.global RdosOpenDir
RdosOpenDir:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movl 8(%ebp),%edi
UserGate open_dir_nr
jc odFail
movzx %bx,%eax
jmp odDone
odFail:
xorl %eax,%eax
odDone:
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseDir
#
# Purpose....: Close directory
#
# Parameters.: Dir handle
#
##########################################################################*/
.global RdosCloseDir
RdosCloseDir:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_dir_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosReadDir
#
# Purpose....: Read directory entry
#
# Parameters.: Dir handle
# Entry #
# MaxNameSize
# Name buffer
# &FileSize
# &Attribute
# &Msb time
# &Lsb time
#
##########################################################################*/
.global RdosReadDir
RdosReadDir:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edi
movw 8(%ebp),%bx
movw 12(%ebp),%dx
movw 16(%ebp),%cx
movl 20(%ebp),%edi
UserGate read_dir_nr
jc rdiFail
movl 24(%ebp),%edi
movl %ecx,(%edi)
movl 28(%ebp),%edi
movzx %bx,%ebx
movl %ebx,(%edi)
movl 32(%ebp),%edi
movl %edx,(%edi)
movl 36(%ebp),%edi
movl %eax,(%edi)
movl $1,%eax
jmp rdiDone
rdiFail:
xorl %eax,%eax
rdiDone:
popl %edi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetFocus
#
# Purpose....: Set input focus
#
# Parameters.: Focus handle
#
##########################################################################*/
.global RdosSetFocus
RdosSetFocus:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
UserGate set_focus_nr
leave
ret
/*##########################################################################
#
# Name : RdosGetFocus
#
# Purpose....: Get input focus
#
# Returns....: Focus handle
#
##########################################################################*/
.global RdosGetFocus
RdosGetFocus:
pushl %ebp
movl %esp,%ebp
UserGate get_focus_nr
leave
ret
/*##########################################################################
#
# Name : RdosClearKeyboard
#
# Purpose....: Clear keyboard buffer
#
##########################################################################*/
.global RdosClearKeyboard
RdosClearKeyboard:
pushl %ebp
movl %esp,%ebp
UserGate flush_keyboard_nr
leave
ret
/*##########################################################################
#
# Name : RdosPollKeyboard
#
# Purpose....: Poll keyboard buffer
#
# Returns....: TRUE if non-empty
#
##########################################################################*/
.global RdosPollKeyboard
RdosPollKeyboard:
pushl %ebp
movl %esp,%ebp
UserGate poll_keyboard_nr
jc rpkEmpty
mov $1,%eax
jmp rpkDone
rpkEmpty:
xorl %eax,%eax
rpkDone:
leave
ret
/*##########################################################################
#
# Name : RdosReadKeyboard
#
# Purpose....: Read keyboard buffer
#
# Returns....: Scan code
#
##########################################################################*/
.global RdosReadKeyboard
RdosReadKeyboard:
pushl %ebp
movl %esp,%ebp
UserGate read_keyboard_nr
movzx %ax,%eax
leave
ret
/*##########################################################################
#
# Name : RdosGetKeyboardState
#
# Purpose....: Get keyboard buffer
#
# Returns....: Keyboard state
#
##########################################################################*/
.global RdosGetKeyboardState
RdosGetKeyboardState:
pushl %ebp
movl %esp,%ebp
UserGate get_keyboard_state_nr
movzx %ax,%eax
leave
ret
/*##########################################################################
#
# Name : RdosPutKeyboard
#
# Purpose....: Put scancode in keyboard buffer
#
##########################################################################*/
.global RdosPutKeyboard
RdosPutKeyboard:
pushl %ebp
movl %esp,%ebp
pushl %edx
movw 8(%ebp),%ax
movb 12(%ebp),%dl
movb 16(%ebp),%dh
UserGate put_keyboard_code_nr
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosPeekKeyEvent
#
# Purpose....: Peek keyboard event
#
##########################################################################*/
.global RdosPeekKeyEvent
RdosPeekKeyEvent:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
pushl %edi
UserGate peek_key_event_nr
jc rpeFail
movl 8(%ebp),%edi
movzx %ax,%eax
movl %eax,(%edi)
movl 12(%ebp),%edi
movzx %cx,%eax
movl %eax,(%edi)
movl 16(%ebp),%edi
movzx %dl,%eax
movl %eax,(%edi)
movl 20(%ebp),%edi
movzx %dh,%eax
movl %eax,(%edi)
movl $1,%eax
jmp rpeDone
rpeFail:
xorl %eax,%eax
rpeDone:
popl %edi
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosReadKeyEvent
#
# Purpose....: Read keyboard event
#
##########################################################################*/
.global RdosReadKeyEvent
RdosReadKeyEvent:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
pushl %edi
UserGate read_key_event_nr
jc rkeFail
movl 8(%ebp),%edi
movzx %ax,%eax
movl %eax,(%edi)
movl 12(%ebp),%edi
movzx %cx,%eax
movl %eax,(%edi)
movl 16(%ebp),%edi
movzx %dl,%eax
movl %eax,(%edi)
movl 20(%ebp),%edi
movzx %dh,%eax
movl %eax,(%edi)
movl $1,%eax
jmp rkeDone
rkeFail:
xorl %eax,%eax
rkeDone:
popl %edi
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosHideMouse
#
# Purpose....: Hide mouse cursor
#
##########################################################################*/
.global RdosHideMouse
RdosHideMouse:
pushl %ebp
movl %esp,%ebp
UserGate hide_mouse_nr
leave
ret
/*##########################################################################
#
# Name : RdosShowMouse
#
# Purpose....: Show mouse cursor
#
##########################################################################*/
.global RdosShowMouse
RdosShowMouse:
pushl %ebp
movl %esp,%ebp
UserGate show_mouse_nr
leave
ret
/*##########################################################################
#
# Name : RdosGetMousePosition
#
# Purpose....: Get mouse position
#
# Parameters.: &x, &y
#
##########################################################################*/
.global RdosGetMousePosition
RdosGetMousePosition:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
UserGate get_mouse_position_nr
movl 8(%ebp),%eax
movzx %cx,%ecx
movl %ecx,(%eax)
movl 12(%ebp),%eax
movzx %dx,%edx
movl %edx,(%eax)
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosSetMousePosition
#
# Purpose....: Set mouse position
#
# Parameters.: x, y
#
##########################################################################*/
.global RdosSetMousePosition
RdosSetMousePosition:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
movw 8(%ebp),%cx
movw 12(%ebp),%dx
UserGate set_mouse_position_nr
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosSetMouseWindow
#
# Purpose....: Set mouse window
#
# Parameters.: start x, start y
# end x, end y
#
##########################################################################*/
.global RdosSetMouseWindow
RdosSetMouseWindow:
pushl %ebp
movl %esp,%ebp
pushl %eax
pushl %ebx
pushl %ecx
pushl %edx
movw 8(%ebp),%ax
movw 12(%ebp),%bx
movw 16(%ebp),%cx
movw 20(%ebp),%dx
UserGate set_mouse_window_nr
popl %edx
popl %ecx
popl %ebx
popl %eax
leave
ret
/*##########################################################################
#
# Name : RdosSetMouseMickey
#
# Purpose....: Set mouse mickey
#
# Parameters.: x, y
#
##########################################################################*/
.global RdosSetMouseMickey
RdosSetMouseMickey:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
movw 8(%ebp),%cx
movw 12(%ebp),%dx
UserGate set_mouse_mickey_nr
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosGetCursorPosition
#
# Purpose....: Get cursor position
#
# Parameters.: &x, &y
#
##########################################################################*/
.global RdosGetCursorPosition
RdosGetCursorPosition:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
UserGate get_cursor_position_nr
movl 8(%ebp),%eax
movzx %cx,%ecx
movl %ecx,(%eax)
movl 12(%ebp),%eax
movzx %dx,%edx
movl %edx,(%eax)
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosSetCursorPosition
#
# Purpose....: Set cursor position
#
# Parameters.: x, y
#
##########################################################################*/
.global RdosSetCursorPosition
RdosSetCursorPosition:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
movw 8(%ebp),%cx
movw 12(%ebp),%dx
UserGate set_cursor_position_nr
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosGetLeftButton
#
# Purpose....: Check if left button is pressed
#
# Returns....: TRUE if pressed
#
##########################################################################*/
.global RdosGetLeftButton
RdosGetLeftButton:
pushl %ebp
movl %esp,%ebp
UserGate get_left_button_nr
jc get_left_rel
mov $1,%eax
jmp get_left_done
get_left_rel:
xorl %eax,%eax
get_left_done:
leave
ret
/*##########################################################################
#
# Name : RdosGetRightButton
#
# Purpose....: Check if right button is pressed
#
# Returns....: TRUE if pressed
#
##########################################################################*/
.global RdosGetRightButton
RdosGetRightButton:
pushl %ebp
movl %esp,%ebp
UserGate get_right_button_nr
jc get_right_rel
mov $1,%eax
jmp get_right_done
get_right_rel:
xorl %eax,%eax
get_right_done:
leave
ret
/*##########################################################################
#
# Name : RdosGetLeftButtonPressPosition
#
# Purpose....: Get left button press position
#
# Parameters.: &x, &y
#
##########################################################################*/
.global RdosGetLeftButtonPressPosition
RdosGetLeftButtonPressPosition:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
UserGate get_left_button_press_position_nr
movl 8(%ebp),%eax
movzx %cx,%ecx
movl %ecx,(%eax)
movl 12(%ebp),%eax
movzx %dx,%edx
movl %edx,(%eax)
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosGetRightButtonPressPosition
#
# Purpose....: Get right button press position
#
# Parameters.: &x, &y
#
##########################################################################*/
.global RdosGetRightButtonPressPosition
RdosGetRightButtonPressPosition:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
UserGate get_right_button_press_position_nr
movl 8(%ebp),%eax
movzx %cx,%ecx
movl %ecx,(%eax)
movl 12(%ebp),%eax
movzx %dx,%edx
movl %edx,(%eax)
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosGetLeftButtonReleasePosition
#
# Purpose....: Get left button release position
#
# Parameters.: &x, &y
#
##########################################################################*/
.global RdosGetLeftButtonReleasePosition
RdosGetLeftButtonReleasePosition:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
UserGate get_left_button_release_position_nr
movl 8(%ebp),%eax
movzx %cx,%ecx
movl %ecx,(%eax)
movl 12(%ebp),%eax
movzx %dx,%edx
movl %edx,(%eax)
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosGetRightButtonReleasePosition
#
# Purpose....: Get right button release position
#
# Parameters.: &x, &y
#
##########################################################################*/
.global RdosGetRightButtonReleasePosition
RdosGetRightButtonReleasePosition:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
UserGate get_right_button_release_position_nr
movl 8(%ebp),%eax
movzx %cx,%ecx
movl %ecx,(%eax)
movl 12(%ebp),%eax
movzx %dx,%edx
movl %edx,(%eax)
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosReadLine
#
# Purpose....: Read a line from keyboard
#
# Parameters.: Buffer
# Size
#
# Returns....: Read count
#
##########################################################################*/
.global RdosReadLine
RdosReadLine:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
movl 12(%ebp),%ecx
UserGate read_con_nr
popl %edi
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosWriteChar
#
# Purpose....: Write a character to screen
#
# Parameters.: Char
#
##########################################################################*/
.global RdosWriteChar
RdosWriteChar:
pushl %ebp
movl %esp,%ebp
movb 8(%ebp),%al
UserGate write_char_nr
leave
ret
/*##########################################################################
#
# Name : RdosWriteSizeString
#
# Purpose....: Write a fixed number of characters to screen
#
# Parameters.: String
# Count
#
##########################################################################*/
.global RdosWriteSizeString
RdosWriteSizeString:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
movl 12(%ebp),%ecx
UserGate write_size_string_nr
popl %edi
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosWriteString
#
# Purpose....: Write a string to screen
#
# Parameters.: String
#
##########################################################################*/
.global RdosWriteString
RdosWriteString:
pushl %ebp
movl %esp,%ebp
pushl %edi
movl 8(%ebp),%edi
UserGate write_asciiz_nr
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosNameToIp
#
# Purpose....: Convert host name to IP address
#
# Parameters.: Name
#
# Returns....: IP
#
##########################################################################*/
.global RdosNameToIp
RdosNameToIp:
pushl %ebp
movl %esp,%ebp
pushl %edi
movl 8(%ebp),%edi
UserGate name_to_ip_nr
jc rntiFail
movl %edx,%eax
jmp rntiDone
rntiFail:
xorl %eax,%eax
rntiDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosGetIp
#
# Purpose....: Get my IP
#
# Returns....: IP
#
##########################################################################*/
.global RdosGetIp
RdosGetIp:
pushl %ebp
movl %esp,%ebp
UserGate get_ip_address_nr
movl %edx,%eax
leave
ret
/*##########################################################################
#
# Name : RdosIpToName
#
# Purpose....: Convert IP address to host name
#
# Parameters.: IP
# Name
# Size
#
##########################################################################*/
.global RdosIpToName
RdosIpToName:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
pushl %edi
;
movl 8(%ebp),%edx
movl 12(%ebp),%edi
movl 16(%ebp),%ecx
UserGate ip_to_name_nr
jnc ritnDone
ritnFail:
xorl %eax,%eax
ritnDone:
popl %edi
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosPing
#
# Purpose....: Ping node
#
# Parameters.: IP
# Timeout
#
##########################################################################*/
.global RdosPing
RdosPing:
pushl %ebp
movl %esp,%ebp
pushl %edx
;
movl 8(%ebp),%edx
movl 12(%ebp),%eax
UserGate ping_nr
jc ping_failed
movl $1,%eax
jmp ping_done
ping_failed:
xorl %eax,%eax
ping_done:
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosOpenTcpConnection
#
# Purpose....: Open an active connection over TCP
#
# Parameters.: RemoteIp
# LocalPort
# RemotePort
# Timeout in ms
# BufferSize
#
# Returns....: Conn handle
#
##########################################################################*/
.global RdosOpenTcpConnection
RdosOpenTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
pushl %edi
movl 8(%ebp),%edx
movw 12(%ebp),%si
movw 16(%ebp),%di
movl 20(%ebp),%eax
movl 24(%ebp),%ecx
UserGate open_tcp_connection_nr
mov $0,%eax
jc rotcDone
movl %ebx,%eax
rotcDone:
popl %edi
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateTcpListen
#
# Purpose....: Create listen handle
#
# Parameters.: Port
# MaxConnections
# BufferSize
#
# Returns....: Listen handle
#
##########################################################################*/
.global RdosCreateTcpListen
RdosCreateTcpListen:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
movw 8(%ebp),%si
movw 12(%ebp),%ax
movl 16(%ebp),%ecx
UserGate create_tcp_listen_nr
movzx %bx,%eax
jnc ctlDone
xorl %eax,%eax
ctlDone:
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetTcpListen
#
# Purpose....: Get connection from listen
#
# Parameters.: Listen handle
#
# Returns....: Conn handle
#
##########################################################################*/
.global RdosGetTcpListen
RdosGetTcpListen:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_tcp_listen_nr
movzx %ax,%eax
jnc gtlDone
xorl %eax,%eax
gtlDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseTcpListen
#
# Purpose....: Close TCP listen
#
# Parameters.: Listen handle
#
##########################################################################*/
.global RdosCloseTcpListen
RdosCloseTcpListen:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_tcp_listen_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddWaitForTcpListen
#
# Purpose....: Add wait object to tcp listen
#
# Parameters.: Wait handle
# Listen handle
# ID
#
##########################################################################*/
.global RdosAddWaitForTcpListen
RdosAddWaitForTcpListen:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
movw 12(%ebp),%ax
movl 16(%ebp),%ecx
UserGate add_wait_for_tcp_listen_nr
movl $1,%eax
jnc awftlDone
xorl %eax,%eax
awftlDone:
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosWaitForTcpConnection
#
# Purpose....: Wait for Tcp connection to be established
#
# Parameters.: Conn handle
# Timeout ms
#
##########################################################################*/
.global RdosWaitForTcpConnection
RdosWaitForTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
movl 12(%ebp),%eax
UserGate wait_for_tcp_connection_nr
movl $1,%eax
jnc wftcDone
xorl %eax,%eax
wftcDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddWaitForTcpConnection
#
# Purpose....: Add wait object to tcp connection
#
# Parameters.: Wait handle
# Conn handle
# ID
#
##########################################################################*/
.global RdosAddWaitForTcpConnection
RdosAddWaitForTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movw 8(%ebp),%bx
movw 12(%ebp),%ax
movl 16(%ebp),%ecx
UserGate add_wait_for_tcp_connection_nr
movl $1,%eax
jnc awftcDone
xorl %eax,%eax
awftcDone:
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseTcpConnection
#
# Purpose....: Close Tcp connection
#
# Parameters.: Conn handle
#
##########################################################################*/
.global RdosCloseTcpConnection
RdosCloseTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate close_tcp_connection_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDeleteTcpConnection
#
# Purpose....: Delete Tcp connection
#
# Parameters.: Conn handle
#
##########################################################################*/
.global RdosDeleteTcpConnection
RdosDeleteTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate delete_tcp_connection_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAbortTcpConnection
#
# Purpose....: Abort Tcp connection
#
# Parameters.: Conn handle
#
##########################################################################*/
.global RdosAbortTcpConnection
RdosAbortTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate abort_tcp_connection_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosPushTcpConnection
#
# Purpose....: Push Tcp connection
#
# Parameters.: Conn handle
#
##########################################################################*/
.global RdosPushTcpConnection
RdosPushTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate push_tcp_connection_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosPollTcpConnection
#
# Purpose....: Poll Tcp connection
#
# Parameters.: Conn handle
#
# Returns....: Available bytes in receive buffer
#
##########################################################################*/
.global RdosPollTcpConnection
RdosPollTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate poll_tcp_connection_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosIsTcpConnectionClosed
#
# Purpose....: Check if connection is closed
#
# Parameters.: Conn handle
#
# Returns....: TRUE if closed
#
##########################################################################*/
.global RdosIsTcpConnectionClosed
RdosIsTcpConnectionClosed:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate is_tcp_connection_closed_nr
jc rptcClosed
xorl %eax,%eax
jmp rptcDone
rptcClosed:
movl $1,%eax
rptcDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetRemoteTcpConnectionIp
#
# Purpose....: Get remote IP
#
# Parameters.: Conn handle
#
# Returns....: IP
#
##########################################################################*/
.global RdosGetRemoteTcpConnectionIp
RdosGetRemoteTcpConnectionIp:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_remote_tcp_connection_ip_nr
jnc grtciDone
movl $0xFFFFFFFF,%eax
grtciDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetRemoteTcpConnectionPort
#
# Purpose....: Get remote port
#
# Parameters.: Conn handle
#
# Returns....: Port
#
##########################################################################*/
.global RdosGetRemoteTcpConnectionPort
RdosGetRemoteTcpConnectionPort:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_remote_tcp_connection_port_nr
jnc grtcpDone
movl $0,%eax
grtcpDone:
movzx %ax,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetLocalTcpConnectionPort
#
# Purpose....: Get local port
#
# Parameters.: Conn handle
#
# Returns....: Port
#
##########################################################################*/
.global RdosGetLocalTcpConnectionPort
RdosGetLocalTcpConnectionPort:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movw 8(%ebp),%bx
UserGate get_local_tcp_connection_port_nr
jnc gltcpDone
movl $0,%eax
gltcpDone:
movzx %ax,%eax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosReadTcpConnection
#
# Purpose....: Read data from connection
#
# Parameters.: Conn handle
# Buffer
# Size
#
# Returns....: Read bytes
#
##########################################################################*/
.global RdosReadTcpConnection
RdosReadTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edi
movw 8(%ebp),%bx
movl 12(%ebp),%edi
movl 16(%ebp),%ecx
UserGate read_tcp_connection_nr
popl %edi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosWriteTcpConnection
#
# Purpose....: Write data fto connection
#
# Parameters.: Conn handle
# Buffer
# Size
#
# Returns....: Written bytes
#
##########################################################################*/
.global RdosWriteTcpConnection
RdosWriteTcpConnection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edi
movw 8(%ebp),%bx
movl 12(%ebp),%edi
movl 16(%ebp),%ecx
UserGate write_tcp_connection_nr
popl %edi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetLocalMailslot
#
# Purpose....: Get local mailslot from name
#
# Parameters.: Name
#
# Returns....: Mailslot handle
#
##########################################################################*/
.global RdosGetLocalMailslot
RdosGetLocalMailslot:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movl 8(%ebp),%edi
UserGate get_local_mailslot_nr
jc rglmFail
movzx %bx,%eax
jmp rglmDone
rglmFail:
xorl %eax,%eax
rglmDone:
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetRemoteMailslot
#
# Purpose....: Get remote mailslot from name
#
# Parameters.: IP
# Name
#
# Returns....: Mailslot handle
#
##########################################################################*/
.global RdosGetRemoteMailslot
RdosGetRemoteMailslot:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edx
pushl %edi
movl 8(%ebp),%edx
movl 12(%ebp),%edi
UserGate get_remote_mailslot_nr
jc rgrmFail
movzx %bx,%eax
jmp rgrmDone
rgrmFail:
xorl %eax,%eax
rgrmDone:
popl %edi
popl %edx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosFreeMailslot
#
# Purpose....: Free mailslot
#
# Parameters.: Mailslot handle
#
##########################################################################*/
.global RdosFreeMailslot
RdosFreeMailslot:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
UserGate free_mailslot_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSendMailslot
#
# Purpose....: Send mailslot
#
# Parameters.: Mailslot handle
# Msg
# Size
# ReplyBuf
# MaxReplySize
#
# Returns....: Size of reply
#
##########################################################################*/
.global RdosSendMailslot
RdosSendMailslot:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
pushl %edi
movw 8(%ebp),%bx
movl 12(%ebp),%esi
movl 16(%ebp),%ecx
movl 20(%ebp),%edi
movl 24(%ebp),%eax
UserGate send_mailslot_nr
jc smFail
movl %ecx,%eax
jmp smDone
smFail:
movl $0xFFFFFFFF,%eax
smDone:
popl %edi
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDefineMailslot
#
# Purpose....: Define mailslot
#
# Parameters.: Name
# Max msg size
#
##########################################################################*/
.global RdosDefineMailslot
RdosDefineMailslot:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
movl 12(%ebp),%ecx
UserGate define_mailslot_nr
popl %edi
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosReceiveMailslot
#
# Purpose....: Receive from mailslot
#
# Parameters.: Msg buffer
#
# Returns....: Msg size
#
##########################################################################*/
.global RdosReceiveMailslot
RdosReceiveMailslot:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
UserGate receive_mailslot_nr
movl %ecx,%eax
popl %edi
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosReplyMailslot
#
# Purpose....: Reply to mailslot
#
# Parameters.: Msg buffer
# Msg size
#
##########################################################################*/
.global RdosReplyMailslot
RdosReplyMailslot:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edi
movl 8(%ebp),%edi
movl 12(%ebp),%ecx
UserGate reply_mailslot_nr
popl %edi
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosGetIdeDisc
#
# Purpose....: Get IDE disc
#
# Parameters.: Unit #
#
# Returns....: Disc #
#
##########################################################################*/
.global RdosGetIdeDisc
RdosGetIdeDisc:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movb 8(%ebp),%bl
UserGate get_ide_disc_nr
jc get_ide_disc_fail
movzx %al,%eax
jmp get_ide_disc_done
get_ide_disc_fail:
movl $0xFFFFFFFF,%eax
get_ide_disc_done:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetFloppyDisc
#
# Purpose....: Get floppy disc
#
# Parameters.: Unit #
#
# Returns....: Disc #
#
##########################################################################*/
.global RdosGetFloppyDisc
RdosGetFloppyDisc:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movb 8(%ebp),%bl
UserGate get_floppy_disc_nr
jc get_floppy_disc_fail
movzx %al,%eax
jmp get_floppy_disc_done
get_floppy_disc_fail:
movl $0xFFFFFFFF,%eax
get_floppy_disc_done:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetDiscInfo
#
# Purpose....: Get disc info
#
# Parameters.: Disc #
# Bytes / sector
# Total sectors
# BIOS sectors / cyl
# BIOS heads
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosGetDiscInfo
RdosGetDiscInfo:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movb 8(%ebp),%al
UserGate get_disc_info_nr
jc get_disc_info_fail
movl 12(%ebp),%ebx
movzx %cx,%ecx
movl %ecx,(%ebx)
movl 16(%ebp),%ebx
movl %edx,(%ebx)
movl 20(%ebp),%ebx
movzx %si,%esi
movl %esi,(%ebx)
movl 24(%ebp),%ebx
movzx %di,%edi
movl %edi,(%ebx)
movl $1,%eax
jmp get_disc_info_done
get_disc_info_fail:
xorl %eax,%eax
get_disc_info_done:
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetDiscInfo
#
# Purpose....: Set disc info
#
# Parameters.: Disc #
# Bytes / sector
# Total sectors
# BIOS sectors / cyl
# BIOS heads
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosSetDiscInfo
RdosSetDiscInfo:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
pushl %esi
pushl %edi
movb 8(%ebp),%al
movl 12(%ebp),%ecx
movl 16(%ebp),%edx
movl 20(%ebp),%esi
movl 24(%ebp),%edi
UserGate set_disc_info_nr
jc set_disc_info_fail
movl $1,%eax
jmp set_disc_info_done
set_disc_info_fail:
xorl %eax,%eax
set_disc_info_done:
popl %edi
popl %esi
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosReadDisc
#
# Purpose....: Read from disc
#
# Parameters.: Disc #
# Sector #
# Buffer
# Size
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosReadDisc
RdosReadDisc:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
pushl %edi
movb 8(%ebp),%al
movl 12(%ebp),%edx
movl 16(%ebp),%edi
movl 20(%ebp),%ecx
UserGate read_disc_nr
jc read_disc_fail
movl $1,%eax
jmp read_disc_done
read_disc_fail:
xorl %eax,%eax
read_disc_done:
popl %edi
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosWriteDisc
#
# Purpose....: Write to disc
#
# Parameters.: Disc #
# Sector #
# Buffer
# Size
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosWriteDisc
RdosWriteDisc:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
pushl %edi
movb 8(%ebp),%al
movl 12(%ebp),%edx
movl 16(%ebp),%edi
movl 20(%ebp),%ecx
UserGate write_disc_nr
jc write_disc_fail
movl $1,%eax
jmp write_disc_done
write_disc_fail:
xorl %eax,%eax
write_disc_done:
popl %edi
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosAllocateFixedDrive
#
# Purpose....: Allocate fixed drive
#
# Parameters.: Drive #
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosAllocateFixedDrive
RdosAllocateFixedDrive:
pushl %ebp
movl %esp,%ebp
movb 8(%ebp),%al
UserGate allocate_fixed_drive_nr
jc allocate_fixed_drive_fail
movl $1,%eax
jmp allocate_fixed_drive_done
allocate_fixed_drive_fail:
xorl %eax,%eax
allocate_fixed_drive_done:
leave
ret
/*##########################################################################
#
# Name : RdosAllocateStaticDrive
#
# Purpose....: Allocate static drive
#
# Returns....: Drive #
#
##########################################################################*/
.global RdosAllocateStaticDrive
RdosAllocateStaticDrive:
pushl %ebp
movl %esp,%ebp
UserGate allocate_static_drive_nr
jc allocate_static_drive_fail
movzx %al,%eax
jmp allocate_static_drive_done
allocate_static_drive_fail:
xorl %eax,%eax
allocate_static_drive_done:
leave
ret
/*##########################################################################
#
# Name : RdosAllocateDynamicDrive
#
# Purpose....: Allocate dynamic drive
#
# Returns....: Drive #
#
##########################################################################*/
.global RdosAllocateDynamicDrive
RdosAllocateDynamicDrive:
pushl %ebp
movl %esp,%ebp
UserGate allocate_dynamic_drive_nr
jc allocate_dynamic_drive_fail
movzx %al,%eax
jmp allocate_dynamic_drive_done
allocate_dynamic_drive_fail:
xorl %eax,%eax
allocate_dynamic_drive_done:
leave
ret
/*##########################################################################
#
# Name : RdosGetRdfsInfo
#
# Purpose....: Get rdfs info
#
# Parameters.: Crypt tab
# Key tab
# Extent size tab
#
##########################################################################*/
.global RdosGetRdfsInfo
RdosGetRdfsInfo:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
pushl %edi
movl 8(%ebp),%esi
movl 12(%ebp),%edi
movl 16(%ebp),%ebx
UserGate get_rdfs_info_nr
popl %edi
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetDriveInfo
#
# Purpose....: Get drive info
#
# Parameters.: Drive #
# Free units
# Bytes per unit
# Total units
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosGetDriveInfo
RdosGetDriveInfo:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movb 8(%ebp),%al
UserGate get_drive_info_nr
jc get_drive_info_fail
movl 12(%ebp),%ebx
movl %eax,(%ebx)
movl 16(%ebp),%ebx
movzx %cx,%ecx
movl %ecx,(%ebx)
movl 20(%ebp),%ebx
movl %edx,(%ebx)
movl $1,%eax
jmp get_drive_info_done
get_drive_info_fail:
xorl %eax,%eax
get_drive_info_done:
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDemandLoadDrive
#
# Purpose....: Demand load drive
#
# Parameters.: Drive #
#
##########################################################################*/
.global RdosDemandLoadDrive
RdosDemandLoadDrive:
pushl %ebp
movl %esp,%ebp
movb 8(%ebp),%al
UserGate demand_load_drive_nr
leave
ret
/*##########################################################################
#
# Name : RdosGetDriveDiscParam
#
# Purpose....: Get drive disc parameters
#
# Parameters.: Drive #
# Disc #
# Start sector
# Total sectors
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosGetDriveDiscParam
RdosGetDriveDiscParam:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %edx
movb 8(%ebp),%al
UserGate get_drive_disc_param_nr
jc get_drive_disc_param_fail
movl 12(%ebp),%ebx
movzx %al,%eax
movl %eax,(%ebx)
movl 16(%ebp),%ebx
movl %edx,(%ebx)
movl 20(%ebp),%ebx
movl %ecx,(%ebx)
movl $1,%eax
jmp get_drive_disc_param_done
get_drive_disc_param_fail:
xorl %eax,%eax
get_drive_disc_param_done:
popl %edx
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosFormatDrive
#
# Purpose....: Format drive
#
# Parameters.: Disc #
# Start sector
# Sectors
# FS name
#
# Returns....: Drive #
#
##########################################################################*/
.global RdosFormatDrive
RdosFormatDrive:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %edx
pushl %edi
movb 8(%ebp),%al
movl 12(%ebp),%edx
movl 16(%ebp),%ecx
movl 20(%ebp),%edi
UserGate format_drive_nr
jc rfdFail
movzx %al,%eax
jmp rfdDone
rfdFail:
xorl %eax,%eax
rfdDone:
popl %edi
popl %edx
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosGetExeName
#
# Purpose....: Get name of executable file
#
# Returns....: Exe pathname
#
##########################################################################*/
.global RdosGetExeName
RdosGetExeName:
pushl %ebp
movl %esp,%ebp
pushl %edi
UserGate get_exe_name_nr
jc rgenFail
movl %edi,%eax
jmp rgenDone
rgenFail:
xorl %eax,%eax
rgenDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosOpenAdc
#
# Purpose....: Open handle to ADC channel
#
# Parameters.: Channel #
#
# Returns....: Adc handle
#
##########################################################################*/
.global RdosOpenAdc
RdosOpenAdc:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%eax
UserGate open_adc_nr
movw %bx,%ax
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseAdc
#
# Purpose....: Close ADC handle
#
# Parameters.: Adc handle
#
##########################################################################*/
.global RdosCloseAdc
RdosCloseAdc:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
UserGate close_adc_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDefineAdcTime
#
# Purpose....: Define time of next conversion
#
# Parameters.: Adc handle
# MSB time
# LSB time
#
##########################################################################*/
.global RdosDefineAdcTime
RdosDefineAdcTime:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edx
movl 8(%ebp),%ebx
movl 12(%ebp),%edx
movl 16(%ebp),%eax
UserGate define_adc_time_nr
popl %edx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosReadAdc
#
# Purpose....: Read ADC
#
# Parameters.: Adc handle
#
# Returns....: Value
#
##########################################################################*/
.global RdosReadAdc
RdosReadAdc:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
UserGate read_adc_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosReadSerialLines
#
# Purpose....: Read serial lines
#
# Parameters.: Device
# &Value
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosReadSerialLines
RdosReadSerialLines:
pushl %ebp
movl %esp,%ebp
pushl %edx
pushl %esi
movb 8(%ebp),%dh
UserGate read_serial_lines_nr
jc rdsFail
movzx %al,%eax
movl 12(%ebp),%esi
movl %eax,(%esi)
movl $1,%eax
jmp rdsDone
rdsFail:
xorl %eax,%eax
rdsDone:
popl %esi
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosToggleSerialLine
#
# Purpose....: Toggle serial line
#
# Parameters.: Device
# Line
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosToggleSerialLine
RdosToggleSerialLine:
pushl %ebp
movl %esp,%ebp
pushl %edx
movb 8(%ebp),%dh
movb 12(%ebp),%dl
UserGate toggle_serial_line_nr
jc rtsFail
movl $1,%eax
jmp rtsDone
rtsFail:
xorl %eax,%eax
rtsDone:
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosReadSerialVal
#
# Purpose....: Read serial value
#
# Parameters.: Device
# Line
# &Val
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosReadSerialVal
RdosReadSerialVal:
pushl %ebp
movl %esp,%ebp
pushl %edx
pushl %esi
movb 8(%ebp),%dh
movb 12(%ebp),%dl
UserGate read_serial_val_nr
pushfw
shll $8,%eax
movl 16(%ebp),%esi
movl %eax,(%esi)
popfw
jc rdvFail
movl $1,%eax
jmp rdvDone
rdvFail:
xorl %eax,%eax
rdvDone:
popl %esi
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosWriteSerialVal
#
# Purpose....: Write serial value
#
# Parameters.: Device
# Line
# Val
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosWriteSerialVal
RdosWriteSerialVal:
pushl %ebp
movl %esp,%ebp
pushl %edx
movb 8(%ebp),%dh
movb 12(%ebp),%dl
movl 16(%ebp),%eax
sarl $8,%eax
UserGate write_serial_val_nr
jc rwvFail
movl $1,%eax
jmp rwvDone
rwvFail:
xorl %eax,%eax
rwvDone:
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosReadSerialRaw
#
# Purpose....: Read serial raw value
#
# Parameters.: Device
# Line
# &Val
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosReadSerialRaw
RdosReadSerialRaw:
pushl %ebp
movl %esp,%ebp
pushl %edx
pushl %esi
movb 8(%ebp),%dh
movb 12(%ebp),%dl
UserGate read_serial_val_nr
pushfw
movl 16(%ebp),%esi
movl %eax,(%esi)
popfw
jc rdrFail
movl $1,%eax
jmp rdrDone
rdrFail:
xorl %eax,%eax
rdrDone:
popl %esi
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosWriteSerialRaw
#
# Purpose....: Write serial raw value
#
# Parameters.: Device
# Line
# Val
#
# Returns....: TRUE if ok
#
##########################################################################*/
.global RdosWriteSerialRaw
RdosWriteSerialRaw:
pushl %ebp
movl %esp,%ebp
pushl %edx
movb 8(%ebp),%dh
movb 12(%ebp),%dl
movl 16(%ebp),%eax
UserGate write_serial_val_nr
jc rwrFail
movl $1,%eax
jmp rwrDone
rwrFail:
xorl %eax,%eax
rwrDone:
popl %edx
leave
ret
/*##########################################################################
#
# Name : RdosOpenSysEnv
#
# Purpose....: Open system environment
#
# Returns....: Env handle
#
##########################################################################*/
.global RdosOpenSysEnv
RdosOpenSysEnv:
pushl %ebp
movl %esp,%ebp
pushl %ebx
UserGate open_sys_env_nr
jc oseFail
movzx %bx,%eax
jmp oseDone
oseFail:
xorl %eax,%eax
oseDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosOpenProcessEnv
#
# Purpose....: Open process environment
#
# Returns....: Env handle
#
##########################################################################*/
.global RdosOpenProcessEnv
RdosOpenProcessEnv:
pushl %ebp
movl %esp,%ebp
pushl %ebx
UserGate open_proc_env_nr
jc opeFail
movzx %bx,%eax
jmp opeDone
opeFail:
xorl %eax,%eax
opeDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseEnv
#
# Purpose....: Close environment
#
# Parameters.: Env handle
#
##########################################################################*/
.global RdosCloseEnv
RdosCloseEnv:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
UserGate close_env_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosAddEnvVar
#
# Purpose....: Add environment variable
#
# Parameters.: Env handle
# var
# data
#
##########################################################################*/
.global RdosAddEnvVar
RdosAddEnvVar:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
pushl %edi
movl 8(%ebp),%ebx
movl 12(%ebp),%esi
movl 16(%ebp),%edi
UserGate add_env_var_nr
popl %edi
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDeleteEnvVar
#
# Purpose....: Delete environment variable
#
# Parameters.: Env handle
# var
#
##########################################################################*/
.global RdosDeleteEnvVar
RdosDeleteEnvVar:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
movl 8(%ebp),%ebx
movl 12(%ebp),%esi
UserGate delete_env_var_nr
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosFindEnvVar
#
# Purpose....: Find environment variable
#
# Parameters.: Env handle
# var
# data
#
##########################################################################*/
.global RdosFindEnvVar
RdosFindEnvVar:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
pushl %edi
movl 8(%ebp),%ebx
movl 12(%ebp),%esi
movl 16(%ebp),%edi
UserGate find_env_var_nr
jc fevFail
movl $1,%eax
jmp fevDone
fevFail:
xorl %eax,%eax
fevDone:
popl %edi
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGetEnvData
#
# Purpose....: Get raw environment data
#
# Parameters.: Env handle
# data
#
##########################################################################*/
.global RdosGetEnvData
RdosGetEnvData:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movl 8(%ebp),%ebx
movl 12(%ebp),%edi
UserGate get_env_data_nr
jnc gedDone
xorw %ax,%ax
stosw
gedDone:
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosSetEnvData
#
# Purpose....: Set raw environment data
#
# Parameters.: Env handle
# data
#
##########################################################################*/
.global RdosSetEnvData
RdosSetEnvData:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movl 8(%ebp),%ebx
movl 12(%ebp),%edi
UserGate set_env_data_nr
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosOpenSysIni
#
# Purpose....: Open system ini-file
#
# Returns....: Ini handle
#
##########################################################################*/
.global RdosOpenSysIni
RdosOpenSysIni:
pushl %ebp
movl %esp,%ebp
pushl %ebx
UserGate open_sys_ini_nr
jc osiFail
movzx %bx,%eax
jmp osiDone
osiFail:
xorl %eax,%eax
osiDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCloseIni
#
# Purpose....: Close ini-file
#
# Parameters.: Ini handle
#
##########################################################################*/
.global RdosCloseIni
RdosCloseIni:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
UserGate close_ini_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosGotoIniSection
#
# Purpose....: Goto ini section
#
# Parameters.: Ini handle
# SectionName
#
##########################################################################*/
.global RdosGotoIniSection
RdosGotoIniSection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %edi
movl 8(%ebp),%ebx
movl 12(%ebp),%edi
UserGate goto_ini_section_nr
jc gisFail
movl $1,%eax
jmp gisDone
gisFail:
xorl %eax,%eax
gisDone:
popl %edi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosRemoveIniSection
#
# Purpose....: Remove current ini section
#
# Parameters.: Ini handle
#
##########################################################################*/
.global RdosRemoveIniSection
RdosRemoveIniSection:
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
UserGate remove_ini_section_nr
jc risFail
movl $1,%eax
jmp risDone
risFail:
xorl %eax,%eax
risDone:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosReadIni
#
# Purpose....: Read ini var in current section
#
# Parameters.: Ini handle
# VarName
# Data
# MaxSize
#
##########################################################################*/
.global RdosReadIni
RdosReadIni:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
pushl %esi
pushl %edi
movl 8(%ebp),%ebx
movl 12(%ebp),%esi
movl 16(%ebp),%edi
movl 20(%ebp),%ecx
UserGate read_ini_nr
jc riFail
movl $1,%eax
jmp riDone
riFail:
xorl %eax,%eax
riDone:
popl %edi
popl %esi
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosWriteIni
#
# Purpose....: Write ini var in current section
#
# Parameters.: Ini handle
# VarName
# Data
#
##########################################################################*/
.global RdosWriteIni
RdosWriteIni:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
pushl %edi
movl 8(%ebp),%ebx
movl 12(%ebp),%esi
movl 16(%ebp),%edi
UserGate write_ini_nr
jc wiFail
movl $1,%eax
jmp wiDone
wiFail:
xorl %eax,%eax
wiDone:
popl %edi
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosDeleteIni
#
# Purpose....: Delete ini var in current section
#
# Parameters.: Ini handle
# VarName
#
##########################################################################*/
.global RdosDeleteIni
RdosDeleteIni:
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %esi
movl 8(%ebp),%ebx
movl 12(%ebp),%esi
UserGate delete_ini_nr
jc diFail
movl $1,%eax
jmp diDone
diFail:
xorl %eax,%eax
diDone:
popl %esi
popl %ebx
leave
ret
/*##########################################################################
#
# Name : RdosCreateFileDrive
#
# Purpose....: Create a new file-drive
#
# Parameters.: Drive
# Size
# FS name
# Filename
#
##########################################################################*/
.global RdosCreateFileDrive
RdosCreateFileDrive:
pushl %ebp
movl %esp,%ebp
pushl %ecx
pushl %esi
pushl %edi
movb 8(%ebp),%al
movl 12(%ebp),%ecx
movl 16(%ebp),%esi
movl 20(%ebp),%edi
UserGate create_file_drive_nr
jnc cfdOk
xorl %eax,%eax
jmp cfdDone
cfdOk:
movl $1,%eax
cfdDone:
popl %edi
popl %esi
popl %ecx
leave
ret
/*##########################################################################
#
# Name : RdosOpenFileDrive
#
# Purpose....: Open a new file-drive
#
# Parameters.: Drive
# Filename
#
##########################################################################*/
.global RdosOpenFileDrive
RdosOpenFileDrive:
pushl %ebp
movl %esp,%ebp
pushl %edi
movb 8(%ebp),%al
movl 12(%ebp),%edi
UserGate open_file_drive_nr
jnc ofdOk
xorl %eax,%eax
jmp ofdDone
ofdOk:
movl $1,%eax
ofdDone:
popl %edi
leave
ret
/*##########################################################################
#
# Name : RdosEnableStatusLed
#
# Purpose....: Enable status LED
#
##########################################################################*/
.global RdosEnableStatusLed
RdosEnableStatusLed:
pushl %ebp
movl %esp,%ebp
UserGate enable_status_led_nr
leave
ret
/*##########################################################################
#
# Name : RdosDisableStatusLed
#
# Purpose....: Disable status LED
#
##########################################################################*/
.global RdosDisableStatusLed
RdosDisableStatusLed:
pushl %ebp
movl %esp,%ebp
UserGate disable_status_led_nr
leave
ret
/*##########################################################################
#
# Name : RdosStartWatchdog
#
# Purpose....: Start watchdog
#
# Parameters.: Timeout, ms
#
##########################################################################*/
.global RdosStartWatchdog
RdosStartWatchdog:
pushl %ebp
movl %esp,%ebp
;
movl 8(%ebp),%eax
UserGate start_watchdog_nr
;
leave
ret
/*##########################################################################
#
# Name : RdosKickWatchdog
#
# Purpose....: Kick watchdog
#
##########################################################################*/
.global RdosKickWatchdog
RdosKickWatchdog:
pushl %ebp
movl %esp,%ebp
UserGate kick_watchdog_nr
leave
ret
|
32bitmicro/newlib-nano-1.0
| 7,258
|
newlib/libc/sys/rdos/crt0.S
|
/*#######################################################################
# RDOS operating system
# Copyright (C) 1988-2006, Leif Ekblad
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# The author of this program may be contacted at leif@rdos.net
#
# crt0.S
# GCC startupcode for RDOS
#
##########################################################################*/
#include "user.def"
KEY_ENTRIES = 256
.macro UserGate nr
.byte 0x9A
.long \nr
.word 2
.endm
.data
.align 8
_key_section:
.word 0
_key_ref_arr:
.long 0
_key_dtor_arr:
.long 0
.text
.align 4
/*##########################################################################
#
# Name : _start
#
# Purpose....: GCC startup-code
#
##########################################################################*/
.global _start
_start:
call get_impure_data_size
movl %eax,%ecx
UserGate allocate_app_mem_nr
xorl %eax,%eax
.byte 0x64
movl %edx,(%eax)
movl %edx,%edi
rep
stosb
pushl %edx
movl $(4 * KEY_ENTRIES),%eax
movl %eax,%ecx
UserGate allocate_app_mem_nr
movl $4,%eax
.byte 0x64
movl %edx,(%eax)
movl %edx,%edi
xorl %eax,%eax
rep
stosb
movl $(4 * KEY_ENTRIES),%eax
movl %eax,%ecx
UserGate allocate_app_mem_nr
movl %edx,_key_ref_arr
movl %edx,%edi
xorl %eax,%eax
rep
stosb
movl $(4 * KEY_ENTRIES),%eax
movl %eax,%ecx
UserGate allocate_app_mem_nr
movl %edx,_key_dtor_arr
movl %edx,%edi
xorl %eax,%eax
rep
stosb
UserGate create_user_section_nr
movw %bx,_key_section
call __init_rdos
add $4, %esp
movl $0x1000,%eax
UserGate allocate_app_mem_nr
pushl %edx
UserGate get_cmd_line_nr
xorl %ecx,%ecx
xorb %ah,%ah
arg_loop:
movl %edi,(%edx)
addl $4,%edx
movb (%edi),%al
orb %al,%al
je arg_done
arg_scan:
movb (%edi),%al
orb %al,%al
je next_arg
cmpb $0x22,%al
jne arg_no_quote
xorb $1,%ah
jmp arg_scan_next
arg_no_quote:
orb %ah,%ah
jnz arg_scan_next
cmpb $0x20,%al
je next_arg
cmpb $0x8,%al
je next_arg
arg_scan_next:
incl %edi
jmp arg_scan
next_arg:
incl %ecx
to_next_arg:
orb %al,%al
je arg_done
xorb %al,%al
movb %al,(%edi)
incl %edi
movb (%edi),%al
cmpb $0x20,%al
je to_next_arg
cmpb $0x8,%al
je to_next_arg
jmp arg_loop
arg_done:
int $3
pushl %ecx
call main
add $8, %esp
pushl %eax
call exit
/*##########################################################################
#
# Name : _exit
#
# Purpose....: GCC exit-code
#
##########################################################################*/
.global _exit
_exit:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
UserGate unload_exe_nr
/*##########################################################################
#
# Name : __getreent
#
# Purpose....: ?
#
##########################################################################*/
.global __getreent
__getreent:
xorl %eax,%eax
.byte 0x64
movl (%eax),%eax
ret
/*##########################################################################
#
# Name : __rdos_thread_key_create
#
# Purpose....: Emulate GCC pthread_key_create
#
# Parameters.: dtor
#
# Returns....: Key index
#
##########################################################################*/
.global __rdos_thread_key_create
__rdos_thread_key_create:
int $3
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
mov _key_section,%bx
UserGate enter_user_section_nr
movl _key_ref_arr,%ebx
movl KEY_ENTRIES,%ecx
rtkc_scan_loop:
movl (%ebx), %eax
orl %eax, %eax
jz rtkc_entry_found
add $4, %ebx
loop rtkc_scan_loop
movl $-1, %eax
jmp rtkc_leave
rtkc_entry_found:
movb $255,3(%ebx)
subl _key_ref_arr,%ebx
addl _key_dtor_arr,%ebx
movl 8(%ebp),%eax
movl %eax,(%ebx)
subl _key_dtor_arr,%ebx
movl %ebx,%eax
rtkc_leave:
mov _key_section, %bx
UserGate leave_user_section_nr
popl %ecx
popl %ebx
leave
ret
/*##########################################################################
#
# Name : __rdos_thread_key_delete
#
# Purpose....: Emulate GCC pthread_key_delete
#
# Parameters.: index
#
# Returns....: result
#
##########################################################################*/
.global __rdos_thread_key_delete
__rdos_thread_key_delete:
int $3
pushl %ebp
movl %esp,%ebp
pushl %ebx
mov _key_section,%bx
UserGate enter_user_section_nr
movl 8(%ebp),%ebx
testb $3,%bl
jnz rtkd_fail
cmpl $(4 * KEY_ENTRIES),%ebx
jae rtkd_fail
addl _key_ref_arr,%ebx
movb $0,3(%ebx)
mov (%ebx),%eax
orl %eax,%eax
jz rtkd_ok
subl _key_ref_arr,%ebx
movl $0,(%ebx)
jmp rtkd_ok
rtkd_fail:
movl $1,%eax
jmp rtkd_leave
rtkd_ok:
xorl %eax,%eax
rtkd_leave:
mov _key_section, %bx
UserGate leave_user_section_nr
popl %ebx
leave
ret
/*##########################################################################
#
# Name : __rdos_thread_getspecific
#
# Purpose....: Emulate GCC pthread_getspecific
#
# Parameters.: index
#
# Returns....: value
#
##########################################################################*/
.global __rdos_thread_getspecific
__rdos_thread_getspecific:
int $3
pushl %ebp
movl %esp,%ebp
pushl %ebx
movl 8(%ebp),%ebx
testb $3,%bl
jnz rtg_fail
cmpl $(4 * KEY_ENTRIES),%ebx
jae rtg_fail
movl $4,%eax
.byte 0x64
movl (%eax),%eax
addl %eax,%ebx
movl (%ebx),%eax
jmp rtg_done
rtg_fail:
xorl %eax,%eax
rtg_done:
popl %ebx
leave
ret
/*##########################################################################
#
# Name : __rdos_thread_setspecific
#
# Purpose....: Emulate GCC pthread_setspecific
#
# Parameters.: index
# value
#
##########################################################################*/
.global __rdos_thread_setspecific
__rdos_thread_setspecific:
int $3
pushl %ebp
movl %esp,%ebp
pushl %ebx
pushl %ecx
movl 8(%ebp),%ebx
testb $3,%bl
jnz rts_fail
cmpl $(4 * KEY_ENTRIES),%ebx
jae rts_fail
movl $4,%eax
.byte 0x64
movl (%eax),%eax
addl %eax,%ebx
movl 12(%ebp),%eax
movl %eax,(%ebx)
xorl %eax,%eax
jmp rts_done
rts_fail:
movl $1,%eax
rts_done:
popl %ebx
leave
ret
|
32bitmicro/newlib-nano-1.0
| 1,252
|
newlib/libc/sys/sysnecv850/crt0.S
|
# NEC V850 startup code
.section .text
.global _start
_start:
#if defined __v850e__
movea 255, r0, r20
mov 65535, r21
mov hilo(_stack), sp
mov hilo(__ep), ep
mov hilo(__gp), gp
mov hilo(__ctbp), r6
ldsr r6, ctbp
mov hilo(_edata), r6
mov hilo(_end), r7
.L0:
st.w r0, 0[r6]
addi 4, r6, r6
cmp r7, r6
bl .L0
.L1:
jarl ___main, r31
addi -16, sp, sp
mov 0, r6
mov 0, r7
mov 0, r8
jarl _main, r31
mov r10, r6
jarl _exit, r31
# else
movea 255, r0, r20
mov r0, r21
ori 65535, r0, r21
movhi hi(_stack), r0, sp
movea lo(_stack), sp, sp
movhi hi(__ep), r0, ep
movea lo(__ep), ep, ep
movhi hi(__gp), r0, gp
movea lo(__gp), gp, gp
movhi hi(_edata), r0, r6
movea lo(_edata), r6, r6
movhi hi(_end), r0, r7
movea lo(_end), r7, r7
.L0:
st.b r0, 0[r6]
addi 1, r6, r6
cmp r7, r6
bl .L0
.L1:
jarl ___main, r31
addi -16, sp, sp
mov 0, r6
mov 0, r7
mov 0, r8
jarl _main, r31
mov r10, r6
jarl _exit, r31
# endif
.section .stack
_stack: .long 1
.section .data
.global ___dso_handle
.weak ___dso_handle
___dso_handle:
.long 0
|
32bitmicro/newlib-nano-1.0
| 1,624
|
newlib/libc/sys/arc/crt0.S
|
; ARC start up file
; In the absence of a custom linker script, go with something simple.
; We do not support passing arguments to "main", but this is an embedded
; system anyway.
;
; We call init/fini here without cpu prefixes because there is always
; only one .init/.fini section per image.
.section .text
.align 4
.global start
start:
mov sp,end ; Round "sp" up to page after "end".
add sp,sp,4095
and sp,sp,-4096
ld r8,[stack_size] ; Add stack size to "sp".
add sp,sp,r8
st sp,[sbrk_start] ; Initialize malloc heap.
st sp,[sbrk_loc]
sub sp,sp,16 ; callee expects 16 bytes already "pushed".
mov fp,0 ; Top of stack frame indicator.
mov r0,edata ; Zero bss.
mov r2,end
sub r2,r2,r0
mov r1,0
#ifdef __base__
bl.nd _memset
bl.nd init ; .init section entry point.
mov r0,%st(fini) ; .fini section entry point.
bl.nd _atexit
mov r0,0 ; argc
mov r1,0 ; argv
bl.nd _main
bl.nd _exit
#endif
#ifdef __host__
bl.nd _host_memset
bl.nd init ; .init section entry point.
mov r0,%st(fini) ; .fini section entry point.
bl.nd _host_atexit
mov r0,0 ; argc
mov r1,0 ; argv
bl.nd _host_main
bl.nd _host_exit
#endif
#ifdef __graphics__
bl.nd _graphics_memset
bl.nd init ; .init section entry point.
mov r0,%st(fini) ; .fini section entry point.
bl.nd _graphics_atexit
mov r0,0 ; argc
mov r1,0 ; argv
bl.nd _graphics_main
bl.nd _graphics_exit
#endif
#ifdef __audio__
bl.nd _audio_memset
bl.nd init ; .init section entry point.
mov r0,%st(fini) ; .fini section entry point.
bl.nd _audio_atexit
mov r0,0 ; argc
mov r1,0 ; argv
bl.nd _audio_main
bl.nd _audio_exit
#endif
|
32bitmicro/newlib-nano-1.0
| 1,119
|
newlib/libc/sys/sysmec/crt0.S
|
#ifdef __mn10300__
.section .text
.global _start
_start:
mov _stack-8,a0 # Load up the stack pointer
mov a0,sp
mov _edata,a0 # Get the start/end of bss
mov _end,a1
cmp a0,a1 # If no bss, then do nothing
beq .L0
clr d0 # clear d0
.L1:
movbu d0,(a0) # Clear a byte and bump pointer
inc a0
cmp a0,a1
bne .L1
.L0:
call ___main,[],0 # Call __main to run ctors/dtors
clr d0
clr d1
mov d0,(4,sp)
call _main,[],0 # Call main program
call _exit,[],0 # All done, no need to return or
# deallocate our stack.
.section ._stack
_stack: .long 1
#else
.section .text
.global _start
_start:
mov _stack-4,a3 # Load up the stack pointer and allocate
# our current frame.
mov _edata,a0 # Get the start/end of bss
mov _end,a1
cmp a0,a1 # If no bss, then do nothing
beqx .L0
sub d0,d0 # clear d0
.L1:
movb d0,(a0) # Clear a byte and bump pointer
add 1,a0
cmp a0,a1
bnex .L1
.L0:
jsr ___main
sub d0,d0
mov d0,d1
mov d0,(a3)
jsr _main # Call main program
jmp _exit # All done, no need to return or
# deallocate our stack.
.section ._stack
_stack: .long 1
#endif
|
32bitmicro/newlib-nano-1.0
| 2,202
|
newlib/libc/sys/sh/crt0.S
|
#ifdef __SH5__
.section .data,"aw"
.global ___data
___data:
.section .rodata,"a"
.global ___rodata
___rodata:
#if __SH5__ == 64
.section .text,"ax"
#define LOAD_ADDR(sym, reg) \
movi (sym >> 48) & 65535, reg; \
shori (sym >> 32) & 65535, reg; \
shori (sym >> 16) & 65535, reg; \
shori sym & 65535, reg
#else
.mode SHmedia
.section .text..SHmedia32,"ax"
#define LOAD_ADDR(sym, reg) \
movi (sym >> 16) & 65535, reg; \
shori sym & 65535, reg
#endif
.global start
start:
LOAD_ADDR (_stack, r15)
pt/l zero_bss_loop, tr0
pt/l _atexit, tr1
pt/l _init, tr5
pt/l _main, tr6
pt/l _exit, tr7
! zero out bss
LOAD_ADDR (_edata, r0)
LOAD_ADDR (_end, r1)
zero_bss_loop:
stx.q r0, r63, r63
addi r0, 8, r0
bgt/l r1, r0, tr0
LOAD_ADDR (___data, r26)
LOAD_ADDR (___rodata, r27)
#if ! __SH4_NOFPU__
getcon cr0, r0
movi 1, r1
shlli r1, 15, r1
or r1, r0, r0
putcon r0, cr0
#endif
! arrange for exit to call fini
LOAD_ADDR (_fini, r2)
blink tr1, r18
! call init
blink tr5, r18
! call the mainline
blink tr6, r18
! call exit
blink tr7, r18
#else
.section .text
.global start
start:
mov.l stack_k,r15
! zero out bss
mov.l edata_k,r0
mov.l end_k,r1
mov #0,r2
start_l:
mov.l r2,@r0
add #4,r0
cmp/ge r0,r1
bt start_l
#ifndef __SH2A_NOFPU__
#if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY) || defined(__SH2A__)
mov.l set_fpscr_k, r1
jsr @r1
mov #0,r4
lds r3,fpscr
#endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A__) */
#endif /* !__SH2A_NOFPU__ */
! call the mainline
mov.l main_k,r0
jsr @r0
or r0,r0
! call exit
mov r0,r4
mov.l exit_k,r0
jsr @r0
or r0,r0
.align 2
#ifndef __SH2A_NOFPU__
#if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A__)
set_fpscr_k:
.long ___set_fpscr
#endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(SH4_SINGLE_ONLY) || defined(__SH2A__) */
#endif /* !__SH2A_NOFPU__ */
stack_k:
.long _stack
edata_k:
.long _edata
end_k:
.long _end
main_k:
.long _main
exit_k:
.long _exit
#endif
|
32bitmicro/newlib-nano-1.0
| 3,076
|
newlib/libc/sys/sparc64/crt0.S
|
! C run time start off
! This file supports:
!
! - both 32bit pointer and 64bit pointer environments (at compile time)
! - an imposed stack bias (of 2047) (at run time)
! - medium/low and medium/anywhere code models (at run time)
! Initial stack setup:
!
! bottom of stack (higher memory address)
! ...
! text of environment strings
! text of argument strings
! envp[envc] = 0 (4/8 bytes)
! ...
! env[0] (4/8 bytes)
! argv[argc] = 0 (4/8 bytes)
! ...
! argv[0] (4/8 bytes)
! argc (4/8 bytes)
! register save area (64 bits by 16 registers = 128 bytes)
! top of stack (%sp)
! Stack Bias:
!
! It is the responsibility of the o/s to set this up.
! We handle both a 0 and 2047 value for the stack bias.
! Medium/Anywhere code model support:
!
! In this model %g4 points to the start of the data segment.
! The text segment can go anywhere, but %g4 points to the *data* segment.
! It is up to the compiler/linker to get this right.
!
! Since this model is statically linked the start of the data segment
! is known at link time. Eg:
!
! sethi %hh(data_start), %g1
! sethi %lm(data_start), %g4
! or %g1, %hm(data_start), %g1
! or %g4, %lo(data_start), %g4
! sllx %g1, 32, %g1
! or %g4, %g1, %g4
!
! FIXME: For now we just assume 0.
! FIXME: if %g1 contains a non-zero value, atexit() should be invoked
! with this value.
#include <sys/syscallasm.h>
TEXT_SECTION
ALIGN (4)
GLOBAL (ASM_PRIVATE_SYMBOL (start))
ASM_PRIVATE_SYMBOL (start):
clr %fp
! We use %g4 even if the code model is Medium/Low (simplifies the code).
clr %g4 ! Medium/Anywhere base reg
! If there is a stack bias in effect, account for it in %g5. Then always
! add %g5 to stack references below. This way the code can be used with
! or without an imposed bias.
andcc %sp, 1, %g5
bnz,a .LHaveBias
mov 2047, %g5
.LHaveBias:
add %sp, %g5, %sp
#if TARGET_PTR_SIZE == 32
! FIXME: We apparently assume here that there is no reserved word.
! This is probably correct, but try to verify it.
ld [%sp + 0x80], %o0 ! argc
add %sp, 0x84, %o1 ! argv
add %o0, 1, %o2
sll %o2, 2, %o2
#else /* TARGET_PTR_SIZE == 64 */
ld [%sp + 0x8c], %o0 ! argc.lo
add %sp, 0x90, %o1 ! argv
add %o0, 1, %o2
sll %o2, 3, %o2
#endif
add %o1, %o2, %o2 ! envp
sethi %hi (ASM_SYMBOL (environ)), %o3
or %o3, %lo (ASM_SYMBOL (environ)), %o3
#if TARGET_PTR_SIZE == 32
st %o2, [%o3 + %g4]
#else /* TARGET_PTR_SIZE == 64 */
stx %o2, [%o3 + %g4]
#endif
! Restore any stack bias before we call main() ...
sub %sp, %g5, %sp
GLOBAL (ASM_SYMBOL (main))
call ASM_SYMBOL (main)
! FIXME: Not sure if this is needed anymore.
#if TARGET_PTR_SIZE == 32
sub %sp, 0x20, %sp ! room to push args
#else /* TARGET_PTR_SIZE == 64 */
sub %sp, 0x30, %sp ! room to push args
#endif
GLOBAL (ASM_SYMBOL (exit))
call ASM_SYMBOL (exit)
nop
GLOBAL (ASM_SYMBOL (_exit))
call ASM_SYMBOL (_exit)
nop
set SYS_exit, %g1
ta SYSCALL_TRAP ! in case user redefines __exit
! If all the above methods fail to terminate the program, try an illegal insn.
! If that does not work, the o/s is hosed more than we are.
WORD (0)
|
32bitmicro/newlib-nano-1.0
| 1,678
|
newlib/libc/sys/sparc64/sigsetjmp.S
|
! This file is called sigsetjmp.s because that is what V8 uses.
! We do not define sigsetjmp() or setlongjmp() yet.
! Solaris has setjmp/longjmp in setjmp.o. Move this stuff there.
#include <sys/syscallasm.h>
TEXT_SECTION
ALIGN (4)
#ifdef __svr4__
GLOBAL (ASM_SYMBOL (setjmp))
.proc 04
ASM_SYMBOL (setjmp):
clr [%o0]
stx %sp,[%o0+8]
add %o7,8,%g1
stx %g1,[%o0+16]
retl
mov %g0,%o0
GLOBAL (ASM_SYMBOL (longjmp))
.proc 04
ASM_SYMBOL (longjmp):
flushw ! flush register windows
sub %sp,136,%sp
ldx [%o0+8],%fp
ldx [%o0+16],%g1
tst %o1
bne L0
sub %g1,8,%o7
mov 1,%o1
L0:
retl
restore %o1,0,%o0
#else
GLOBAL (ASM_SYMBOL (setjmp))
.proc 04
ASM_SYMBOL (setjmp):
save %sp,-136,%sp
or %g0,%g0,%o0 ! %o0 = 0
or %g0,0x6d,%g1 ! %g1 = 0x6d (syscall number)
ta SYSCALL_TRAP
stw %o0,[%i0+4] ! save result at [%i0+4] (sigmask?)
add %fp,-8,%o1 ! %o1 -> tmp 8 byte buffer
or %g0,%g0,%o0 ! %o0 = 0
or %g0,0x70,%g1 ! %g1 = 0x70 (syscall number)
ta SYSCALL_TRAP
lduw [%fp-4],%g1 ! %g1 = onsstack?
stw %fp,[%i0+8] ! save %fp at [%i0+8]
stw %g1,[%i0+0] ! save ? at [%i0+8]
add %i7,8,%g1 ! %g1 = return address
stw %g1,[%i0+12] ! save return address at [%i0+12]
add %g1,4,%g1 ! %g1 = nPC
stw %g1,[%i0+16] ! save nPC at [%i0+16]
stw %g0,[%i0+20]
stw %g0,[%i0+24]
stw %g0,[%i0+32]
jmpl %i7+8,%g0
restore %g0,0,%o0
GLOBAL (ASM_SYMBOL (longjmp))
.proc 04
ASM_SYMBOL (longjmp):
orcc %g0,%o1,%g0 ! return val == 0 ?
be,a L1 ! branch if 0
or %g0,1,%o1 ! make it 1 (executed if branch taken)
L1:
or %g0,0x8b,%g1 ! set syscall 0x8b
stw %o1,[%o0+28] ! save return val for restoration
ta SYSCALL_TRAP
#endif /* ! __svr4__ */
|
32bitmicro/newlib-nano-1.0
| 1,475
|
newlib/libc/sys/sparc64/sbrk.S
|
! sbrk() system call
#include "sys/syscallasm.h"
DATA_SECTION
ALIGN (4)
! CURBRK contains the current top of allocated space.
! END is a private symbol in svr4, but a public one in sunos4.
! FIXME: CURBRK is 4 bytes for now.
GLOBAL (ASM_PRIVATE_SYMBOL (curbrk))
ASM_PRIVATE_SYMBOL (curbrk):
#ifdef __svr4__
WORD (ASM_PRIVATE_SYMBOL (end))
#else
WORD (ASM_SYMBOL (end))
#endif
TEXT_SECTION
ALIGN (4)
#ifdef REENT
GLOBAL (ASM_SYMBOL (_sbrk_r))
ASM_SYMBOL (_sbrk_r):
mov %o0,%o5
mov %o1,%o0
#else
GLOBAL (ASM_SYMBOL (sbrk))
ASM_SYMBOL (sbrk):
#endif
add %o0,7,%o0
andn %o0,7,%o0
sethi %hi (ASM_PRIVATE_SYMBOL (curbrk)),%o2
lduw [%o2+%lo (ASM_PRIVATE_SYMBOL (curbrk))],%o3
add %o3,7,%o3
andn %o3,7,%o3
add %o3,%o0,%o0
mov %o0,%o4
mov SYS_brk,%g1
ta SYSCALL_TRAP
bcs err
nop
stw %o4,[%o2+%lo (ASM_PRIVATE_SYMBOL (curbrk))]
jmpl %o7+8,%g0
mov %o3,%o0
#ifdef REENT
GLOBAL (ASM_SYMBOL (_brk_r))
ASM_SYMBOL (_brk_r):
mov %o0,%o5
mov %o1,%o0
#else
GLOBAL (ASM_SYMBOL (brk))
ASM_SYMBOL (brk):
#endif
add %o0,7,%o0
andn %o0,7,%o0
mov %o0,%o2
mov SYS_brk,%g1
ta SYSCALL_TRAP
bcs err
nop
sethi %hi (ASM_PRIVATE_SYMBOL (curbrk)),%o3
st %o2,[%o3+%lo (ASM_PRIVATE_SYMBOL (curbrk))]
retl
mov %g0,%o0
err:
#ifdef REENT
sethi %hi (ASM_PRIVATE_SYMBOL (cerror_r)),%g1
or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror_r)),%g1
#else
sethi %hi (ASM_PRIVATE_SYMBOL (cerror)),%g1
or %g1,%lo (ASM_PRIVATE_SYMBOL (cerror)),%g1
#endif
jmpl %g1,%g0
mov %o5,%o1
|
32bitmicro/newlib-nano-1.0
| 5,015
|
newlib/libc/sys/arm/trap.S
|
/* Run-time exception support */
#if !defined(__thumb2__)
#include "swi.h"
/* .text is used instead of .section .text so it works with arm-aout too. */
.text
.align 0
.global __rt_stkovf_split_big
.global __rt_stkovf_split_small
/* The following functions are provided for software stack checking.
If hardware stack-checking is being used then the code can be
compiled without the PCS entry checks, and simply rely on VM
management to extend the stack for a thread.
The stack extension event occurs when the PCS function entry code
would result in a stack-pointer beneath the stack-limit register
value. The system relies on the following map:
+-----------------------------------+ <-- end of stack block
| ... |
| ... |
| active stack |
| ... | <-- sp (stack-pointer) somewhere in here
| ... |
+-----------------------------------+ <-- sl (stack-limit)
| stack-extension handler workspace |
+-----------------------------------+ <-- base of stack block
The "stack-extension handler workspace" is an amount of memory in
which the stack overflow support code must execute. It must be
large enough to deal with the worst case path through the extension
code. At the moment the compiler expects this to be AT LEAST
256bytes. It uses this fact to code functions with small local
data usage within the overflow space.
In a true target environment We may need to increase the space
between sl and the true limit to allow for the stack extension
code, SWI handlers and for undefined instruction handlers of the
target environment. */
__rt_stkovf_split_small:
mov ip,sp @ Ensure we can calculate the stack required
@ and fall through to...
__rt_stkovf_split_big:
@ in: sp = current stack-pointer (beneath stack-limit)
@ sl = current stack-limit
@ ip = low stack point we require for the current function
@ lr = return address into the current function
@ fp = frame-pointer
@ original sp --> +----------------------------------+
@ | pc (12 ahead of PCS entry store) |
@ current fp ---> +----------------------------------+
@ | lr (on entry) pc (on exit) |
@ +----------------------------------+
@ | sp ("original sp" on entry) |
@ +----------------------------------+
@ | fp (on entry to function) |
@ +----------------------------------+
@ | |
@ | ..argument and work registers.. |
@ | |
@ current sp ---> +----------------------------------+
@
@ The "current sl" is somewhere between "original sp" and "current sp"
@ but above "true sl". The "current sl" should be at least 256bytes
@ above the "true sl". The 256byte stack guard should be large enough
@ to deal with the worst case function entry stacking (160bytes) plus
@ the stack overflow handler stacking requirements, plus the stack
@ required for the memory allocation routines.
@
@ Normal PCS entry (before stack overflow check) can stack 16
@ standard registers (64bytes) and 8 floating point registers
@ (96bytes). This gives a minimum stack guard of 160bytes (excluding
@ the stack required for the code). (Actually only a maximum of
@ 14standard registers are ever stacked on entry to a function).
@
@ NOTE: Structure returns are performed by the caller allocating a
@ dummy space on the stack and passing in a "phantom" arg1 into
@ the function. This means that we do not need to worry about
@ preserving the stack under "sp" even on function return.
@
@ Code should never poke values beneath sp. The sp register
@ should always be "dropped" first to cover the data. This
@ protects the data against any events that may try and use
@ the stack.
SUB ip, sp, ip @ extra stack required for function
@ Add stack extension code here. If desired a new stack chunk
@ can be allocated, and the register state updated suitably.
@ We now know how much extra stack the function requires.
@ Terminate the program for the moment:
swi SWI_Exit
#endif
|
32bitmicro/newlib-nano-1.0
| 6,902
|
newlib/libc/sys/arm/crt0.S
|
#include "newlib.h"
#include "swi.h"
/* ANSI concatenation macros. */
#define CONCAT(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b
#ifdef __USER_LABEL_PREFIX__
#define FUNCTION( name ) CONCAT (__USER_LABEL_PREFIX__, name)
#else
#error __USER_LABEL_PREFIX is not defined
#endif
#ifdef HAVE_INITFINI_ARRAY
#define _init __libc_init_array
#define _fini __libc_fini_array
#endif
/* .text is used instead of .section .text so it works with arm-aout too. */
.text
#if defined(__thumb2__)
.syntax unified
.thumb
.macro FUNC_START name
.global \name
.thumb_func
\name:
.endm
#else
.code 32
.macro FUNC_START name
.global \name
\name:
.endm
#endif
.align 0
FUNC_START _mainCRTStartup
FUNC_START _start
FUNC_START start
#if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__)
/* Annotation for EABI unwinding tables. */
.fnstart
#endif
/* Start by setting up a stack */
#ifdef ARM_RDP_MONITOR
/* Issue Demon SWI to read stack info */
swi SWI_GetEnv /* Returns command line in r0 */
mov sp,r1 /* and the highest memory address in r1 */
ldr sl, .LC2 /* stack limit is at end of data */
add sl, sl, #256 /* allow slop for stack overflow handling */
/* and small frames */
#else
#ifdef ARM_RDI_MONITOR
/* Issue Angel SWI to read stack info */
mov r0, #AngelSWI_Reason_HeapInfo
adr r1, .LC0 /* point at ptr to 4 words to receive data */
#if defined(__thumb2__)
bkpt AngelSWI
#else
/* We are always in ARM mode for startup */
AngelSWIAsm AngelSWI_ARM
#endif
ldr r0, .LC0 /* point at values read */
ldr sp, [r0, #8]
ldr sl, [r0, #12]
add sl, sl, #256 /* allow slop for stack overflow handling */
/* and small frames */
#else
/* Set up the stack pointer to a fixed value */
ldr r3, .LC0
mov sp, r3
/* Setup a default stack-limit in-case the code has been
compiled with "-mapcs-stack-check". Hard-wiring this value
is not ideal, since there is currently no support for
checking that the heap and stack have not collided, or that
this default 64k is enough for the program being executed.
However, it ensures that this simple crt0 world will not
immediately cause an overflow event: */
sub sl, sp, #64 << 10 /* Still assumes 256bytes below sl */
#endif
#endif
/* Zero the memory in the .bss section. */
mov a2, #0 /* Second arg: fill value */
mov fp, a2 /* Null frame pointer */
mov r7, a2 /* Null frame pointer for Thumb */
ldr a1, .LC1 /* First arg: start of memory block */
ldr a3, .LC2
sub a3, a3, a1 /* Third arg: length of block */
#if defined(__thumb__) && !defined(__thumb2__)
/* Enter Thumb mode.... */
add a4, pc, #1 /* Get the address of the Thumb block */
bx a4 /* Go there and start Thumb decoding */
.code 16
.global __change_mode
.thumb_func
__change_mode:
#endif
bl FUNCTION (memset)
#if !defined (ARM_RDP_MONITOR) && !defined (ARM_RDI_MONITOR)
mov r0, #0 /* no arguments */
mov r1, #0 /* no argv either */
#else
/* Need to set up standard file handles */
bl FUNCTION (initialise_monitor_handles)
#ifdef ARM_RDP_MONITOR
swi SWI_GetEnv /* sets r0 to point to the command line */
mov r1, r0
#else
mov r0, #AngelSWI_Reason_GetCmdLine
adr r1, .LC30 /* Space for command line */
AngelSWIAsm AngelSWI
ldr r1, .LC30
#endif
/* Parse string at r1 */
mov r0, #0 /* count of arguments so far */
/* Push a NULL argument onto the end of the list. */
#ifdef __thumb__
push {r0}
#else
stmfd sp!, {r0}
#endif
.LC10:
/* Skip leading blanks */
#ifdef __thumb__
ldrb r3, [r1]
add r1, #1
#else
ldrb r3, [r1], #1
#endif
cmp r3, #0
beq .LC12
cmp r3, #' '
beq .LC10
/* See whether we are scanning a string */
cmp r3, #'"'
#ifdef __thumb__
beq .LC20
cmp r3, #'\''
bne .LC21
.LC20:
mov r2, r3
b .LC22
.LC21:
mov r2, #' ' /* terminator type */
sub r1, r1, #1 /* adjust back to point at start char */
.LC22:
#else
cmpne r3, #'\''
moveq r2, r3
movne r2, #' ' /* terminator type */
subne r1, r1, #1 /* adjust back to point at start char */
#endif
/* Stack a pointer to the current argument */
#ifdef __thumb__
push {r1}
#else
stmfd sp!, {r1}
#endif
add r0, r0, #1
.LC11:
#ifdef __thumb__
ldrb r3, [r1]
add r1, #1
#else
ldrb r3, [r1], #1
#endif
cmp r3, #0
beq .LC12
cmp r2, r3 /* reached terminator? */
bne .LC11
mov r2, #0
sub r3, r1, #1
strb r2, [r3] /* terminate the arg string */
b .LC10
.LC12:
mov r1, sp /* point at stacked arg pointers */
/* We've now got the stacked args in order reverse the */
#ifdef __thumb__
mov r2, r0
lsl r2, #2
add r2, sp
mov r3, sp
.LC15: cmp r2, r3
bls .LC14
sub r2, #4
ldr r4, [r2]
ldr r5, [r3]
str r5, [r2]
str r4, [r3]
add r3, #4
b .LC15
.LC14:
/* Ensure doubleword stack alignment. */
mov r4, sp
mov r5, #7
bic r4, r5
mov sp, r4
#else
add r2, sp, r0, LSL #2 /* End of args */
mov r3, sp /* Start of args */
.LC13: cmp r2, r3
ldrhi r4,[r2, #-4] /* Reverse ends of list */
ldrhi r5, [r3]
strhi r5, [r2, #-4]!
strhi r4, [r3], #4
bhi .LC13
/* Ensure doubleword stack alignment. */
bic sp, sp, #7
#endif
#endif
#ifdef __USES_INITFINI__
/* Some arm/elf targets use the .init and .fini sections
to create constructors and destructors, and for these
targets we need to call the _init function and arrange
for _fini to be called at program exit. */
mov r4, r0
mov r5, r1
ldr r0, .Lfini
bl FUNCTION (atexit)
bl FUNCTION (_init)
mov r0, r4
mov r1, r5
#endif
bl FUNCTION (main)
bl FUNCTION (exit) /* Should not return. */
#if defined(__thumb__) && !defined(__thumb2__)
/* Come out of Thumb mode. This code should be redundant. */
mov a4, pc
bx a4
.code 32
.global change_back
change_back:
/* Halt the execution. This code should never be executed. */
/* With no debug monitor, this probably aborts (eventually).
With a Demon debug monitor, this halts cleanly.
With an Angel debug monitor, this will report 'Unknown SWI'. */
swi SWI_Exit
#endif
/* For Thumb, constants must be after the code since only
positive offsets are supported for PC relative addresses. */
.align 0
.LC0:
#ifdef ARM_RDI_MONITOR
.word HeapBase
#else
#ifndef ARM_RDP_MONITOR
#ifdef __pe__
.word 0x800000
#else
/* .word 0x80000 */ /* Top of RAM on the PIE board. */
#endif
#endif
#endif
#if defined(__ELF__) && !defined(__USING_SJLJ_EXCEPTIONS__)
/* Protect against unhandled exceptions. */
.cantunwind
.fnend
#endif
.LC1:
.word __bss_start__
.LC2:
.word __bss_end__
#ifdef __USES_INITFINI__
.Lfini:
.word FUNCTION(_fini)
#endif
#ifdef ARM_RDI_MONITOR
.LC30:
.word CommandLine
.word 255
/* Workspace for Angel calls. */
.data
/* Data returned by monitor SWI. */
.global __stack_base__
HeapBase: .word 0
HeapLimit: .word 0
__stack_base__: .word 0
StackLimit: .word 0
CommandLine: .space 256,0 /* Maximum length of 255 chars handled. */
#endif
#ifdef __pe__
.section .idata$3
.long 0,0,0,0,0,0,0,0
#endif
|
32bitmicro/newlib-nano-1.0
| 1,507
|
newlib/libc/sys/a29khif/_ioctl.S
|
; @(#)_ioctl.s 1.2 90/10/14 21:57:25, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _ioctl.s
; _ioctl( int fd );
;
.file "_ioctl.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global __ioctl
__ioctl:
const tav,HIF_ioctl @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,982
|
newlib/libc/sys/a29khif/alloc.S
|
;
;(#)_alloc.s 1.4 90/10/14 21:57:19, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1989, 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 07/06/89 (JS) Replaced call to const tav,HIF_macro
; and deleted call to reterr macro as a NULL needs to be
; returned on failure.
; _alloc.s
; void *vp = _sysalloc( int size );
;
.file "_alloc.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global __sysalloc
__sysalloc:
const tav,HIF_alloc
asneq V_SYSCALL,gr1,gr1
jmpti tav, lr0
const tpc, _errno
consth tpc, _errno
store 0, 0, tav, tpc
jmpi lr0
const v0, 0 ; return NULL on error.
;
; int errret = _sysfree( void *addr, int size );
;
.global __sysfree
__sysfree:
const tav,HIF_free
asneq V_SYSCALL,gr1,gr1
jmpti tav,lr0
const tpc,_errno
consth tpc,_errno
store 0,0,tav,tpc
jmpi lr0
constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,721
|
newlib/libc/sys/a29khif/getenv.S
|
; @(#)getenv.s 1.4 90/10/14 21:57:45, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; getenv.s
; char *value = getenv( const char *name );
;
.file "getenv.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global _getenv
.global __getenv
_getenv:
__getenv:
const tav,HIF_getenv @ asneq V_SYSCALL,gr1,gr1 ; HIF service trap
jmpti tav, lr0 ; If tav is true, were finished, return.
const tpc, _errno
consth tpc, _errno ; Otherwise,
store 0, 0, tav, tpc ; store error code in _errno,
jmpi lr0 ; then return
const v0, 0 ; with a value of 0 (NULL pointer).
.end
|
32bitmicro/newlib-nano-1.0
| 1,557
|
newlib/libc/sys/a29khif/_setvec.S
|
; @(#)_setvec.s 1.2 90/10/14 21:57:35, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _setvec.s
; int success = _setvec( int trap_no, void (*handler)( void ) );
;
.file "_setvec.s"
.include "sys/sysmac.h"
.text
.word 0x00040000 ; Debugger tag word
.global __setvec
__setvec:
const tav,HIF_setvec @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 2,125
|
newlib/libc/sys/a29khif/_alloc.S
|
; @(#)_alloc.s 1.4 90/10/14 21:57:19, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1989, 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 07/06/89 (JS) Replaced call to const tav,HIF_macro @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1 to syscall macro,
; and deleted call to reterr macro as a NULL needs to be
; returned on failure.
; _alloc.s
; void *vp = _sysalloc( int size );
;
.file "_alloc.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global __sysalloc
__sysalloc:
const tav,HIF_alloc @ asneq V_SYSCALL,gr1,gr1
jmpti tav, lr0
const tpc, _errno
consth tpc, _errno
store 0, 0, tav, tpc
jmpi lr0
const v0, 0 ; return NULL on error.
;
; int errret = _sysfree( void *addr, int size );
;
.global __sysfree
__sysfree:
const tav,HIF_free @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,514
|
newlib/libc/sys/a29khif/_iowait.S
|
; @(#)_iowait.s 1.3 90/10/14 21:57:27, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _iowait.s
; _iowait( int fd );
;
.file "_iowait.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global __iowait
__iowait:
const tav,HIF_iowait @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,533
|
newlib/libc/sys/a29khif/_read.S
|
; @(#)_read.s 1.4 90/10/14 21:57:32, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _read.s
; int nread = _read( int fd, char *buf, int count );
;
.file "_read.s"
.include "sys/sysmac.h"
.text
.word 0x00050000 ; Debugger tag word
.global __read
__read:
const tav,HIF_read @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,655
|
newlib/libc/sys/a29khif/_tmpnam.S
|
; @(#)_tmpnam.s 1.2 90/10/14 21:57:36, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _tmpnam.s
; char *cp = _khif_tmpnam( char *bufr );
; /* same as ANSI tmpnam(), but NULL arg is not allowed */
; NOTE - Will not work on BSD (no tmpnam sys call)
;
.file "_tmpnam.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global __khif_tmpnam
__khif_tmpnam:
const tav,HIF_tmpnam @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 2,124
|
newlib/libc/sys/a29khif/stubs.S
|
;
;
; File of stubs so that unix applications can link into a HIF monitor
;
; sac@cygnus.com
.text
.global _sysalloc
_sysalloc:
const gr121,__sysalloc
consth gr121,__sysalloc
jmpi gr121
.global _sysfree
_sysfree:
const gr121,__sysfree
consth gr121,__sysfree
jmpi gr121
.global _cycles
_cycles:
const gr121,__cycles
consth gr121,__cycles
jmpi gr121
; .global _exit
;_exit:
; const gr121,__exit
; consth gr121,__exit
; jmpi gr121
.global _getpsiz
_getpsiz:
const gr121,__getpsiz
consth gr121,__getpsiz
jmpi gr121
.global _gettz
_gettz:
const gr121,__gettz
consth gr121,__gettz
jmpi gr121
.global _ioctl
_ioctl:
const gr121,__ioctl
consth gr121,__ioctl
jmpi gr121
.global _iowait
_iowait:
const gr121,__iowait
consth gr121,__iowait
jmpi gr121
;; syscalls used now -- .global _open
;; syscalls used now -- _open:
;; syscalls used now -- const gr121,__open
;; syscalls used now -- consth gr121,__open
;; syscalls used now -- jmpi gr121
.global _query
_query:
const gr121,__query
consth gr121,__query
jmpi gr121
.global _setim
_setim:
const gr121,__setim
consth gr121,__setim
jmpi gr121
.global _settrap
_settrap:
const gr121,__settrap
consth gr121,__settrap
jmpi gr121
.global _setvec
_setvec:
const gr121,__setvec
consth gr121,__setvec
jmpi gr121
.global _getargs
_getargs:
const gr121,__getargs
consth gr121,__getargs
jmpi gr121
;; syscalls used now -- .global _unlink
;; syscalls used now -- _unlink:
;; syscalls used now -- const gr121,__unlink
;; syscalls used now -- consth gr121,__unlink
;; syscalls used now -- jmpi gr121
.global _sigret
_sigret:
const gr121,__sigret
consth gr121,__sigret
jmpi gr121
.global _sigdfl
_sigdfl:
const gr121,__sigdfl
consth gr121,__sigdfl
jmpi gr121
.global _sigrep
_sigrep:
const gr121,__sigrep
consth gr121,__sigrep
jmpi gr121
.global _sigskp
_sigskp:
const gr121,__sigskp
consth gr121,__sigskp
jmpi gr121
.global _sendsig
_sendsig:
const gr121,__sendsig
consth gr121,__sendsig
jmpi gr121
; fill this jmpi delay slot
; the others are not done since they do not matter
constn lr0,-1
|
32bitmicro/newlib-nano-1.0
| 1,560
|
newlib/libc/sys/a29khif/_cycles.S
|
; @(#)_cycles.s 1.2 90/10/14 21:57:21, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _cycles.s
; struct { unsigned long low_ticks, long hi_ticks } = _cycles( );
;
.file "_cycles.s"
.include "sys/sysmac.h"
.text
.word 0x00020000 ; Debugger tag word
.global __cycles
__cycles:
const tav,HIF_cycles @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,528
|
newlib/libc/sys/a29khif/_getpsiz.S
|
; @(#)_getpsiz.s 1.2 90/10/14 21:57:23, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _getpsiz.s
; int size = _getpsiz( );
;
.file "_getpsiz.s"
.include "sys/sysmac.h"
.text
.word 0x00020000 ; Debugger tag word
.global __getpsiz
__getpsiz:
const tav,HIF_getpagesize @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,334
|
newlib/libc/sys/a29khif/vec.S
|
; @(#)vec.s 1.2 90/10/14 21:58:01, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.global V_SPILL, V_FILL
.global V_EPI_OS, V_BSD_OS
.equ V_SPILL, 64
.equ V_FILL, 65
.equ V_BSD_OS, 66
.equ V_EPI_OS, 69
.end
|
32bitmicro/newlib-nano-1.0
| 1,579
|
newlib/libc/sys/a29khif/_iostat.S
|
;----------------------------------------------------------------------------
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _iostat.s
; _iostat( int fd );
;
.file "_iostat.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global __iostat
.global _iostat
__iostat:
_iostat:
const tav,HIF_iostat @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,558
|
newlib/libc/sys/a29khif/_settrap.S
|
; @(#)_settrap.s 2.2 90/10/14 21:57:34, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _settrap.s
; void *prevaddr = _settrap( int trapno, void *trapaddr );
;
.file "_settrap.s"
.include "sys/sysmac.h"
.text
.word 0x00040000 ; Debugger tag word
.global __settrap
__settrap:
const tav,HIF_settrap @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,511
|
newlib/libc/sys/a29khif/_query.S
|
; @(#)_query.s 2.2 90/10/14 21:57:31, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _query.s
; _query( query_code );
;
.file "_query.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global __query
__query:
const tav,HIF_query @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 1,543
|
newlib/libc/sys/a29khif/systime.S
|
; @(#)systime.s 1.2 90/10/14 21:57:59, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _time.s
; time_t secs = time( time_t *secs );
;
; NOTE - Will not work on BSD (no time sys call)
;
.file "systime.s"
.include "sys/sysmac.h"
.text
.word 0x00030000 ; Debugger tag word
.global _time
_time:
const tav,HIF_time @ asneq V_SYSCALL,gr1,gr1
cpeq gr97, lr2, 0
jmpti gr97, lr0
nop
jmpi lr0
store 0, 0, gr96, lr2
.end
|
32bitmicro/newlib-nano-1.0
| 1,538
|
newlib/libc/sys/a29khif/_open.S
|
; @(#)_open.s 1.4 90/10/14 21:57:30, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _open.s
; int fd = _open( char *path, int oflag [, int mode ] );
;
.file "_open.s"
.include "sys/sysmac.h"
.text
.word 0x00050000 ; Debugger tag word
.global __open
__open:
const tav,HIF_open @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.end
|
32bitmicro/newlib-nano-1.0
| 2,081
|
newlib/libc/sys/a29khif/read.S
|
; @(#)_read.s 1.4 90/10/14 21:57:32, AMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright 1990 Advanced Micro Devices, Inc.
;
; This software is the property of Advanced Micro Devices, Inc (AMD) which
; specifically grants the user the right to modify, use and distribute this
; software provided this notice is not removed or altered. All other rights
; are reserved by AMD.
;
; AMD MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS
; SOFTWARE. IN NO EVENT SHALL AMD BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL
; DAMAGES IN CONNECTION WITH OR ARISING FROM THE FURNISHING, PERFORMANCE, OR
; USE OF THIS SOFTWARE.
;
; So that all may benefit from your experience, please report any problems
; or suggestions about this software to the 29K Technical Support Center at
; 800-29-29-AMD (800-292-9263) in the USA, or 0800-89-1131 in the UK, or
; 0031-11-1129 in Japan, toll free. The direct dial number is 512-462-4118.
;
; Advanced Micro Devices, Inc.
; 29K Support Products
; Mail Stop 573
; 5900 E. Ben White Blvd.
; Austin, TX 78741
; 800-292-9263
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; _read.s
; int nread = _read( int fd, char *buf, int count );
;
.file "_read.s"
.include "sys/sysmac.h"
.text
.word 0x00050000 ; Debugger tag word
.global __read
;; syscalls used now -- .global _read
__read:
;; syscalls used now -- _read:
.ifdef _BSD_OS
; BSD version - uses readv const tav,HIF_call @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
sub msp, msp, 8
store 0, 0, lr3, msp
add tav, msp, 4
add lr3, msp, 0
store 0, 0, lr4, tav
const lr4, 1
const tav,HIF_readv @ asneq V_SYSCALL,gr1,gr1
jmpti tav, lr0
add msp, msp, 8
const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.else
const tav,HIF_read @ asneq V_SYSCALL,gr1,gr1 @ jmpti tav,lr0 @ const tpc,_errno @ consth tpc,_errno @ store 0,0,tav,tpc @ jmpi lr0 @ constn v0,-1
.endif
.end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.