***Listing 1 for di2362: Frequency Multiplier code*** .include "1200def.inc" .device AT90S1200 .def cnt =r16 ; .def temp_1 =r17 ; .def temp_2 =r18 ; .def temp_3 =r19 ; .def temp_4 =r20 ; .def temp_5 =r21 ; .def temp_6 =r22 ; .def number =r23 ; .def pulse =r24 ; .def delay_1 =r25 ; .def delay_2 =r26 ; .def cnt_1 =r27 ; .def cnt_2 =r28 ; ; reset: ; rjmp init ; int: ; in temp_4, PINB ; read input andi temp_4, $07 ; mov temp_5, temp_4; mov temp_6, temp_4; lsl temp_5 ; lsr temp_6 ; ldi temp_2, $0 ; cp number, temp_4; brne next_1 ; ldi temp_2, $1 ; next_1: ; dec temp_2 ; breq next_2 ; out PORTD, pulse ; inc pulse ; next_2: ; cp number, temp_4; brlo dec_cnt ; cp number, temp_5; brlo inc_cnt ; sec ; rol cnt_1 ; rol cnt_2 ; brcc int_out ; cnt_overflow: ; ldi cnt_1, $ff ; ldi cnt_2, $ff ; rjmp int_out ; inc_cnt: ; add cnt_2, temp_3; breq inc_1 ; add cnt_1, cnt_2 ; brcc inc_1 ; inc cnt_2 ; breq cnt_overflow ; inc_1: ; inc cnt_1 ; brne int_out ; inc cnt_2 ; breq cnt_overflow ; rjmp int_out ; dec_cnt: ; cp number, temp_6; brlo half_cnt ; add cnt_2, temp_3; breq dec_1 ; sub cnt_1, cnt_2 ; brcc dec_1 ; subi cnt_2, $1 ; brcs cnt_underflow ; dec_1: ; subi cnt_1, $1 ; brcc int_out ; subi cnt_2, $1 ; brcc int_out ; cnt_underflow: ; ldi cnt_1, $1 ; ldi cnt_2, $0 ; int_out: ; ldi number, $0 ; rjmp loop_1 ; half_cnt: ; clc ; ror cnt_2 ; ror cnt_1 ; rjmp int_out ; init: ; ser temp_1 ; out PORTB, temp_1; out PORTD, temp_1; ldi temp_1, $0 ; out DDRB, temp_1; ldi temp_1, $1 ; out DDRD, temp_1; ldi delay_1, $ff ; ldi delay_2, $ff ; ldi temp_1, $40 ; out GIMSK, temp_1; ldi temp_1, $3 ; out MCUCR, temp_1; ldi pulse, $0 ; ldi number, $0 ; ldi temp_3, $0 ; in temp_4, PINB ; andi temp_4, $07 ; mov temp_5, temp_4; mov temp_6, temp_4; lsl temp_5 ; lsr temp_6 ; ; loop_1: ; endless loop sei ; mov delay_1, cnt_1 ; mov delay_2, cnt_2 ; loop_2: ; delay loop subi delay_1, $1 ; brcc loop_2 ; subi delay_2, $1 ; brcc loop_2 ; cli ; out PORTD, pulse ; send output inc pulse ; sbrs pulse, $0 ; inc number ; rjmp loop_1 ;