;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 2.9.0 #5416 (Mar 22 2009) (MINGW32) ; This file was generated Tue Nov 24 13:25:23 2015 ;-------------------------------------------------------- .module timer .optsdcc -mmcs51 --model-small ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- .globl _process_timer .globl _emulator .globl _SPR0 .globl _SPR1 .globl _CPHA .globl _CPOL .globl _SPIM .globl _SPE .globl _WCOL .globl _ISPI .globl _I2CI .globl _I2CTX .globl _I2CRS .globl _I2CM .globl _MDI .globl _MCO .globl _MDE .globl _MDO .globl _CS0 .globl _CS1 .globl _CS2 .globl _CS3 .globl _SCONV .globl _CCONV .globl _DMA .globl _ADCI .globl _P .globl _F1 .globl _OV .globl _RS0 .globl _RS1 .globl _F0 .globl _AC .globl _CY .globl _CAP2 .globl _CNT2 .globl _TR2 .globl _XEN .globl _TCLK .globl _RCLK .globl _EXF2 .globl _TF2 .globl _WDE .globl _WDS .globl _WDR2 .globl _WDR1 .globl _PRE0 .globl _PRE1 .globl _PRE2 .globl _PX0 .globl _PT0 .globl _PX1 .globl _PT1 .globl _PS .globl _PT2 .globl _PADC .globl _PSI .globl _RXD .globl _TXD .globl _INT0 .globl _INT1 .globl _T0 .globl _T1 .globl _WR .globl _RD .globl _EX0 .globl _ET0 .globl _EX1 .globl _ET1 .globl _ES .globl _ET2 .globl _EADC .globl _EA .globl _RI .globl _TI .globl _RB8 .globl _TB8 .globl _REN .globl _SM2 .globl _SM1 .globl _SM0 .globl _T2 .globl _T2EX .globl _IT0 .globl _IE0 .globl _IT1 .globl _IE1 .globl _TR0 .globl _TF0 .globl _TR1 .globl _TF1 .globl _DACCON .globl _DAC1H .globl _DAC1L .globl _DAC0H .globl _DAC0L .globl _SPICON .globl _SPIDAT .globl _ADCCON3 .globl _ADCGAINH .globl _ADCGAINL .globl _ADCOFSH .globl _ADCOFSL .globl _B .globl _ADCCON1 .globl _I2CCON .globl _ACC .globl _PSMCON .globl _ADCDATAH .globl _ADCDATAL .globl _ADCCON2 .globl _DMAP .globl _DMAH .globl _DMAL .globl _PSW .globl _TH2 .globl _TL2 .globl _RCAP2H .globl _RCAP2L .globl _T2CON .globl _EADRL .globl _WDCON .globl _EDATA4 .globl _EDATA3 .globl _EDATA2 .globl _EDATA1 .globl _ETIM3 .globl _ETIM2 .globl _ETIM1 .globl _ECON .globl _IP .globl _P3 .globl _IE2 .globl _IE .globl _P2 .globl _I2CADD .globl _I2CDAT .globl _SBUF .globl _SCON .globl _P1 .globl _TH1 .globl _TH0 .globl _TL1 .globl _TL0 .globl _TMOD .globl _TCON .globl _PCON .globl _DPP .globl _DPH .globl _DPL .globl _SP .globl _P0 .globl _pre_rand .globl _del .globl _threshold .globl _dif .globl _period .globl _low_add_volume .globl _medium_volume .globl _emulated_tank_volume .globl _init_value .globl _time .globl _tank_value .globl _get_tank_value .globl _get_current_millis .globl _get_time_interval .globl _sleep .globl _init_timer .globl _next_rand ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- .area RSEG (DATA) _P0 = 0x0080 _SP = 0x0081 _DPL = 0x0082 _DPH = 0x0083 _DPP = 0x0084 _PCON = 0x0087 _TCON = 0x0088 _TMOD = 0x0089 _TL0 = 0x008a _TL1 = 0x008b _TH0 = 0x008c _TH1 = 0x008d _P1 = 0x0090 _SCON = 0x0098 _SBUF = 0x0099 _I2CDAT = 0x009a _I2CADD = 0x009b _P2 = 0x00a0 _IE = 0x00a8 _IE2 = 0x00a9 _P3 = 0x00b0 _IP = 0x00b8 _ECON = 0x00b9 _ETIM1 = 0x00ba _ETIM2 = 0x00bb _ETIM3 = 0x00c4 _EDATA1 = 0x00bc _EDATA2 = 0x00bd _EDATA3 = 0x00be _EDATA4 = 0x00bf _WDCON = 0x00c0 _EADRL = 0x00c6 _T2CON = 0x00c8 _RCAP2L = 0x00ca _RCAP2H = 0x00cb _TL2 = 0x00cc _TH2 = 0x00cd _PSW = 0x00d0 _DMAL = 0x00d2 _DMAH = 0x00d3 _DMAP = 0x00d4 _ADCCON2 = 0x00d8 _ADCDATAL = 0x00d9 _ADCDATAH = 0x00da _PSMCON = 0x00df _ACC = 0x00e0 _I2CCON = 0x00e8 _ADCCON1 = 0x00ef _B = 0x00f0 _ADCOFSL = 0x00f1 _ADCOFSH = 0x00f2 _ADCGAINL = 0x00f3 _ADCGAINH = 0x00f4 _ADCCON3 = 0x00f5 _SPIDAT = 0x00f7 _SPICON = 0x00f8 _DAC0L = 0x00f9 _DAC0H = 0x00fa _DAC1L = 0x00fb _DAC1H = 0x00fc _DACCON = 0x00fd ;-------------------------------------------------------- ; special function bits ;-------------------------------------------------------- .area RSEG (DATA) _TF1 = 0x008f _TR1 = 0x008e _TF0 = 0x008d _TR0 = 0x008c _IE1 = 0x008b _IT1 = 0x008a _IE0 = 0x0089 _IT0 = 0x0088 _T2EX = 0x0091 _T2 = 0x0090 _SM0 = 0x009f _SM1 = 0x009e _SM2 = 0x009d _REN = 0x009c _TB8 = 0x009b _RB8 = 0x009a _TI = 0x0099 _RI = 0x0098 _EA = 0x00af _EADC = 0x00ae _ET2 = 0x00ad _ES = 0x00ac _ET1 = 0x00ab _EX1 = 0x00aa _ET0 = 0x00a9 _EX0 = 0x00a8 _RD = 0x00b7 _WR = 0x00b6 _T1 = 0x00b5 _T0 = 0x00b4 _INT1 = 0x00b3 _INT0 = 0x00b2 _TXD = 0x00b1 _RXD = 0x00b0 _PSI = 0x00bf _PADC = 0x00be _PT2 = 0x00bd _PS = 0x00bc _PT1 = 0x00bb _PX1 = 0x00ba _PT0 = 0x00b9 _PX0 = 0x00b8 _PRE2 = 0x00c7 _PRE1 = 0x00c6 _PRE0 = 0x00c5 _WDR1 = 0x00c3 _WDR2 = 0x00c2 _WDS = 0x00c1 _WDE = 0x00c0 _TF2 = 0x00cf _EXF2 = 0x00ce _RCLK = 0x00cd _TCLK = 0x00cc _XEN = 0x00cb _TR2 = 0x00ca _CNT2 = 0x00c9 _CAP2 = 0x00c8 _CY = 0x00d7 _AC = 0x00d6 _F0 = 0x00d5 _RS1 = 0x00d4 _RS0 = 0x00d3 _OV = 0x00d2 _F1 = 0x00d1 _P = 0x00d0 _ADCI = 0x00df _DMA = 0x00de _CCONV = 0x00dd _SCONV = 0x00dc _CS3 = 0x00db _CS2 = 0x00da _CS1 = 0x00d9 _CS0 = 0x00d8 _MDO = 0x00ef _MDE = 0x00ee _MCO = 0x00ed _MDI = 0x00ec _I2CM = 0x00eb _I2CRS = 0x00ea _I2CTX = 0x00e9 _I2CI = 0x00e8 _ISPI = 0x00ff _WCOL = 0x00fe _SPE = 0x00fd _SPIM = 0x00fc _CPOL = 0x00fb _CPHA = 0x00fa _SPR1 = 0x00f9 _SPR0 = 0x00f8 ;-------------------------------------------------------- ; overlayable register banks ;-------------------------------------------------------- .area REG_BANK_0 (REL,OVR,DATA) .ds 8 ;-------------------------------------------------------- ; overlayable bit register bank ;-------------------------------------------------------- .area BIT_BANK (REL,OVR,DATA) bits: .ds 1 b0 = bits[0] b1 = bits[1] b2 = bits[2] b3 = bits[3] b4 = bits[4] b5 = bits[5] b6 = bits[6] b7 = bits[7] ;-------------------------------------------------------- ; internal ram data ;-------------------------------------------------------- .area DSEG (DATA) _tank_value:: .ds 1 _time:: .ds 1 _init_value:: .ds 4 _emulated_tank_volume:: .ds 1 _medium_volume:: .ds 1 _low_add_volume:: .ds 1 _period:: .ds 1 _dif:: .ds 1 _threshold:: .ds 1 _del:: .ds 1 _pre_rand:: .ds 1 ;-------------------------------------------------------- ; overlayable items in internal ram ;-------------------------------------------------------- .area OSEG (OVR,DATA) ;-------------------------------------------------------- ; indirectly addressable internal ram data ;-------------------------------------------------------- .area ISEG (DATA) ;-------------------------------------------------------- ; absolute internal ram data ;-------------------------------------------------------- .area IABS (ABS,DATA) .area IABS (ABS,DATA) ;-------------------------------------------------------- ; bit data ;-------------------------------------------------------- .area BSEG (BIT) ;-------------------------------------------------------- ; paged external ram data ;-------------------------------------------------------- .area PSEG (PAG,XDATA) ;-------------------------------------------------------- ; external ram data ;-------------------------------------------------------- .area XSEG (XDATA) ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- .area XABS (ABS,XDATA) ;-------------------------------------------------------- ; external initialized ram data ;-------------------------------------------------------- .area XISEG (XDATA) .area HOME (CODE) .area GSINIT0 (CODE) .area GSINIT1 (CODE) .area GSINIT2 (CODE) .area GSINIT3 (CODE) .area GSINIT4 (CODE) .area GSINIT5 (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area CSEG (CODE) ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area HOME (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area GSINIT (CODE) ; SRC/timer.c:10: unsigned char emulated_tank_volume = 30; mov _emulated_tank_volume,#0x1E ; SRC/timer.c:11: unsigned char medium_volume = 30; mov _medium_volume,#0x1E ; SRC/timer.c:12: unsigned char low_add_volume = 20; mov _low_add_volume,#0x14 ; SRC/timer.c:13: unsigned char period = 50; mov _period,#0x32 ; SRC/timer.c:14: unsigned char dif = 3; mov _dif,#0x03 ; SRC/timer.c:15: unsigned char threshold = 4; mov _threshold,#0x04 ; SRC/timer.c:16: unsigned char del = 0; mov _del,#0x00 ; SRC/timer.c:91: unsigned char pre_rand = 17; mov _pre_rand,#0x11 ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area HOME (CODE) .area HOME (CODE) ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area CSEG (CODE) ;------------------------------------------------------------ ;Allocation info for local variables in function 'get_tank_value' ;------------------------------------------------------------ ;------------------------------------------------------------ ; SRC/timer.c:19: unsigned char get_tank_value() { ; ----------------------------------------- ; function get_tank_value ; ----------------------------------------- _get_tank_value: ar2 = 0x02 ar3 = 0x03 ar4 = 0x04 ar5 = 0x05 ar6 = 0x06 ar7 = 0x07 ar0 = 0x00 ar1 = 0x01 ; SRC/timer.c:20: return emulated_tank_volume; mov dpl,_emulated_tank_volume ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'emulator' ;------------------------------------------------------------ ;------------------------------------------------------------ ; SRC/timer.c:23: void emulator() ; ----------------------------------------- ; function emulator ; ----------------------------------------- _emulator: ; SRC/timer.c:27: if (time == 254) mov a,#0xFE cjne a,_time,00106$ ; SRC/timer.c:29: del++; inc _del ; SRC/timer.c:30: if (del == 10) mov a,#0x0A cjne a,_del,00106$ ; SRC/timer.c:32: del = 0; mov _del,#0x00 ; SRC/timer.c:33: if (emulated_tank_volume > 1) mov a,_emulated_tank_volume add a,#0xff - 0x01 jnc 00106$ ; SRC/timer.c:34: emulated_tank_volume = emulated_tank_volume - next_rand() % dif; lcall _next_rand mov a,dpl mov b,_dif div ab mov r2,b mov a,_emulated_tank_volume clr c subb a,r2 mov _emulated_tank_volume,a 00106$: ; SRC/timer.c:37: if (emulated_tank_volume < threshold) emulated_tank_volume = next_rand() % medium_volume + low_add_volume; clr c mov a,_emulated_tank_volume subb a,_threshold jnc 00109$ lcall _next_rand mov a,dpl mov b,_medium_volume div ab mov a,b add a,_low_add_volume mov _emulated_tank_volume,a 00109$: ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'process_timer' ;------------------------------------------------------------ ;------------------------------------------------------------ ; SRC/timer.c:40: void process_timer(void) interrupt 1 ; ----------------------------------------- ; function process_timer ; ----------------------------------------- _process_timer: push bits push acc push b push dpl push dph push (0+2) push (0+3) push (0+4) push (0+5) push (0+6) push (0+7) push (0+0) push (0+1) push psw mov psw,#0x00 ; SRC/timer.c:42: time++; inc _time ; SRC/timer.c:43: TH0 = (0xFF00 & init_value) >> 8; mov r3,(_init_value + 1) mov _TH0,r3 ; SRC/timer.c:44: TL0 = (0x00FF & init_value); mov r2,_init_value mov _TL0,r2 ; SRC/timer.c:45: emulator(); lcall _emulator pop psw pop (0+1) pop (0+0) pop (0+7) pop (0+6) pop (0+5) pop (0+4) pop (0+3) pop (0+2) pop dph pop dpl pop b pop acc pop bits reti ;------------------------------------------------------------ ;Allocation info for local variables in function 'get_current_millis' ;------------------------------------------------------------ ;temp Allocated to registers ;------------------------------------------------------------ ; SRC/timer.c:49: unsigned char get_current_millis(void) ; ----------------------------------------- ; function get_current_millis ; ----------------------------------------- _get_current_millis: ; SRC/timer.c:53: EA = 0; clr _EA ; SRC/timer.c:54: temp = time; mov dpl,_time ; SRC/timer.c:55: EA = 1; setb _EA ; SRC/timer.c:57: return temp; ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'get_time_interval' ;------------------------------------------------------------ ;t0 Allocated to registers r2 ;------------------------------------------------------------ ; SRC/timer.c:61: unsigned char get_time_interval(unsigned char t0) ; ----------------------------------------- ; function get_time_interval ; ----------------------------------------- _get_time_interval: mov r2,dpl ; SRC/timer.c:63: return get_current_millis() - t0; push ar2 lcall _get_current_millis mov r3,dpl pop ar2 mov a,r3 clr c subb a,r2 mov dpl,a ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'sleep' ;------------------------------------------------------------ ;delay Allocated to registers r2 ;startTime Allocated to registers r3 ;------------------------------------------------------------ ; SRC/timer.c:67: void sleep(unsigned char delay) ; ----------------------------------------- ; function sleep ; ----------------------------------------- _sleep: mov r2,dpl ; SRC/timer.c:69: unsigned char startTime = get_current_millis(); push ar2 lcall _get_current_millis mov r3,dpl pop ar2 ; SRC/timer.c:71: while (get_time_interval(startTime) < delay); 00101$: mov dpl,r3 push ar2 push ar3 lcall _get_time_interval mov r4,dpl pop ar3 pop ar2 clr c mov a,r4 subb a,r2 jc 00101$ ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'init_timer' ;------------------------------------------------------------ ;frequency Allocated to registers r2 r3 r4 r5 ;------------------------------------------------------------ ; SRC/timer.c:75: void init_timer(unsigned long frequency) ; ----------------------------------------- ; function init_timer ; ----------------------------------------- _init_timer: mov r2,dpl mov r3,dph mov r4,b mov r5,a ; SRC/timer.c:77: time = 0; mov _time,#0x00 ; SRC/timer.c:79: set_vector(0x200B, (void *) process_timer); mov r6,#_process_timer mov r7,#(_process_timer >> 8) mov r0,#0x80 push ar2 push ar3 push ar4 push ar5 push ar6 push ar7 push ar0 mov dptr,#0x200B lcall _set_vector dec sp dec sp dec sp ; SRC/timer.c:81: init_value = 65536 - (921600 / frequency); mov dptr,#0x1000 mov b,#0x0E clr a lcall __divulong mov r2,dpl mov r3,dph mov r4,b mov r5,a mov a,sp add a,#0xfc mov sp,a clr a clr c subb a,r2 mov _init_value,a clr a subb a,r3 mov (_init_value + 1),a mov a,#0x01 subb a,r4 mov (_init_value + 2),a clr a subb a,r5 mov (_init_value + 3),a ; SRC/timer.c:82: TH0 = (0xFF00 & init_value) >> 8; mov r3,(_init_value + 1) mov _TH0,r3 ; SRC/timer.c:83: TL0 = (0x00FF & init_value); mov r2,_init_value mov _TL0,r2 ; SRC/timer.c:86: TMOD |= 0x01; orl _TMOD,#0x01 ; SRC/timer.c:87: ET0 = 1; // Маска прерывания таймера 1 setb _ET0 ; SRC/timer.c:88: TR0 = 1; // Разрешаем таймеру 0 считать setb _TR0 ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'next_rand' ;------------------------------------------------------------ ;timerValue Allocated to registers r2 ;newRandom Allocated to registers r2 ;------------------------------------------------------------ ; SRC/timer.c:92: unsigned char next_rand(void) ; ----------------------------------------- ; function next_rand ; ----------------------------------------- _next_rand: ; SRC/timer.c:94: unsigned char timerValue = get_current_millis(); lcall _get_current_millis mov r2,dpl ; SRC/timer.c:95: unsigned char newRandom = (timerValue * pre_rand + timerValue) % 256; mov b,r2 mov a,_pre_rand mul ab mov r3,a mov r4,b mov r5,#0x00 mov a,r2 add a,r3 mov dpl,a mov a,r5 addc a,r4 mov dph,a clr a push acc mov a,#0x01 push acc lcall __modsint mov r2,dpl dec sp dec sp ; SRC/timer.c:96: pre_rand = newRandom; mov _pre_rand,r2 ; SRC/timer.c:97: return newRandom; mov dpl,r2 ret .area CSEG (CODE) .area CONST (CODE) .area XINIT (CODE) .area CABS (ABS,CODE)