comparison code_part1/OSTC_code_asm_part1/valconv.asm @ 103:fe195f766014

Codesize optimized valconv.asm
author JeanDo
date Tue, 14 Dec 2010 11:14:32 +0100
parents e8756eba54ee
children 966ebf905514
comparison
equal deleted inserted replaced
101:526d2c016645 103:fe195f766014
16 16
17 17
18 ; converts hex values to dez values 18 ; converts hex values to dez values
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com 19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
20 ; written: 13/10/07 20 ; written: 13/10/07
21 ; last updated: 5/11/07 21 ; 10/12/2010 jDG: optimize macro size.
22 ; last updated: 10/12/2010
22 ; known bugs: 23 ; known bugs:
23 ; ToDo: clean up!!! 24 ; ToDo: clean up!!!
24 25
25 26
26 output_16_3 macro ; displays only last three figures from a 16Bit value (0-999) 27 output_16_3 macro ; displays only last three figures from a 16Bit value (0-999)
27 clrf ignore_digits 28 call output16_3_call
28 incf ignore_digits,F
29 clrf temp4
30 bsf show_last3
31 movf temp4,W ; Temp4 stores position for decimal point
32 call output16
33 endm 29 endm
34 30
35 output_16dp macro temp4 ; 16Bit with decimal point 31 output_16dp macro temp4 ; 16Bit with decimal point
36 movlw temp4 ; Temp4 stores position for decimal point 32 movlw temp4 ; Temp4 stores position for decimal point
37 call output16 33 call output16
38 endm 34 endm
39 35
40 output_16 macro ; 16Bit Normal 36 output_16 macro ; 16Bit Normal
37 call output16_call
38 endm
39
40 output_8 macro ; 8 Bit Normal
41 call output8_call
42 endm
43
44 output_99 macro ; displays only last two figures from a 8Bit value (0-99)
45 call output99_call
46 endm
47
48 output_99x macro ; displays only last two figures from a 8Bit value with leading zero (00-99)
49 call output99x_call
50 endm
51
52 output99_call:
41 clrf ignore_digits 53 clrf ignore_digits
42 incf ignore_digits,F 54 incf ignore_digits,F
43 clrf temp4 55 clrf temp4
44 movf temp4,W ; Temp4 stores position for decimal point
45 call output16
46 endm
47
48 output_8 macro ; 8 Bit Normal
49 clrf ignore_digits
50 incf ignore_digits,F
51 clrf temp4
52 call output8
53 endm
54
55 output_99 macro ; displays only last two figures from a 8Bit value (0-99)
56 clrf ignore_digits
57 incf ignore_digits,F
58 clrf temp4
59 call output99
60 endm
61
62 output_99x macro ; displays only last two figures from a 8Bit value with leading zero (00-99)
63 clrf ignore_digits
64 incf ignore_digits,F
65 clrf temp4
66 call output99x
67 endm
68 56
69 output99: 57 output99:
70 movlw d'99' 58 movlw d'99'
71 cpfslt lo 59 cpfslt lo
72 movwf lo ; Limit to 99 60 movwf lo ; Limit to 99
85 clrf temp3 73 clrf temp3
86 bsf pre_zero_flag ; last figure, display zero (0) 74 bsf pre_zero_flag ; last figure, display zero (0)
87 rcall DEC2ASCII 75 rcall DEC2ASCII
88 RETURN 76 RETURN
89 77
90 output99x: 78 output99x_call:
79 clrf ignore_digits
80 incf ignore_digits,F
81 clrf temp4
82
91 movlw d'99' 83 movlw d'99'
92 cpfslt lo 84 cpfslt lo
93 movwf lo ; Limit to 99 85 movwf lo ; Limit to 99
94 movff lo, lo_temp 86 movff lo, lo_temp
95 clrf hi_temp 87 clrf hi_temp
96 bsf pre_zero_flag ; display leading zeros 88 bsf pre_zero_flag ; display leading zeros
97 bra LCD_val99_2 89 bra LCD_val99_2
98 90
91 output8_call:
92 clrf ignore_digits
93 incf ignore_digits,F
94 clrf temp4
95
99 output8 96 output8
100 movff lo, lo_temp 97 movff lo, lo_temp
101 clrf hi_temp 98 clrf hi_temp
102 bcf pre_zero_flag ; do not display leading zeros 99 bcf pre_zero_flag ; do not display leading zeros
103 100
105 movwf temp2 102 movwf temp2
106 clrf temp3 103 clrf temp3
107 rcall DEC2ASCII 104 rcall DEC2ASCII
108 bra LCD_val99_2 105 bra LCD_val99_2
109 106
107 output16_3_call:
108 clrf ignore_digits
109 incf ignore_digits,F
110 clrf WREG
111 bra output16
112
113 output16_call:
114 clrf ignore_digits
115 incf ignore_digits,F
116 clrf WREG
117
110 output16 118 output16
119 movwf temp4 ; Passed from output16dp macro, cleared by others.
120
111 bcf all_zeros_flag ; do not display any zero from here unless there was at least one figure /zero 121 bcf all_zeros_flag ; do not display any zero from here unless there was at least one figure /zero
112 122
113 movwf temp4
114
115 bsf leading_zeros 123 bsf leading_zeros
116 incf temp4,1 124 incf temp4,1
117 decfsz temp4,F 125 decfsz temp4,F
118 bcf leading_zeros 126 bcf leading_zeros
119 127