Advertisement
Guest User

a4

a guest
Nov 28th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 100h
  2.         cpu 8086
  3.  
  4.         jmp start
  5.  
  6. ; Variablen
  7. alarm   db 'Alarm   '
  8. aus db 0
  9. status  db 0                    ; Statusbyte
  10.  
  11. ; Konstanten
  12. intab7  equ 3ch                 ; Adresse Interrupttabelle Lichttaster
  13. intab0  equ 20h                 ; Adresse Interrupttabelle Timerkanal 1
  14. eoi     equ 20h                 ; End of Interrupt
  15. clrscr  equ 0                   ; Clear Screen
  16. ascii   equ 2                   ; Funktion ASCIIZ-Stringausgabe
  17. getkey  equ 1                   ; Funktion auf Tastatureingabe warten
  18. conin   equ 5                   ; Console IN
  19. conout  equ 6                   ; Console OUT
  20. ppi_ctl equ 0b6h                ; Steuerkanal PPI (Parallelinterface)
  21. ppi_a   equ 0b0h                ; Kanal A PPI
  22. ppi_b   equ 0b2h                ; Kanal B PPI
  23. ppi_c   equ 0b4h                ; Kanal C PPI
  24. ocw_2_3 equ 0c0h                ; PIC (Interruptcontroller), OCW2,3
  25. ocw_1   equ 0c2h                ; PIC (Interruptcontroller), OCW1
  26. icw_1   equ 0c0h                ; PIC (Interruptcontroller), ICW1
  27. icw_2_4 equ 0c2h                ; PIC (Interruptcontroller), ICW2,4
  28. pitc    equ 0a6h                ; Steuerkanal PIT (Intervaltimer)
  29. pit1    equ 0a2h                ; Kanal 1 PIT
  30. pit2    equ 0a4h                ; Kanal 2 PIT
  31. leds    equ 0                   ; LED Port
  32. schalter        equ 0           ; Schalterport
  33. keybs   equ 80h                 ; SBC-86 Tastatur
  34. sseg7   equ 9eh                 ; Segmentanzeige 7
  35. tc      equ 0                   ; Zeitkonstante (1,8432 MHz Takt)
  36.  
  37. start:
  38.  
  39. ; Initialisierungen (Display, LED's, Alarm aus etc.) erfolgen hier
  40.  
  41.        mov ah,0
  42.        int 6
  43.        
  44.         mov al ,2
  45.        out pitc , al
  46.        
  47.        ;mov al, 250
  48.        ;out tc , al
  49.    
  50.  
  51.        call init               ; Initialisierung PIT (Kanal 1), PPI, PIC
  52.                                ; und Interruptsystem
  53.  
  54. ; Hintergrundprogramm
  55.  
  56. again:
  57.      
  58. ; Der hier einzufügende Programmcode wird immer dann ausgeführt, wenn
  59. ; die Interruptserviceroutinen nicht laufen (Hintergrundprogramm).
  60. ; Das wäre z.B. die Abfrage der Tastatur, die Manipulation der Statusbits und
  61. ; die Ausgabe an das Display und die LED's.
  62.  
  63.     mov ah, 1
  64.     int 5
  65.    
  66.     cmp al ,aus
  67.     JZ ritoo
  68.    
  69.         jmp again
  70.  
  71.  
  72. init:   cli                     ; Interrupts aus
  73.  
  74. ; PIT-Init.
  75.  
  76.         mov al, 01110110b       ; Kanal 1, Mode 3, 16-Bit ZK
  77.         out pitc, al            ; Steuerkanal
  78.         mov al, tc & 0ffh       ; Low-Teil Zeitkonstante
  79.         out pit1, al
  80.         mov al, tc >> 8         ; High-Teil Zeitkonstante
  81.         out pit1, al
  82.  
  83. ; PPI-Init.
  84.         mov al, 10001011b       ; PPI A/B/C Mode0, A Output, sonst Input
  85.         out ppi_ctl, al
  86.         jmp short $+2           ; I/O-Delay
  87.         mov al, 0               ; LED's aus (high aktiv)
  88.        out ppi_a, al
  89.      
  90. ; PIC-Init.
  91.        mov al, 00010011b       ; ICW1, ICW4 benötigt, Bit 2 egal,
  92.                                ; Flankentriggerung
  93.        out icw_1, al
  94.        jmp short $+2           ; I/O-Delay
  95.        mov al, 00001000b       ; ICW2, auf INT 8 gemapped
  96.        out icw_2_4, al
  97.        jmp short $+2           ; I/O-Delay
  98.        mov al, 00010001b       ; ICW4, MCS-86, EOI, non-buffered,
  99.                                ; fully nested
  100.        out icw_2_4, al
  101.        jmp short $+2           ; I/O-Delay
  102.        mov al, 01111110b       ; Kanal 0 + 7 am PIC demaskieren
  103.                                ; PIT K1 und Lichttaster
  104.        out ocw_1, al
  105.      
  106. ; Interrupttabelle init.      
  107.        mov word [intab7], isr_1        ; Interrupttabelle (Lichttaster)
  108.                                        ; initialisieren (Offset)
  109.        mov [intab7 + 2], cs            ; (Segmentadresse)
  110.        mov word [intab0], isr_2        ; Interrupttabelle (Timer)
  111.                                        ; initialisieren (Offset)
  112.        mov [intab0 + 2], cs            ; (Segmentadresse)
  113.      
  114.        sti                     ; ab jetzt Interrupts
  115.        ret
  116.  
  117. isr_1:  push ax
  118.  
  119. ; Interruptservice Reflexlichttaster:
  120. ; Hier ist z.B. der Programmcode einzufügen, um Statusbits zu manipulieren.
  121. ; Der gemeinsame Ausgang aus der ISR ist "isr1".
  122.  
  123.        mov ah,2
  124.        mov dl,7
  125.      
  126.        mov bx,alarm
  127.        int 6
  128.        mov al,1
  129.     mov [status], al
  130.        
  131.        
  132.      
  133. isr1:   mov al, eoi             ; EOI an PIC
  134.        out ocw_2_3, al         ; OCW
  135.        pop ax
  136.        iret
  137.  
  138. isr_2:  push ax
  139.        mov bx, -1              ; dieser Code macht fuer Sie möglicherweise
  140.        mov dx, bx              ; keinen Sinn, ist aber unbedingt an dieser
  141.                                ; Stelle zu belassen!
  142.  
  143. ; Interruptservice Timer Kanal 1:
  144. ; Hier ist z.B. der Programmcode einzufügen, um Statusbits abzufragen und
  145. ; den Lautsprecher anzusteuern. Ausgänge sind auch lesbar!
  146. ; Der gemeinsame Ausgang aus der ISR ist "isr2".
  147.     mov al,1
  148.     cmp [status] , al
  149.     JZ rito
  150.    
  151.  
  152.    
  153. isr2:   mov al, eoi             ; EOI an PIC
  154.        out ocw_2_3, al         ; OCW
  155.        pop ax
  156.        iret
  157.        
  158. rito:   in al, ppi_a
  159.     xor al ,9
  160.     out ppi_a,al
  161.     jmp isr2
  162.  
  163. ritoo:  mov al ,0
  164.     mov [status],al
  165.     mov ah,0
  166.        int 6
  167.     jmp again
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement