timer1.asm
1 ; Test program to verify correct emu8051 operation 2 ; 3 ; Test desc: timers 4 ; Test output: PC = $FFF0 5 ; Test output: SP = $60 6 ; Test output: R0 = $22 7 ; Test output: R1 = $97 8 ; Test output: R2 = $20 9 ; Test output: R3 = $42 10 ; Test output: TIMER0 = $10DA 11 ; Test output: TIMER1 = $1F42 12 ; Test output: TCON = $A0 13 ; Test output: TMOD = $11 14 ; Test output: PSW = $00 15 16 TOS EQU 60h ; Adresse du dessus de la pile. 17 18 ORG 0000h ; Reset vector 19 MOV SP,#TOS ; Init stack pointer 20 21 MOV TMOD,#00010001B ; Init timers 0 and 1 as 16-bit timers, 22 ; incremented by the internal clock 23 24 ;; First test: no overflow 25 MOV TH0,#2 26 MOV TL0,#55h ; Set initial value of timer0 to $0255 27 LCALL DELAY 28 29 MOV 00h, TH0 ; Save value of timer 0 30 MOV 01h, TL0 31 MOV 02h, TH1 ; Save value of timer 1 32 MOV 03h, TL1 33 MOV 04h, TCON 34 35 ;; Second test: overflow 36 MOV TH0,#0F0h 37 MOV TL0,#98h ; Set initial value of timer0 to $F098 38 MOV Th1,#0FFh 39 MOV TL1,#00h ; Set initial value of timer1 to $FF00 40 LCALL DELAY 41 42 LJMP 0FFF0h 43 44 ;; Loop of $2040 cycles 45 DELAY: 46 MOV A,#10h 47 ORL TCON,#50h ; Timer 0 and timer 1 ON. 48 B2: 49 MOV B,#0 50 B1: 51 DJNZ B,B1 52 DJNZ ACC,B2 53 ANL TCON,#0AFh ; Stop both timers 54 RET 55 56 END