summaryrefslogtreecommitdiff
path: root/device/lib/stm8-large/_memcmp.asm
blob: a8f78b66625b73358540f8cfef9da69abcd75f30 (plain) (blame)
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
;--------------------------------------------------------
; File Created by SDCC : free open source ANSI-C Compiler
; Version 3.9.3 #11345 (Linux)
;--------------------------------------------------------
	.module _memcmp
	.optsdcc -mstm8
	
;--------------------------------------------------------
; Public variables in this module
;--------------------------------------------------------
	.globl _memcmp
;--------------------------------------------------------
; 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
;	../_memcmp.c: 31: int memcmp (const void * buf1, const void * buf2, size_t count)
;	-----------------------------------------
;	 function memcmp
;	-----------------------------------------
_memcmp:
	sub	sp, #5
;	../_memcmp.c: 33: if (!count)
;	../_memcmp.c: 34: return(0);
	ldw	x, (0x0d, sp)
;	../_memcmp.c: 36: while ( --count && *((char *)buf1) == *((char *)buf2) ) {
	jreq	00107$
	ldw	y, (0x0d, sp)
	ldw	(0x04, sp), y
00104$:
	ldw	x, (0x04, sp)
	decw	x
	ldw	(0x04, sp), x
	ldw	x, (0x09, sp)
	ldw	y, (0x0b, sp)
	ldw	(0x01, sp), y
	ld	a, (x)
	ld	(0x03, sp), a
	ldw	y, (0x01, sp)
	ld	a, (y)
	ldw	y, (0x04, sp)
	jreq	00106$
	cp	a, (0x03, sp)
	jrne	00106$
;	../_memcmp.c: 37: buf1 = (char *)buf1 + 1;
	incw	x
	ldw	(0x09, sp), x
;	../_memcmp.c: 38: buf2 = (char *)buf2 + 1;
	ldw	x, (0x01, sp)
	incw	x
	ldw	(0x0b, sp), x
	jra	00104$
00106$:
;	../_memcmp.c: 41: return( *((unsigned char *)buf1) - *((unsigned char *)buf2) );
	clrw	x
	exg	a, xl
	ld	a, (0x03, sp)
	exg	a, xl
	ld	(0x05, sp), a
	clr	(0x04, sp)
	subw	x, (0x04, sp)
00107$:
;	../_memcmp.c: 42: }
	addw	sp, #5
	retf
	.area CODE
	.area CONST
	.area INITIALIZER
	.area CABS (ABS)