Sebgg

tsea82lab1

Sep 13th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;Huvudprogram
  3. start
  4. org $1000
  5. lea $7000, A7
  6. jsr setuppia
  7. move.b #1, $4010
  8. move.b #3, $4011
  9. move.b #3, $4012
  10. move.b #7, $4013
  11. string
  12. move.w "Felaktig kod!\n\b", $4020
  13. clear
  14. clearinput
  15. jsr deactivatealarm
  16. waitkey
  17. jsr getkey
  18. cmp.b #10, d4
  19. bne waitkey
  20. jsr activatealarm
  21. jsr getkey
  22. isnumber
  23. cmp.b #15, d4
  24. bne tryunlock
  25. cmp.b #$09, d4
  26. bhi isnumber
  27. jsr addkey
  28. jmp isnumber
  29. unlock
  30. jsr checkcode
  31. tst.b d4
  32. bne falsecode
  33. jsr deactivatealarm
  34. jmp waitkey
  35.  
  36. falsecode
  37. lea string, a4
  38. jsr printstring
  39. jmp waitkey
  40. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  41.  
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. ; Inargument: ASCII-kodat tecken i register d4
  44. ; Varning - Denna rutin gar inte att stega sig igenom med TRACE da den
  45. ; anvander serieporten pa ett satt som ar inkompatibelt med TRACE.
  46. printchar
  47. move.b d5,-(a7) ; Spara undan d5 (bit 7-0) pa stacken
  48. waittx
  49. move.b $10040,d5 ; Serieportens statusregister
  50. and.b #2,d5 ; Isolera bit 1 (Ready to transmit)
  51. beq waittx ; Vanta tills serieporten ar klar att sand
  52. move.b d4,$10042 ; Skicka ut
  53. move.b (a7)+,d5 ;Aterstall d5
  54. rts ;Tips: Satt en breakpoint har om du har problem med trace!
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56.  
  57. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  58. setuppia
  59. move.b #0,$10084 ; Valj datariktningsregistret (DDRA)
  60. move.b #1,$10080 ; Satt pinne 0 pa PIAA som utgang
  61. move.b #4,$10084 ; Valj in/utgangsregistret
  62. move.b #0,$10086 ; Valj datariktningsregistret (DDRB)
  63. move.b #0,$10082 ; Satt alla pinnar som ingangar
  64. move.b #4,$10086 ; Valj in/utgangsregistret
  65. rts
  66. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  67.  
  68. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  69. ; Inargument: Pekare till strangen i a4
  70. ; Langd pa strangen i d5
  71. printstring
  72. move.b (a4)+, d4
  73. jsr printchar
  74. sub.b #1,d5
  75. bne printstring
  76. rts
  77. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  78.  
  79. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  80. ; Inargument: Inga
  81. ; Utargument: Inga
  82. ;
  83. ; Funktion: Slacker lysdioden kopplad till PIAA
  84. deactivatealarm
  85. move.b #0, $10080
  86. rts
  87. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  88.  
  89. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  90. ; Inargument: Inga
  91. ; Utargument: Inga
  92. ;
  93. ; Funktion: Tander lysdioden kopplad till PIAA
  94. activatealarm
  95. move.b #1, $10080
  96. rts
  97. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  98.  
  99. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  100. ; Inargument: Vald tangent i d4
  101. ; Utargument: Inga
  102. ;
  103. ; Funktion: Flyttar innehallet pa $4001-$4003 bakat en byte till
  104. ; $4000-$4002. Lagrar sedan innehallet i d4 pa adress $4003.
  105. addkey
  106. move.b $4001, $4000
  107. move.b $4002, $4001
  108. move.b $4003, $4002
  109. move.b d4, $4003
  110. rts
  111. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  112.  
  113. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  114. ; Inargument: Inga
  115. ; Utargument: Inga
  116. ;
  117. ; Funktion: Satter innehallet pa $4000-$4003 till $FF
  118. clearinput
  119. move.b $FF, $4000
  120. move.b $FF, $4001
  121. move.b $FF, $4002
  122. move.b $FF, $4003
  123. rts
  124. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  125.  
  126. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  127. ; Inargument: Inga
  128. ; Utargument: Returnerar 1 i d4 om koden var korrekt, annars 0 i d4
  129. checkcode
  130. move.l $4000, d2
  131. move.l $4010, d3
  132. cmp.l d2, d3
  133. bne notequal
  134. move.b #1, d4
  135. rts
  136. notequal
  137. move.b #0, d4
  138. rts
  139.  
  140. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  141.  
  142. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  143. getkey
  144. btst
  145. bne getkey
  146. move.w $10082, d4
  147. and.b #$1F,d4
  148. keyrelease
  149. btst
  150. beq keyrelease
  151. rts
  152. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Add Comment
Please, Sign In to add comment