Nik Zhafran
Junior Member level 1
- Joined
- Feb 23, 2015
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Location
- Shinjuku-ku, Tokyo, Japan, Japan
- Activity points
- 134
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
try yourself with this clue. use 'swap' instruction and accumulator
Org 00H
data_a equ P2
IPIN EQU P1.0
DPIN EQU P1.1
Mynumber Equ 30H
; ************************************************* ******
; Conversi hex to perpuluhan
; ************************************************* ******
BCD: Mov A,Mynumber
MOV B,#10
DIV AB
SWAP A
ORL A,B
MOV P2,A
mov dptr,#seg_conv
MOVC A,@A+DPTR ; MOVE DATA @A+DPTR IN A
mov data_a, A
Ret
mov dptr,#seg_conv
MOVC A,@A+DPTR ; MOVE DATA @A+DPTR IN A
mov data_a, A
you dont required these lines
; ************************************************* ******
; Data aray seven segment
; ************************************************* ******
Seg_conv:
DB 00H ; 0
DB 01H ; 1
DB 02H ; 2
DB 03H ; 3
DB 04H ; 4
DB 05H ; 5
DB 06H ; 6
DB 07H ; 7
DB 08H ; 8
DB 09H ; 9
END
either change hardware or mov the contents of B first then A. try, just extra 2 more extra code
Org 00H
data_a equ P2
IPIN EQU P1.0
DPIN EQU P1.1
Mynumber Equ 30H
main_prog:
CALL INIT
AGAIN:
AG2: JB IPIN,AG1
CALL DELAY1 ;debounce
JB IPIN,AG1
JNB IPIN,$ ;wait till switch release
INC MYNUMBER
mov a,mynumber
cjne a,#100,pq1
mov mynumber,#01
pq1:
call bcd ;diaplay data
AG1: JB DPIN,AG2
CALL DELAY1
JB DPIN,AG2
JNB DPIN,$
clr mynumber
mov a,#0C0H
cjne a,#0C0H,pq2
mov mynumber,#00
pq2:
call bcd
JMP AGAIN
INIT:
MOV data_a,#00H
MOV data_a,#00H
mov Mynumber,#0
mov p1,#255 ;set port 1 as input BY . IT SHOULD BE 1
RET
DELAY1: MOV R4,#255
DJNZ R4,$
RET
; ************************************************* ******
; Conversi hex to perpuluhan
; ************************************************* ******
BCD: Mov A,Mynumber
MOV B,#01
DIV AB
SWAP A
ORL A,B
MOV P2,A
Ret
; ************************************************* ******
; Tunda
; ************************************************* ******
delay: MOV R5,#0ffh
MOV R6,#0ffH
MOV R7,#2
delay_loop: DJNZ R5,delay_loop
DJNZ R6,delay_loop
DJNZ R7,delay_loop
RET
; ************************************************* ******
; Data aray seven segment
; ************************************************* ******
Seg_conv:
DB 00H ; 0
DB 01H ; 1
DB 02H ; 2
DB 03H ; 3
DB 04H ; 4
DB 05H ; 5
DB 06H ; 6
DB 07H ; 7
DB 08H ; 8
DB 09H ; 9
END
BCD: Mov A,Mynumber
MOV B,#01
DIV AB
SWAP A
ORL A,B
MOV P2,A
Ret
Code C - [expand] 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 unsigned char counter = 0, bcd = 0, bcdU = 0, bcdL = 0; char Dec2Bcd(unsigned char dec) { return (((dec / 10) << 4) | (dec % 10)); } void main() { P0 = 0x00; P1 = 0x00; P2 = 0x03; P3 = 0x00; while(1) { if(!P2_0_bit) { Delay_ms(30); while(!P2_0_bit); if(counter < 99)++counter; } if(!P2_1_bit) { Delay_ms(30); while(!P2_1_bit); if(counter > 0)--counter; } bcd = Dec2Bcd(counter); bcdU = (bcd & 0x0F) << 4; bcdL = bcd >> 4; P3 = bcdU | bcdL; } }
Code ASM - [expand] 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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 _Dec2Bcd: ;dec2bcd2ssd.c,3 :: char Dec2Bcd(unsigned char dec) { ;dec2bcd2ssd.c,4 :: return (((dec / 10) << 4) | (dec % 10)); MOV B+0, #10 MOV A, FARG_Dec2Bcd_dec+0 DIV AB MOV R2, A MOV R0, #4 MOV A, R2 INC R0 SJMP L__Dec2Bcd10 L__Dec2Bcd11: CLR C RLC A L__Dec2Bcd10: DJNZ R0, L__Dec2Bcd11 MOV R1, A MOV B+0, #10 MOV A, FARG_Dec2Bcd_dec+0 DIV AB MOV A, B+0 MOV R0, A MOV A, R1 ORL 0, A ;dec2bcd2ssd.c,5 :: } RET ; end of _Dec2Bcd _main: MOV SP+0, #128 ;dec2bcd2ssd.c,7 :: void main() { ;dec2bcd2ssd.c,9 :: P0 = 0x00; MOV P0+0, #0 ;dec2bcd2ssd.c,10 :: P1 = 0x00; MOV P1+0, #0 ;dec2bcd2ssd.c,11 :: P2 = 0x03; MOV P2+0, #3 ;dec2bcd2ssd.c,12 :: P3 = 0x00; MOV P3+0, #0 ;dec2bcd2ssd.c,14 :: while(1) { L_main0: ;dec2bcd2ssd.c,16 :: if(!P2_0_bit) { JB P2_0_bit+0, L_main2 NOP ;dec2bcd2ssd.c,17 :: Delay_ms(30); MOV R6, 54 MOV R7, 201 DJNZ R7, DJNZ R6, ;dec2bcd2ssd.c,18 :: while(!P2_0_bit); L_main3: JB P2_0_bit+0, L_main4 NOP SJMP L_main3 L_main4: ;dec2bcd2ssd.c,19 :: if(counter < 99)++counter; CLR C MOV A, _counter+0 SUBB A, #99 JNC L_main5 INC _counter+0 L_main5: ;dec2bcd2ssd.c,20 :: } L_main2: ;dec2bcd2ssd.c,22 :: if(!P2_1_bit) { JB P2_1_bit+0, L_main6 NOP ;dec2bcd2ssd.c,23 :: Delay_ms(30); MOV R6, 54 MOV R7, 201 DJNZ R7, DJNZ R6, ;dec2bcd2ssd.c,24 :: while(!P2_1_bit); L_main7: JB P2_1_bit+0, L_main8 NOP SJMP L_main7 L_main8: ;dec2bcd2ssd.c,25 :: if(counter > 0)--counter; SETB C MOV A, _counter+0 SUBB A, #0 JC L_main9 DEC _counter+0 L_main9: ;dec2bcd2ssd.c,26 :: } L_main6: ;dec2bcd2ssd.c,28 :: bcd = Dec2Bcd(counter); MOV FARG_Dec2Bcd_dec+0, _counter+0 LCALL _Dec2Bcd+0 MOV _bcd+0, 0 ;dec2bcd2ssd.c,29 :: bcdU = (bcd & 0x0F) << 4; MOV A, R0 ANL A, #15 MOV R2, A MOV R1, #4 MOV A, R2 INC R1 SJMP L__main12 L__main13: CLR C RLC A L__main12: DJNZ R1, L__main13 MOV R3, A MOV _bcdU+0, 3 ;dec2bcd2ssd.c,30 :: bcdL = bcd >> 4; MOV R2, #4 MOV A, R0 INC R2 SJMP L__main14 L__main15: CLR C RRC A L__main14: DJNZ R2, L__main15 MOV R1, A MOV _bcdL+0, 1 ;dec2bcd2ssd.c,31 :: P3 = bcdU | bcdL; MOV A, R3 ORL A, R1 MOV P3+0, A ;dec2bcd2ssd.c,32 :: } LJMP L_main0 ;dec2bcd2ssd.c,33 :: } SJMP #254 ; end of _main
Code C - [expand] 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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 ; LST file generated by mikroListExporter - v.2.0 ; Date/Time: 3/4/2015 12:52:34 AM ;---------------------------------------------- ;Address Opcode ASM 0x0000 0x02004D LJMP 77 0x0003 0x020000 LJMP 0 0x0006 0x00 NOP 0x0007 0x00 NOP 0x0008 0x00 NOP 0x0009 0x00 NOP 0x000A 0x00 NOP 0x000B 0x020000 LJMP 0 0x000E 0x00 NOP 0x000F 0x00 NOP 0x0010 0x00 NOP 0x0011 0x00 NOP 0x0012 0x00 NOP 0x0013 0x020000 LJMP 0 0x0016 0x00 NOP 0x0017 0x00 NOP 0x0018 0x00 NOP 0x0019 0x00 NOP 0x001A 0x00 NOP 0x001B 0x020000 LJMP 0 0x001E 0x00 NOP 0x001F 0x00 NOP 0x0020 0x00 NOP 0x0021 0x00 NOP 0x0022 0x00 NOP 0x0023 0x020000 LJMP 0 _Dec2Bcd: ;dec2bcd2ssd.c,3 :: char Dec2Bcd(unsigned char dec) { ;dec2bcd2ssd.c,4 :: return (((dec / 10) << 4) | (dec % 10)); 0x0026 0x75F00A MOV B, #10 0x0029 0xE508 MOV A, FARG_Dec2Bcd_dec 0x002B 0x84 DIV AB 0x002C 0xFA MOV R2, A 0x002D 0x7804 MOV R0, #4 0x002F 0xEA MOV A, R2 0x0030 0x08 INC R0 0x0031 0x8002 SJMP L__Dec2Bcd10 L__Dec2Bcd11: 0x0033 0xC3 CLR C 0x0034 0x33 RLC A L__Dec2Bcd10: 0x0035 0xD8FC DJNZ R0, L__Dec2Bcd11 0x0037 0xF9 MOV R1, A 0x0038 0x75F00A MOV B, #10 0x003B 0xE508 MOV A, FARG_Dec2Bcd_dec 0x003D 0x84 DIV AB 0x003E 0xE5F0 MOV A, B 0x0040 0xF8 MOV R0, A 0x0041 0xE9 MOV A, R1 0x0042 0x4200 ORL R0, A ;dec2bcd2ssd.c,5 :: } 0x0044 0x22 RET ; end of _Dec2Bcd ___CC2D: ;__Lib_System.c,13 :: ;__Lib_System.c,15 :: _CC2D_Loop1: ;__Lib_System.c,16 :: 0x0045 0xE4 CLR A ;__Lib_System.c,17 :: 0x0046 0x93 MOVC A, @A+DPTR ;__Lib_System.c,18 :: 0x0047 0xF6 MOV @R0, A ;__Lib_System.c,19 :: 0x0048 0x08 INC R0 ;__Lib_System.c,20 :: 0x0049 0xA3 INC DPTR ;__Lib_System.c,21 :: 0x004A 0xD9F9 DJNZ R1, _CC2D_Loop1 ;__Lib_System.c,23 :: 0x004C 0x22 RET ; end of ___CC2D _main: 0x004D 0x758134 MOV SP, #52 0x0050 0x1200C5 LCALL 197 ;dec2bcd2ssd.c,7 :: void main() { ;dec2bcd2ssd.c,9 :: P0 = 0x00; 0x0053 0x758000 MOV P0, #0 ;dec2bcd2ssd.c,10 :: P1 = 0x00; 0x0056 0x759000 MOV P1, #0 ;dec2bcd2ssd.c,11 :: P2 = 0x03; 0x0059 0x75A003 MOV P2, #3 ;dec2bcd2ssd.c,12 :: P3 = 0x00; 0x005C 0x75B000 MOV P3, #0 ;dec2bcd2ssd.c,14 :: while(1) { L_main0: ;dec2bcd2ssd.c,16 :: if(!P2_0_bit) { 0x005F 0x20A016 JB P2_0_bit, L_main2 ;dec2bcd2ssd.c,17 :: Delay_ms(30); 0x0062 0x7E36 MOV R6, 54 0x0064 0x7FC9 MOV R7, 201 0x0066 0xDFFE DJNZ R7, PC-2 0x0068 0xDEFC DJNZ R6, PC-4 ;dec2bcd2ssd.c,18 :: while(!P2_0_bit); L_main3: 0x006A 0x20A002 JB P2_0_bit, L_main4 0x006D 0x80FB SJMP L_main3 L_main4: ;dec2bcd2ssd.c,19 :: if(counter < 99)++counter; 0x006F 0xC3 CLR C 0x0070 0xE533 MOV A, _counter 0x0072 0x9463 SUBB A, #99 0x0074 0x5002 JNC L_main5 0x0076 0x0533 INC _counter L_main5: ;dec2bcd2ssd.c,20 :: } L_main2: ;dec2bcd2ssd.c,22 :: if(!P2_1_bit) { 0x0078 0x20A116 JB P2_1_bit, L_main6 ;dec2bcd2ssd.c,23 :: Delay_ms(30); 0x007B 0x7E36 MOV R6, 54 0x007D 0x7FC9 MOV R7, 201 0x007F 0xDFFE DJNZ R7, PC-2 0x0081 0xDEFC DJNZ R6, PC-4 ;dec2bcd2ssd.c,24 :: while(!P2_1_bit); L_main7: 0x0083 0x20A102 JB P2_1_bit, L_main8 0x0086 0x80FB SJMP L_main7 L_main8: ;dec2bcd2ssd.c,25 :: if(counter > 0)--counter; 0x0088 0xD3 SETB C 0x0089 0xE533 MOV A, _counter 0x008B 0x9400 SUBB A, #0 0x008D 0x4002 JC L_main9 0x008F 0x1533 DEC _counter L_main9: ;dec2bcd2ssd.c,26 :: } L_main6: ;dec2bcd2ssd.c,28 :: bcd = Dec2Bcd(counter); 0x0091 0x853308 MOV FARG_Dec2Bcd_dec, _counter+0 0x0094 0x1126 ACALL _Dec2Bcd 0x0096 0x850032 MOV _bcd, 0 ;dec2bcd2ssd.c,29 :: bcdU = (bcd & 0x0F) << 4; 0x0099 0xE8 MOV A, R0 0x009A 0x540F ANL A, #15 0x009C 0xFA MOV R2, A 0x009D 0x7904 MOV R1, #4 0x009F 0xEA MOV A, R2 0x00A0 0x09 INC R1 0x00A1 0x8002 SJMP L__main12 L__main13: 0x00A3 0xC3 CLR C 0x00A4 0x33 RLC A L__main12: 0x00A5 0xD9FC DJNZ R1, L__main13 0x00A7 0xFB MOV R3, A 0x00A8 0x850331 MOV _bcdU, 3 ;dec2bcd2ssd.c,30 :: bcdL = bcd >> 4; 0x00AB 0x7A04 MOV R2, #4 0x00AD 0xE8 MOV A, R0 0x00AE 0x0A INC R2 0x00AF 0x8002 SJMP L__main14 L__main15: 0x00B1 0xC3 CLR C 0x00B2 0x13 RRC A L__main14: 0x00B3 0xDAFC DJNZ R2, L__main15 0x00B5 0xF9 MOV R1, A 0x00B6 0x850130 MOV _bcdL, 1 ;dec2bcd2ssd.c,31 :: P3 = bcdU | bcdL; 0x00B9 0xEB MOV A, R3 0x00BA 0x49 ORL A, R1 0x00BB 0xF5B0 MOV P3, A ;dec2bcd2ssd.c,32 :: } 0x00BD 0x015F AJMP L_main0 ;dec2bcd2ssd.c,33 :: } 0x00BF 0x80FE SJMP #254 ; end of _main 0x00C5 0x7830 MOV R0, 48 0x00C7 0x7904 MOV R1, 4 0x00C9 0x7582C1 MOV DP0L, 193 0x00CC 0x758300 MOV DP0H, 0 0x00CF 0x120045 LCALL 69 0x00D2 0x22 RET ;dec2bcd2ssd.c,0 :: ?ICS_bcdL 0x00C1 0x00 ;?ICS_bcdL+0 ; end of ?ICS_bcdL ;dec2bcd2ssd.c,0 :: ?ICS_bcdU 0x00C2 0x00 ;?ICS_bcdU+0 ; end of ?ICS_bcdU ;dec2bcd2ssd.c,0 :: ?ICS_bcd 0x00C3 0x00 ;?ICS_bcd+0 ; end of ?ICS_bcd ;dec2bcd2ssd.c,0 :: ?ICS_counter 0x00C4 0x00 ;?ICS_counter+0 ; end of ?ICS_counter Symbol List: //** Routines locations ** //ADDRESS SIZE PROCEDURE //---------------------------------------------- 0x0026 [31] _Dec2Bcd 0x0045 [8] ___CC2D 0x004D [116] _main //** Variables locations ** //ADDRESS SIZE VARIABLE //---------------------------------------------- 0x0000 [1] R0 0x0001 [1] R1 0x0002 [1] R2 0x0003 [1] R3 0x0004 [1] R4 0x0005 [1] R5 0x0006 [1] R6 0x0007 [1] R7 0x0008 [1] FARG_Dec2Bcd_dec 0x0030 [1] _bcdL 0x0031 [1] _bcdU 0x0032 [1] _bcd 0x0033 [1] _counter 0x0080 [1] P0 0x0081 [1] SP 0x0082 [1] DPL 0x0083 [1] DPH 0x0090 [1] P1 0x00A0 [1] P2 0x00A0 [0] P2_1_bit 0x00A0 [0] P2_0_bit 0x00B0 [1] P3 0x00D0 [1] PSW 0x00E0 [1] ACC 0x00F0 [1] B //** Constants locations ** //ADDRESS SIZE CONSTANT //---------------------------------------------- 0x00C1 [1] ?ICS_bcdL 0x00C2 [1] ?ICS_bcdU 0x00C3 [1] ?ICS_bcd 0x00C4 [1] ?ICS_counter //** Label List: ** //---------------------------------------------- L_main0 L_main1 L_main2 L_main3 L_main4 L_main5 L_main6 L_main7 L_main8 L_main9 _Dec2Bcd L__Dec2Bcd10 L__Dec2Bcd11 _main L__main12 L__main13 L__main14 L__main15 _CC2D_Loop1 _CC2PD_Loop1 _CC2XD_Loop1 ___DoIFC ___CC2D ___CC2PD ___CC2XD
BCD: Mov A,Mynumber
MOV B,#10
DIV AB
MOV R3,A
MOV A,B
SWAP A
ADD A,R3 ; check this command is right or use suitable one
MOV P2,A
Ret
mikroC PRO 8051 code attached. See the .lst file for asm code generated by compiler.
Code C - [expand] 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 unsigned char counter = 0, bcd = 0, bcdU = 0, bcdL = 0; char Dec2Bcd(unsigned char dec) { return (((dec / 10) << 4) | (dec % 10)); } void main() { P0 = 0x00; P1 = 0x00; P2 = 0x03; P3 = 0x00; while(1) { if(!P2_0_bit) { Delay_ms(30); while(!P2_0_bit); if(counter < 99)++counter; } if(!P2_1_bit) { Delay_ms(30); while(!P2_1_bit); if(counter > 0)--counter; } bcd = Dec2Bcd(counter); bcdU = (bcd & 0x0F) << 4; bcdL = bcd >> 4; P3 = bcdU | bcdL; } }
Code ASM - [expand] 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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 _Dec2Bcd: ;dec2bcd2ssd.c,3 :: char Dec2Bcd(unsigned char dec) { ;dec2bcd2ssd.c,4 :: return (((dec / 10) << 4) | (dec % 10)); MOV B+0, #10 MOV A, FARG_Dec2Bcd_dec+0 DIV AB MOV R2, A MOV R0, #4 MOV A, R2 INC R0 SJMP L__Dec2Bcd10 L__Dec2Bcd11: CLR C RLC A L__Dec2Bcd10: DJNZ R0, L__Dec2Bcd11 MOV R1, A MOV B+0, #10 MOV A, FARG_Dec2Bcd_dec+0 DIV AB MOV A, B+0 MOV R0, A MOV A, R1 ORL 0, A ;dec2bcd2ssd.c,5 :: } RET ; end of _Dec2Bcd _main: MOV SP+0, #128 ;dec2bcd2ssd.c,7 :: void main() { ;dec2bcd2ssd.c,9 :: P0 = 0x00; MOV P0+0, #0 ;dec2bcd2ssd.c,10 :: P1 = 0x00; MOV P1+0, #0 ;dec2bcd2ssd.c,11 :: P2 = 0x03; MOV P2+0, #3 ;dec2bcd2ssd.c,12 :: P3 = 0x00; MOV P3+0, #0 ;dec2bcd2ssd.c,14 :: while(1) { L_main0: ;dec2bcd2ssd.c,16 :: if(!P2_0_bit) { JB P2_0_bit+0, L_main2 NOP ;dec2bcd2ssd.c,17 :: Delay_ms(30); MOV R6, 54 MOV R7, 201 DJNZ R7, DJNZ R6, ;dec2bcd2ssd.c,18 :: while(!P2_0_bit); L_main3: JB P2_0_bit+0, L_main4 NOP SJMP L_main3 L_main4: ;dec2bcd2ssd.c,19 :: if(counter < 99)++counter; CLR C MOV A, _counter+0 SUBB A, #99 JNC L_main5 INC _counter+0 L_main5: ;dec2bcd2ssd.c,20 :: } L_main2: ;dec2bcd2ssd.c,22 :: if(!P2_1_bit) { JB P2_1_bit+0, L_main6 NOP ;dec2bcd2ssd.c,23 :: Delay_ms(30); MOV R6, 54 MOV R7, 201 DJNZ R7, DJNZ R6, ;dec2bcd2ssd.c,24 :: while(!P2_1_bit); L_main7: JB P2_1_bit+0, L_main8 NOP SJMP L_main7 L_main8: ;dec2bcd2ssd.c,25 :: if(counter > 0)--counter; SETB C MOV A, _counter+0 SUBB A, #0 JC L_main9 DEC _counter+0 L_main9: ;dec2bcd2ssd.c,26 :: } L_main6: ;dec2bcd2ssd.c,28 :: bcd = Dec2Bcd(counter); MOV FARG_Dec2Bcd_dec+0, _counter+0 LCALL _Dec2Bcd+0 MOV _bcd+0, 0 ;dec2bcd2ssd.c,29 :: bcdU = (bcd & 0x0F) << 4; MOV A, R0 ANL A, #15 MOV R2, A MOV R1, #4 MOV A, R2 INC R1 SJMP L__main12 L__main13: CLR C RLC A L__main12: DJNZ R1, L__main13 MOV R3, A MOV _bcdU+0, 3 ;dec2bcd2ssd.c,30 :: bcdL = bcd >> 4; MOV R2, #4 MOV A, R0 INC R2 SJMP L__main14 L__main15: CLR C RRC A L__main14: DJNZ R2, L__main15 MOV R1, A MOV _bcdL+0, 1 ;dec2bcd2ssd.c,31 :: P3 = bcdU | bcdL; MOV A, R3 ORL A, R1 MOV P3+0, A ;dec2bcd2ssd.c,32 :: } LJMP L_main0 ;dec2bcd2ssd.c,33 :: } SJMP #254 ; end of _main
List file
Code C - [expand] 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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 ; LST file generated by mikroListExporter - v.2.0 ; Date/Time: 3/4/2015 12:52:34 AM ;---------------------------------------------- ;Address Opcode ASM 0x0000 0x02004D LJMP 77 0x0003 0x020000 LJMP 0 0x0006 0x00 NOP 0x0007 0x00 NOP 0x0008 0x00 NOP 0x0009 0x00 NOP 0x000A 0x00 NOP 0x000B 0x020000 LJMP 0 0x000E 0x00 NOP 0x000F 0x00 NOP 0x0010 0x00 NOP 0x0011 0x00 NOP 0x0012 0x00 NOP 0x0013 0x020000 LJMP 0 0x0016 0x00 NOP 0x0017 0x00 NOP 0x0018 0x00 NOP 0x0019 0x00 NOP 0x001A 0x00 NOP 0x001B 0x020000 LJMP 0 0x001E 0x00 NOP 0x001F 0x00 NOP 0x0020 0x00 NOP 0x0021 0x00 NOP 0x0022 0x00 NOP 0x0023 0x020000 LJMP 0 _Dec2Bcd: ;dec2bcd2ssd.c,3 :: char Dec2Bcd(unsigned char dec) { ;dec2bcd2ssd.c,4 :: return (((dec / 10) << 4) | (dec % 10)); 0x0026 0x75F00A MOV B, #10 0x0029 0xE508 MOV A, FARG_Dec2Bcd_dec 0x002B 0x84 DIV AB 0x002C 0xFA MOV R2, A 0x002D 0x7804 MOV R0, #4 0x002F 0xEA MOV A, R2 0x0030 0x08 INC R0 0x0031 0x8002 SJMP L__Dec2Bcd10 L__Dec2Bcd11: 0x0033 0xC3 CLR C 0x0034 0x33 RLC A L__Dec2Bcd10: 0x0035 0xD8FC DJNZ R0, L__Dec2Bcd11 0x0037 0xF9 MOV R1, A 0x0038 0x75F00A MOV B, #10 0x003B 0xE508 MOV A, FARG_Dec2Bcd_dec 0x003D 0x84 DIV AB 0x003E 0xE5F0 MOV A, B 0x0040 0xF8 MOV R0, A 0x0041 0xE9 MOV A, R1 0x0042 0x4200 ORL R0, A ;dec2bcd2ssd.c,5 :: } 0x0044 0x22 RET ; end of _Dec2Bcd ___CC2D: ;__Lib_System.c,13 :: ;__Lib_System.c,15 :: _CC2D_Loop1: ;__Lib_System.c,16 :: 0x0045 0xE4 CLR A ;__Lib_System.c,17 :: 0x0046 0x93 MOVC A, @A+DPTR ;__Lib_System.c,18 :: 0x0047 0xF6 MOV @R0, A ;__Lib_System.c,19 :: 0x0048 0x08 INC R0 ;__Lib_System.c,20 :: 0x0049 0xA3 INC DPTR ;__Lib_System.c,21 :: 0x004A 0xD9F9 DJNZ R1, _CC2D_Loop1 ;__Lib_System.c,23 :: 0x004C 0x22 RET ; end of ___CC2D _main: 0x004D 0x758134 MOV SP, #52 0x0050 0x1200C5 LCALL 197 ;dec2bcd2ssd.c,7 :: void main() { ;dec2bcd2ssd.c,9 :: P0 = 0x00; 0x0053 0x758000 MOV P0, #0 ;dec2bcd2ssd.c,10 :: P1 = 0x00; 0x0056 0x759000 MOV P1, #0 ;dec2bcd2ssd.c,11 :: P2 = 0x03; 0x0059 0x75A003 MOV P2, #3 ;dec2bcd2ssd.c,12 :: P3 = 0x00; 0x005C 0x75B000 MOV P3, #0 ;dec2bcd2ssd.c,14 :: while(1) { L_main0: ;dec2bcd2ssd.c,16 :: if(!P2_0_bit) { 0x005F 0x20A016 JB P2_0_bit, L_main2 ;dec2bcd2ssd.c,17 :: Delay_ms(30); 0x0062 0x7E36 MOV R6, 54 0x0064 0x7FC9 MOV R7, 201 0x0066 0xDFFE DJNZ R7, PC-2 0x0068 0xDEFC DJNZ R6, PC-4 ;dec2bcd2ssd.c,18 :: while(!P2_0_bit); L_main3: 0x006A 0x20A002 JB P2_0_bit, L_main4 0x006D 0x80FB SJMP L_main3 L_main4: ;dec2bcd2ssd.c,19 :: if(counter < 99)++counter; 0x006F 0xC3 CLR C 0x0070 0xE533 MOV A, _counter 0x0072 0x9463 SUBB A, #99 0x0074 0x5002 JNC L_main5 0x0076 0x0533 INC _counter L_main5: ;dec2bcd2ssd.c,20 :: } L_main2: ;dec2bcd2ssd.c,22 :: if(!P2_1_bit) { 0x0078 0x20A116 JB P2_1_bit, L_main6 ;dec2bcd2ssd.c,23 :: Delay_ms(30); 0x007B 0x7E36 MOV R6, 54 0x007D 0x7FC9 MOV R7, 201 0x007F 0xDFFE DJNZ R7, PC-2 0x0081 0xDEFC DJNZ R6, PC-4 ;dec2bcd2ssd.c,24 :: while(!P2_1_bit); L_main7: 0x0083 0x20A102 JB P2_1_bit, L_main8 0x0086 0x80FB SJMP L_main7 L_main8: ;dec2bcd2ssd.c,25 :: if(counter > 0)--counter; 0x0088 0xD3 SETB C 0x0089 0xE533 MOV A, _counter 0x008B 0x9400 SUBB A, #0 0x008D 0x4002 JC L_main9 0x008F 0x1533 DEC _counter L_main9: ;dec2bcd2ssd.c,26 :: } L_main6: ;dec2bcd2ssd.c,28 :: bcd = Dec2Bcd(counter); 0x0091 0x853308 MOV FARG_Dec2Bcd_dec, _counter+0 0x0094 0x1126 ACALL _Dec2Bcd 0x0096 0x850032 MOV _bcd, 0 ;dec2bcd2ssd.c,29 :: bcdU = (bcd & 0x0F) << 4; 0x0099 0xE8 MOV A, R0 0x009A 0x540F ANL A, #15 0x009C 0xFA MOV R2, A 0x009D 0x7904 MOV R1, #4 0x009F 0xEA MOV A, R2 0x00A0 0x09 INC R1 0x00A1 0x8002 SJMP L__main12 L__main13: 0x00A3 0xC3 CLR C 0x00A4 0x33 RLC A L__main12: 0x00A5 0xD9FC DJNZ R1, L__main13 0x00A7 0xFB MOV R3, A 0x00A8 0x850331 MOV _bcdU, 3 ;dec2bcd2ssd.c,30 :: bcdL = bcd >> 4; 0x00AB 0x7A04 MOV R2, #4 0x00AD 0xE8 MOV A, R0 0x00AE 0x0A INC R2 0x00AF 0x8002 SJMP L__main14 L__main15: 0x00B1 0xC3 CLR C 0x00B2 0x13 RRC A L__main14: 0x00B3 0xDAFC DJNZ R2, L__main15 0x00B5 0xF9 MOV R1, A 0x00B6 0x850130 MOV _bcdL, 1 ;dec2bcd2ssd.c,31 :: P3 = bcdU | bcdL; 0x00B9 0xEB MOV A, R3 0x00BA 0x49 ORL A, R1 0x00BB 0xF5B0 MOV P3, A ;dec2bcd2ssd.c,32 :: } 0x00BD 0x015F AJMP L_main0 ;dec2bcd2ssd.c,33 :: } 0x00BF 0x80FE SJMP #254 ; end of _main 0x00C5 0x7830 MOV R0, 48 0x00C7 0x7904 MOV R1, 4 0x00C9 0x7582C1 MOV DP0L, 193 0x00CC 0x758300 MOV DP0H, 0 0x00CF 0x120045 LCALL 69 0x00D2 0x22 RET ;dec2bcd2ssd.c,0 :: ?ICS_bcdL 0x00C1 0x00 ;?ICS_bcdL+0 ; end of ?ICS_bcdL ;dec2bcd2ssd.c,0 :: ?ICS_bcdU 0x00C2 0x00 ;?ICS_bcdU+0 ; end of ?ICS_bcdU ;dec2bcd2ssd.c,0 :: ?ICS_bcd 0x00C3 0x00 ;?ICS_bcd+0 ; end of ?ICS_bcd ;dec2bcd2ssd.c,0 :: ?ICS_counter 0x00C4 0x00 ;?ICS_counter+0 ; end of ?ICS_counter Symbol List: //** Routines locations ** //ADDRESS SIZE PROCEDURE //---------------------------------------------- 0x0026 [31] _Dec2Bcd 0x0045 [8] ___CC2D 0x004D [116] _main //** Variables locations ** //ADDRESS SIZE VARIABLE //---------------------------------------------- 0x0000 [1] R0 0x0001 [1] R1 0x0002 [1] R2 0x0003 [1] R3 0x0004 [1] R4 0x0005 [1] R5 0x0006 [1] R6 0x0007 [1] R7 0x0008 [1] FARG_Dec2Bcd_dec 0x0030 [1] _bcdL 0x0031 [1] _bcdU 0x0032 [1] _bcd 0x0033 [1] _counter 0x0080 [1] P0 0x0081 [1] SP 0x0082 [1] DPL 0x0083 [1] DPH 0x0090 [1] P1 0x00A0 [1] P2 0x00A0 [0] P2_1_bit 0x00A0 [0] P2_0_bit 0x00B0 [1] P3 0x00D0 [1] PSW 0x00E0 [1] ACC 0x00F0 [1] B //** Constants locations ** //ADDRESS SIZE CONSTANT //---------------------------------------------- 0x00C1 [1] ?ICS_bcdL 0x00C2 [1] ?ICS_bcdU 0x00C3 [1] ?ICS_bcd 0x00C4 [1] ?ICS_counter //** Label List: ** //---------------------------------------------- L_main0 L_main1 L_main2 L_main3 L_main4 L_main5 L_main6 L_main7 L_main8 L_main9 _Dec2Bcd L__Dec2Bcd10 L__Dec2Bcd11 _main L__main12 L__main13 L__main14 L__main15 _CC2D_Loop1 _CC2PD_Loop1 _CC2XD_Loop1 ___DoIFC ___CC2D ___CC2PD ___CC2XD