AT90S2313-Odd-EvenCounter
This project shows the application of AT90S2313 as Odd - Even counter, which displays both odd and even numbers from 0-F.
This database contains 2 dot matrix display and an AT90S2313 Microcontroller.
The program is as shown:
_SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
.global __do_copy_data
.global __do_clear_bss
.text
.global main
.type main, @function
-------- Main Routine ----------------------------
main:
/* prologue: frame size=0 */
/* ldi r28,lo8(__stack - 0)
ldi r29,hi8(__stack - 0)
out __SP_H__,r29
out __SP_L__,r28
/* prologue end (size=4) */
LDI r24,0x01 ; loading R24 with 0x01
LDI r28,0x00 ; loading R28 with 0x00
LDI r30,0x01 ; loading R30 with 0x01
LDI r29,0xff ; loading R29 with 0xff
OUT 0x17,r29 ;setting up the DDRB register as output mode
loop1:
OUT 0x18,r24 ; outputting PORTB with the value on R24
SWAP r28 ; swapping the value at R28
ADIW r28,0x02 ; incrementing R28 by 2
ADIW r30,0x02 ; incrementing R30 by 2
CLZ ; clearing the zero flag of SREG
CPI r28,0x0f ; comparing the R28 value with 0x0f
BREQ main ; if equal then jump to ‘main’ routine
MOV r24,r30 ; moving the value at R30 to R24
ANDI r24,0x0f ;suppressing lower bit for R24
ANDI r28,0x0f ;suppressing lower bit for R28
SWAP r28 ; swapping the value at R28
ADD r24,r28 ; adding R28 with R24
RJMP loop1