Advertisement
Sumss

lab3v0.2

Dec 6th, 2018
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .org 0000
  2.     jmp START
  3.     .org INT0addr
  4.     jmp INT0_our
  5.     .org INT1addr
  6.     jmp INT1_OUR
  7.  
  8.     .def multi = r20
  9.  
  10.  
  11. START:
  12.     ldi r16,HIGH(RAMEND)
  13.     out SPH,r16
  14.     ldi r16,LOW(RAMEND)
  15.     out SPL,r16
  16.     call INIT
  17.     call RESET
  18.     call KLAR
  19.  
  20.  
  21. RESET:
  22.     clr multi
  23.     ldi ZH, high(TIME)
  24.     ldi ZL, LOW(TIME)
  25.     clr r16
  26.     st Z, r16
  27.     std Z+1, r16
  28.     std Z+2, r16
  29.     std Z+3, r16
  30.     ret
  31.  
  32. ;----------------------------------INTERRUPTS----------------------------------;
  33. INT0_OUR: ;klocka
  34.     ldi ZH, high(TIME)
  35.     ldi ZL, LOW(TIME)
  36.     ldi r17, $A
  37.     ldi r18, $6
  38.  
  39. LOOP:
  40.     ;Sec ental
  41.     ld r16, Z
  42.     subi r16, -1
  43.     cpse r16, r17
  44.     rjmp SAVE
  45.     clr r16
  46.     st Z+, r16
  47.  
  48.     ;Sec tiotal
  49.     ld r16, Z
  50.     subi r16, -1
  51.     cpse r16, r18
  52.     rjmp SAVE
  53.     clr r16
  54.     st Z+, r16
  55.  
  56.     ;Min ental
  57.     ld r16, Z
  58.     subi r16, -1
  59.     cpse r16, r17
  60.     rjmp SAVE
  61.     clr r16
  62.     st Z+, r16
  63.    
  64.     ;Min tiotal
  65.     ld r16, Z
  66.     subi r16, -1
  67.     cpse r16, r18
  68.     rjmp SAVE
  69.     clr r16
  70.     st Z+, r16
  71. SAVE:
  72.     st Z+, r16
  73.     reti
  74.  
  75.  
  76. INT1_OUR: ;lcd timer
  77.     out PORTB, multi
  78.     sbrc multi, 2
  79.     clr multi
  80.    
  81.     ;Visa siffran
  82.     ldi ZH, high(TIME)
  83.     ldi ZL, LOW(TIME)
  84.     add ZL, multi
  85.     ld r16, Z
  86.     ldi ZH, high(TABELL*2)
  87.     ldi ZL, LOW(TABELL*2)
  88.     add ZL, r16
  89.     lpm r16, Z
  90.     out PORTA, r16
  91.  
  92.     subi multi, -1
  93.     reti
  94.  
  95. ;----------------------------------HELP----------------------------------;
  96. INIT:
  97.     ldi r16,$FF ; 0111 1111
  98.     out DDRA,r16
  99.     ldi r16,$03
  100.     out DDRB,r16
  101.  
  102. ENABLE_INTERUPTION:
  103.     ldi r16,(1<<INT0)|(1<<INT1)
  104.     out GICR,r16
  105.     ldi r16, (1<<ISC01)|(1<<ISC00)|(1<<ISC11)|(1<<ISC10)
  106.     out MCUCR,r16
  107.     sei
  108.     ret
  109.  
  110. KLAR:
  111.     rjmp KLAR
  112.  
  113. ;----------------------------------DATA----------------------------------;
  114. .org 180
  115. TABELL: .db $FC,$60,$DA,$F2,$66,$B6,$BE,$E0,$FE,$F6
  116.  
  117.  
  118. .dseg TIME: .byte 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement