Page 278 - Programming Microcontrollers in C
P. 278
Timer Operations 263
15 0003 0C .byte 12
16 .set OFST=12
17 ; 5 unsigned long num = 120000000;
18 0004 CC0E00 ldd #3584
19 0007 ED0A std OFST-2,x
20 0009 CC0727 ldd #1831
21 000C ED08 std OFST-4,x
22 ; 6
23 ; 7 return num/RPM;
24 000E EC0C ldd OFST+0,x
25 0010 6F02 clr 2,x
26 0012 6F03 clr 3,x
27 0014 ED06 std OFST-6,x
28 0016 EC02 ldd 2,x
29 0018 ED04 std OFST-8,x
30 001A EC08 ldd OFST-4,x
31 001C ED02 std 2,x
32 001E EC00 ldd 0,x
33 0020 C3FFF7 addd #-9
34 0023 188F xgdy
35 0025 EC0A ldd OFST-2,x
36 0027 BD0000 jsr c_ludv
37 002A AE00 lds 0,x
38 002C 38 pulx
39 002D 39 rts
40 ; 8 }
41 ; 9
42 .public _count
43 .public _Register_Set
44 .external c_kents
45 .external c_ludv
46 .end
This function requires 0x2d bytes (45 bytes) of code and that
does not count the functions c_ludv and c_kents that must be
linked to this function. Our innocuous little one-line piece of code
creates a rather formidable piece of assembly code. If at all possible,
it would be desirable to shorten this function. A slight modification
of the above function code is