Code:
;Würfel mit 7seg Anzeige;
.include "C:\Dokumente und Einstellungen\eric\Desktop\asm\2313def.inc"
.equ dp=3
.def temp=r16
.def zahl=r17
.def counter=r18
.macro einsaus ;Segmente abhängig von der Platine;
ldi temp, 0b01000001
out PORTB, temp
.endmacro
.macro zweiaus
ldi temp, 0b10110011
out PORTB, temp
.endmacro
.macro dreiaus
ldi temp, 0b10110110
out PORTB, temp
.endmacro
.macro vieraus
ldi temp, 0b11010100
out PORTB, temp
.endmacro
.macro fuenfaus
ldi temp, 0b11100110
out PORTB, temp
.endmacro
.macro sechsaus
ldi temp, 0b11100111
out PORTB, temp
.endmacro
.cseg
.org 0x000
rjmp reset
rjmp int
reset: ldi temp, ramend
out SPL, temp
ldi temp, 0b01000000 ;externer interrupt an int0 wenn int0 auf low liegt(pull up an int0);
out GIMSK, temp
ldi temp, 0b00000000
out MCUCR, temp
sbi PORTB, dp
sei
main: ldi temp, 0x05
dec: nop ;zählschleife;
nop
nop
sbi PORTB, dp ;dp zeigt nacher an ob der Würfelvorgang abgeschlossen ist;
nop
nop
dec temp
breq main
rjmp dec
int: mov zahl, temp ;ermitteln der zahl die in temp war als der Interrupt ausgelöst würde;
ldi temp, 0x00
cpse temp, zahl
rjmp inta
rjmp eins
inta: ldi temp, 0x01
cpse temp, zahl
rjmp intb
rjmp zwei
intb: ldi temp, 0x02
cpse temp, zahl
rjmp intc
rjmp drei
intc: ldi temp, 0x03
cpse temp, zahl
rjmp intd
rjmp vier
intd: ldi temp, 0x04
cpse temp, zahl
rjmp inte
rjmp fuenf
inte: rjmp sechs
eins: einsaus ;durchzählen der 7seg Anzeige für die Optik :) ;
ldi counter, 0x00 ;counter für die Warteschleife null setzen;
rcall warte
zweiaus
rcall warte
dreiaus
rcall warte
vieraus
rcall warte
fuenfaus
rcall warte
sechsaus
rcall warte
einsaus
rcall warte
zweiaus
rjmp entp
zwei: zweiaus
ldi counter, 0x00
rcall warte
dreiaus
rcall warte
vieraus
rcall warte
fuenfaus
rcall warte
sechsaus
rcall warte
einsaus
rcall warte
zweiaus
rcall warte
dreiaus
rjmp entp
drei: dreiaus
ldi counter, 0x00
rcall warte
vieraus
rcall warte
fuenfaus
rcall warte
sechsaus
rcall warte
einsaus
rcall warte
zweiaus
rcall warte
dreiaus
rcall warte
vieraus
rjmp entp
vier: vieraus
ldi counter, 0x00
rcall warte
fuenfaus
rcall warte
sechsaus
rcall warte
einsaus
rcall warte
zweiaus
rcall warte
dreiaus
rcall warte
vieraus
rcall warte
fuenfaus
rjmp entp
fuenf: fuenfaus
ldi counter, 0x00
rcall warte
sechsaus
rcall warte
einsaus
rcall warte
zweiaus
rcall warte
dreiaus
rcall warte
vieraus
rcall warte
fuenfaus
rcall warte
sechsaus
rjmp entp
sechs: sechsaus
ldi counter, 0x00
rcall warte
einsaus
rcall warte
zweiaus
rcall warte
dreiaus
rcall warte
vieraus
rcall warte
fuenfaus
rcall warte
sechsaus
rcall warte
einsaus
rjmp entp
warte: inc counter ;Warteschleife abhängig von der Anzahl der Durchgänge (5Mhz Quarz);
inc counter
mov temp, counter
zaehl3: ldi r19, 0x01
zaehl2: clr r1
zaehl1: clr r0
zaehl0: dec r0
brne zaehl0
dec r1
brne zaehl1
dec r19
brne zaehl2
dec temp
brne zaehl3
ret
entp: in temp, pind ;überprüfen ob schalter noch gedrückt;
ldi r20, 0x04
cpse temp, r20
rjmp entp
ldi temp, 0x03
reti
Das Layout von meiner Schaltung hab ich auch noch, wenns einer will ^^
Lesezeichen