Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;Huvudprogram
- start
- org $1000
- lea $7000, A7
- jsr setuppia
- move.b #1, $4010
- move.b #3, $4011
- move.b #3, $4012
- move.b #7, $4013
- string
- move.w "Felaktig kod!\n\b", $4020
- clear
- clearinput
- jsr deactivatealarm
- waitkey
- jsr getkey
- cmp.b #10, d4
- bne waitkey
- jsr activatealarm
- jsr getkey
- isnumber
- cmp.b #15, d4
- bne tryunlock
- cmp.b #$09, d4
- bhi isnumber
- jsr addkey
- jmp isnumber
- unlock
- jsr checkcode
- tst.b d4
- bne falsecode
- jsr deactivatealarm
- jmp waitkey
- falsecode
- lea string, a4
- jsr printstring
- jmp waitkey
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Inargument: ASCII-kodat tecken i register d4
- ; Varning - Denna rutin gar inte att stega sig igenom med TRACE da den
- ; anvander serieporten pa ett satt som ar inkompatibelt med TRACE.
- printchar
- move.b d5,-(a7) ; Spara undan d5 (bit 7-0) pa stacken
- waittx
- move.b $10040,d5 ; Serieportens statusregister
- and.b #2,d5 ; Isolera bit 1 (Ready to transmit)
- beq waittx ; Vanta tills serieporten ar klar att sand
- move.b d4,$10042 ; Skicka ut
- move.b (a7)+,d5 ;Aterstall d5
- rts ;Tips: Satt en breakpoint har om du har problem med trace!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- setuppia
- move.b #0,$10084 ; Valj datariktningsregistret (DDRA)
- move.b #1,$10080 ; Satt pinne 0 pa PIAA som utgang
- move.b #4,$10084 ; Valj in/utgangsregistret
- move.b #0,$10086 ; Valj datariktningsregistret (DDRB)
- move.b #0,$10082 ; Satt alla pinnar som ingangar
- move.b #4,$10086 ; Valj in/utgangsregistret
- rts
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Inargument: Pekare till strangen i a4
- ; Langd pa strangen i d5
- printstring
- move.b (a4)+, d4
- jsr printchar
- sub.b #1,d5
- bne printstring
- rts
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Inargument: Inga
- ; Utargument: Inga
- ;
- ; Funktion: Slacker lysdioden kopplad till PIAA
- deactivatealarm
- move.b #0, $10080
- rts
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Inargument: Inga
- ; Utargument: Inga
- ;
- ; Funktion: Tander lysdioden kopplad till PIAA
- activatealarm
- move.b #1, $10080
- rts
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Inargument: Vald tangent i d4
- ; Utargument: Inga
- ;
- ; Funktion: Flyttar innehallet pa $4001-$4003 bakat en byte till
- ; $4000-$4002. Lagrar sedan innehallet i d4 pa adress $4003.
- addkey
- move.b $4001, $4000
- move.b $4002, $4001
- move.b $4003, $4002
- move.b d4, $4003
- rts
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Inargument: Inga
- ; Utargument: Inga
- ;
- ; Funktion: Satter innehallet pa $4000-$4003 till $FF
- clearinput
- move.b $FF, $4000
- move.b $FF, $4001
- move.b $FF, $4002
- move.b $FF, $4003
- rts
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; Inargument: Inga
- ; Utargument: Returnerar 1 i d4 om koden var korrekt, annars 0 i d4
- checkcode
- move.l $4000, d2
- move.l $4010, d3
- cmp.l d2, d3
- bne notequal
- move.b #1, d4
- rts
- notequal
- move.b #0, d4
- rts
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- getkey
- btst
- bne getkey
- move.w $10082, d4
- and.b #$1F,d4
- keyrelease
- btst
- beq keyrelease
- rts
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Add Comment
Please, Sign In to add comment