1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.9.3 #11345 (Linux)
;--------------------------------------------------------
.module _strncpy
.optsdcc -mstm8
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
.globl _strncpy
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area DATA
;--------------------------------------------------------
; ram data
;--------------------------------------------------------
.area INITIALIZED
;--------------------------------------------------------
; absolute external ram data
;--------------------------------------------------------
.area DABS (ABS)
; default segment ordering for linker
.area HOME
.area GSINIT
.area GSFINAL
.area CONST
.area INITIALIZER
.area CODE
;--------------------------------------------------------
; global & static initialisations
;--------------------------------------------------------
.area HOME
.area GSINIT
.area GSFINAL
.area GSINIT
;--------------------------------------------------------
; Home
;--------------------------------------------------------
.area HOME
.area HOME
;--------------------------------------------------------
; code
;--------------------------------------------------------
.area CODE
; ../_strncpy.c: 33: char *strncpy ( char * d, const char * s, size_t n )
; -----------------------------------------
; function strncpy
; -----------------------------------------
_strncpy:
sub sp, #6
; ../_strncpy.c: 35: register char * d1 = d;
ldw y, (0x0a, sp)
ldw (0x01, sp), y
; ../_strncpy.c: 37: while ( n && *s )
ldw y, (0x0e, sp)
ldw (0x05, sp), y
ldw y, (0x0c, sp)
ldw (0x03, sp), y
ldw x, (0x01, sp)
00102$:
ldw y, (0x05, sp)
jreq 00114$
ldw y, (0x03, sp)
ld a, (y)
jreq 00114$
; ../_strncpy.c: 39: n-- ;
ldw y, (0x05, sp)
decw y
ldw (0x05, sp), y
; ../_strncpy.c: 40: *d++ = *s++ ;
ldw y, (0x03, sp)
incw y
ldw (0x03, sp), y
ld (x), a
incw x
jra 00102$
; ../_strncpy.c: 42: while ( n-- )
00114$:
00105$:
ldw y, (0x05, sp)
ldw (0x03, sp), y
ldw y, (0x05, sp)
decw y
ldw (0x05, sp), y
ldw y, (0x03, sp)
jreq 00107$
; ../_strncpy.c: 44: *d++ = '\0' ;
clr (x)
incw x
jra 00105$
00107$:
; ../_strncpy.c: 46: return d1;
ldw x, (0x01, sp)
; ../_strncpy.c: 47: }
addw sp, #6
retf
.area CODE
.area CONST
.area INITIALIZER
.area CABS (ABS)
|