Index

auto-plow / 90c3edc

A wheelchair motor-propelled battery-powered ESP32-driven remote control snow plow.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
1401 Dec 2018 13:444f44ee4Rename wiring_pulse.S to wiring_pulse_a.SJoshua11780N

Blob @ auto-plow / include / arduino / wiring_pulse_a.S

text/plain6022 bytesdownload raw
1/*
2 wiring_pulse.s - pulseInASM() function in different flavours
3 Part of Arduino - http://www.arduino.cc/
4
5 Copyright (c) 2014 Martino Facchin
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General
18 Public License along with this library; if not, write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 Boston, MA 02111-1307 USA
21*/
22
23/*
24 * The following routine was generated by avr-gcc 4.8.3 with the following parameters
25 * -gstabs -Wa,-ahlmsd=output.lst -dp -fverbose-asm -O2
26 * on the original C function
27 *
28 * unsigned long pulseInSimpl(volatile uint8_t *port, uint8_t bit, uint8_t stateMask, unsigned long maxloops)
29 * {
30 * unsigned long width = 0;
31 * // wait for any previous pulse to end
32 * while ((*port & bit) == stateMask)
33 * if (--maxloops == 0)
34 * return 0;
35 *
36 * // wait for the pulse to start
37 * while ((*port & bit) != stateMask)
38 * if (--maxloops == 0)
39 * return 0;
40 *
41 * // wait for the pulse to stop
42 * while ((*port & bit) == stateMask) {
43 * if (++width == maxloops)
44 * return 0;
45 * }
46 * return width;
47 * }
48 *
49 * some compiler outputs were removed but the rest of the code is untouched
50 */
51
52#include <avr/io.h>
53
54.section .text
55
56.global countPulseASM
57
58countPulseASM:
59
60.LM0:
61.LFBB1:
62 push r12 ; ; 130 pushqi1/1 [length = 1]
63 push r13 ; ; 131 pushqi1/1 [length = 1]
64 push r14 ; ; 132 pushqi1/1 [length = 1]
65 push r15 ; ; 133 pushqi1/1 [length = 1]
66 push r16 ; ; 134 pushqi1/1 [length = 1]
67 push r17 ; ; 135 pushqi1/1 [length = 1]
68/* prologue: function */
69/* frame size = 0 */
70/* stack size = 6 */
71.L__stack_usage = 6
72 mov r30,r24 ; port, port ; 2 *movhi/1 [length = 2]
73 mov r31,r25 ; port, port
74/* unsigned long width = 0;
75*** // wait for any previous pulse to end
76*** while ((*port & bit) == stateMask)
77*/
78.LM1:
79 rjmp .L2 ; ; 181 jump [length = 1]
80.L4:
81/* if (--maxloops == 0) */
82.LM2:
83 subi r16,1 ; maxloops, ; 17 addsi3/2 [length = 4]
84 sbc r17, r1 ; maxloops
85 sbc r18, r1 ; maxloops
86 sbc r19, r1 ; maxloops
87 breq .L13 ; , ; 19 branch [length = 1]
88.L2:
89/* if (--maxloops == 0) */
90.LM3:
91 ld r25,Z ; D.1554, *port_7(D) ; 22 movqi_insn/4 [length = 1]
92 and r25,r22 ; D.1554, bit ; 24 andqi3/1 [length = 1]
93 cp r25,r20 ; D.1554, stateMask ; 25 *cmpqi/2 [length = 1]
94 breq .L4 ; , ; 26 branch [length = 1]
95 rjmp .L6 ; ; 184 jump [length = 1]
96.L7:
97/* return 0;
98***
99*** // wait for the pulse to start
100*** while ((*port & bit) != stateMask)
101*** if (--maxloops == 0)
102*/
103.LM4:
104 subi r16,1 ; maxloops, ; 31 addsi3/2 [length = 4]
105 sbc r17, r1 ; maxloops
106 sbc r18, r1 ; maxloops
107 sbc r19, r1 ; maxloops
108 breq .L13 ; , ; 33 branch [length = 1]
109.L6:
110/* if (--maxloops == 0) */
111.LM5:
112 ld r25,Z ; D.1554, *port_7(D) ; 41 movqi_insn/4 [length = 1]
113 and r25,r22 ; D.1554, bit ; 43 andqi3/1 [length = 1]
114 cpse r25,r20 ; D.1554, stateMask ; 44 enable_interrupt-3 [length = 1]
115 rjmp .L7 ;
116 mov r12, r1 ; width ; 7 *movsi/2 [length = 4]
117 mov r13, r1 ; width
118 mov r14, r1 ; width
119 mov r15, r1 ; width
120 rjmp .L9 ; ; 186 jump [length = 1]
121.L10:
122/* return 0;
123***
124*** // wait for the pulse to stop
125*** while ((*port & bit) == stateMask) {
126*** if (++width == maxloops)
127*/
128.LM6:
129 ldi r24,-1 ; , ; 50 addsi3/3 [length = 5]
130 sub r12,r24 ; width,
131 sbc r13,r24 ; width,
132 sbc r14,r24 ; width,
133 sbc r15,r24 ; width,
134 cp r16,r12 ; maxloops, width ; 51 *cmpsi/2 [length = 4]
135 cpc r17,r13 ; maxloops, width
136 cpc r18,r14 ; maxloops, width
137 cpc r19,r15 ; maxloops, width
138 breq .L13 ; , ; 52 branch [length = 1]
139.L9:
140/* if (++width == maxloops) */
141.LM7:
142 ld r24,Z ; D.1554, *port_7(D) ; 60 movqi_insn/4 [length = 1]
143 and r24,r22 ; D.1554, bit ; 62 andqi3/1 [length = 1]
144 cp r24,r20 ; D.1554, stateMask ; 63 *cmpqi/2 [length = 1]
145 breq .L10 ; , ; 64 branch [length = 1]
146/* return 0;
147*** }
148*** return width;
149*/
150.LM8:
151 mov r22,r12 ; D.1553, width ; 108 movqi_insn/1 [length = 1]
152 mov r23,r13 ; D.1553, width ; 109 movqi_insn/1 [length = 1]
153 mov r24,r14 ; D.1553, width ; 110 movqi_insn/1 [length = 1]
154 mov r25,r15 ; D.1553, width ; 111 movqi_insn/1 [length = 1]
155/* epilogue start */
156.LM9:
157 pop r17 ; ; 171 popqi [length = 1]
158 pop r16 ; ; 172 popqi [length = 1]
159 pop r15 ; ; 173 popqi [length = 1]
160 pop r14 ; ; 174 popqi [length = 1]
161 pop r13 ; ; 175 popqi [length = 1]
162 pop r12 ; ; 176 popqi [length = 1]
163 ret ; 177 return_from_epilogue [length = 1]
164.L13:
165.LM10:
166 ldi r22,0 ; D.1553 ; 120 movqi_insn/1 [length = 1]
167 ldi r23,0 ; D.1553 ; 121 movqi_insn/1 [length = 1]
168 ldi r24,0 ; D.1553 ; 122 movqi_insn/1 [length = 1]
169 ldi r25,0 ; D.1553 ; 123 movqi_insn/1 [length = 1]
170/* epilogue start */
171.LM11:
172 pop r17 ; ; 138 popqi [length = 1]
173 pop r16 ; ; 139 popqi [length = 1]
174 pop r15 ; ; 140 popqi [length = 1]
175 pop r14 ; ; 141 popqi [length = 1]
176 pop r13 ; ; 142 popqi [length = 1]
177 pop r12 ; ; 143 popqi [length = 1]
178 ret ; 144 return_from_epilogue [length = 1]
179