Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.08 KB | None | 0 0
  1. org 100h
  2. cpu 8086
  3.  
  4. jmp start
  5.  
  6. ; Variablen
  7. status db 00000000b ; Statusbyte
  8. ; xxxx x
  9. ; |||| |
  10. ; |||| +--------> Vereinzeler (1, auf) / (0, zu) bzw.
  11. ; |||| Verzoegerung aktiv
  12. ; ++++------------> Anzahl Teile binaer (8-0)
  13.  
  14. tcounts db 0 ; Impulszaehler fuer Servo, Vorwaertszaehler
  15. tcountv dw 100 * twait ; Impulszaehler fuer Verzoegerung * 10ms
  16. ; Rueckwaertszaehler
  17. frei db 'frei ', 0 ; Texte
  18. belegt db 'belegt ', 0
  19. clrscrn db ' ', 0
  20.  
  21. ; Konstanten
  22. servo_timer equ 0 ; Zeitkonstante für Servo
  23. vereinzeler_timer equ 0 ; Zeitkonstante für Vereinzeler
  24. VE_aktiv equ 1 << 0 ; Vereinzeler bzw. Verzoegerung aktiv
  25. intab0 equ 20h ; Adresse Interrupttabelle PIT, Kanal 1
  26. intab1 equ intab0 + 1 * 4 ; Adresse Interrupttabelle PIT, Kanal 2
  27. intab7 equ intab0 + 7 * 4 ; Adresse Interrupttabelle Lichttaster
  28. eoi equ 20h ; End Of Interrupt (EOI)
  29. clrscr equ 0 ; Clear Screen
  30. getkey equ 1 ; Funktion auf Tastatureingabe warten
  31. ascii equ 2 ; Funktion ASCII-Zeichenausgabe
  32. hexbyte equ 4 ; HEX-Byte Ausgabe
  33. conin equ 5 ; Console IN
  34. conout equ 6 ; Console OUT
  35. pitc equ 0a6h ; Steuerkanal PIT
  36. pit1 equ 0a2h ; Counter 1 PIT
  37. pit2 equ 0a4h ; Counter 2 PIT
  38. ppi_ctl equ 0b6h ; Steuerkanal PPI (Parallelinterface)
  39. ppi_a equ 0b0h ; Kanal A PPI
  40. ppi_pa0 equ 1 ; LED 0
  41. ppi_pa1 equ 2 ; LED 1
  42. ppi_pa2 equ 4 ; LED 2
  43. ppi_pa3 equ 8 ; Lautsprecher
  44. ppi_pa6 equ 1 << 6 ; Servomotor
  45. ppi_b equ 0b2h ; Kanal B PPI
  46. ppi_c equ 0b4h ; Kanal C PPI
  47. ocw_2_3 equ 0c0h ; PIC (Interruptcontroller), OCW2,3
  48. ocw_1 equ 0c2h ; PIC (Interruptcontroller), OCW1
  49. icw_1 equ 0c0h ; PIC (Interruptcontroller), ICW1
  50. icw_2_4 equ 0c2h ; PIC (Interruptcontroller), ICW2,4
  51. leds equ 0 ; LED Port
  52. schalter equ 0 ; Schalterport
  53. keybd equ 80h ; SBC-86 Tastatur
  54. gokey equ 11h ; Taste "GO"
  55. outkey equ 15h ; Taste "OUT"
  56. sseg7 equ 9eh ; Segmentanzeige 7
  57. tcpwm equ 184 ; 1843200 Hz / 184 = ca. 10000 Hz = 0.1 ms
  58. ; Taktzyklus
  59. ; Zeitkonstante fuer PWM-Interrupt
  60. tpwm equ 200 ; Periodendauer des PWM-Signals * 0.1 ms
  61. tlinks equ 10 ; Impulsdauer fuer "ZU" * 0.1 ms
  62. trechts equ 20 ; Impulsdauer fuer "AUF" * 0.1 ms
  63. tcwait equ 18432 ; 1843200 Hz / 18432 = 100 Hz => 10 ms
  64. ; Zeitkonstante fuer Wartezeitinterrupt
  65. twait equ 1 ; Wartezeit fuer offenen Vereinzeler (s)
  66. shcnt equ 4 ; Shiftcount Anzahl Teile
  67. pieces equ 8 ; Anzahl Teile initial
  68.  
  69. start:
  70.  
  71. ; Initialisierung
  72.  
  73. call init ; Controller und Interruptsystem scharfmachen
  74.  
  75. mov ah, clrscr ; Anzeige aus
  76. int conout
  77.  
  78. mov byte [status], pieces << shcnt ; Init. Statusbyte und alle LEDs
  79. mov al, 0
  80. out ppi_a, al
  81. out leds, al
  82.  
  83. ; Hintergrundprogramm (ist immer aktiv, wenn im Service nichts zu tun ist)
  84. ; Hier sollten Ausgaben auf das Display getätigt werden, Zählung der Teile, etc.
  85.  
  86. again:
  87.  
  88. ; Ihr Programmcode...
  89.  
  90. mov ah, 2
  91. mov bx, clrscrn
  92. mov dl, 7
  93. int 6
  94. mov al, 0
  95. out schalter, al
  96.  
  97. mov al, [status]
  98. cmp al, 0
  99. je voll
  100.  
  101. struff:
  102. mov ah, 4h
  103. mov bx, [status]
  104. mov dl, 1h
  105. int 6
  106. mov ah, 2
  107. mov bx, frei
  108. mov dl, 7
  109. int 6
  110. mov al, [status]
  111. cmp al, 0
  112. je voll
  113. jmp struff
  114.  
  115. voll:
  116. mov ah, 2
  117. mov bx, clrscrn
  118. mov dl, 7
  119. int 6
  120.  
  121. mov ah, 2
  122. mov bx, belegt
  123. mov dl, 7
  124. int 6
  125.  
  126. jmp again
  127.  
  128. ; Initialisierung Controller und Interruptsystem
  129.  
  130. init:
  131. cli ; Interrupts aus
  132.  
  133. ; PIT-Init.
  134.  
  135. mov al, 01110110b ; Kanal 1, Mode 3, 16-Bit ZK
  136. out pitc, al ; Steuerkanal
  137. mov al, tcpwm & 0ffh ; Low-Teil Zeitkonstante
  138. out pit1, al
  139. mov al, tcpwm >> 8 ; High-Teil Zeitkonstante
  140. out pit1, al
  141.  
  142. mov al, 10110110b ; Kanal 2, Mode 3, 16-Bit ZK
  143. out pitc, al ; Steuerkanal
  144. mov al, tcwait & 0ffh ; Low-Teil Zeitkonstante
  145. out pit2, al
  146. mov al, tcwait >> 8 ; High-Teil Zeitkonstante
  147. out pit2, al
  148.  
  149.  
  150. ; PPI-Init.
  151. mov al, 10001011b ; PPI A/B/C Mode 0, A Output, sonst Input
  152. out ppi_ctl, al
  153. jmp short $+2 ; I/O-Delay
  154. mov al, 0 ; LED's aus (high aktiv)
  155. out ppi_a, al
  156.  
  157. ; PIC-Init.
  158. mov al, 00010011b ; ICW1, ICW4 benoetigt, Bit 2 egal,
  159. ; Flankentriggerung
  160. out icw_1, al
  161. jmp short $+2 ; I/O-Delay
  162. mov al, 00001000b ; ICW2, auf INT 8 gemapped
  163. out icw_2_4, al
  164. jmp short $+2 ; I/O-Delay
  165. mov al, 00010001b ; ICW4, MCS-86, EOI, non-buffered,
  166. ; fully nested
  167. out icw_2_4, al
  168. jmp short $+2 ; I/O-Delay
  169. mov al, 01111100b ; Kanal 0, 1 + 7 am PIC demaskieren
  170. ; PIT K1, K2 und Lichttaster
  171. out ocw_1, al
  172.  
  173. ; Interrupttabelle init.
  174. mov word [intab7], isr_lt ; Interrupttabelle (Lichttaster)
  175. ; initialisieren (Offset)
  176. mov [intab7 + 2], cs ; (Segmentadresse)
  177.  
  178. mov word [intab0], isr_servotimer ; Interrupttabelle (Timer K1)
  179. ; initialisieren (Offset)
  180. mov [intab0 + 2], cs ; (Segmentadresse)
  181.  
  182. mov word [intab1], isr_opentimer ; Interrupttabelle (Timer K2)
  183. ; initialisieren (Offset)
  184. mov [intab1 + 2], cs ; (Segmentadresse)
  185.  
  186. sti ; ab jetzt Interrupts
  187. ret
  188.  
  189. ;------------------------ Serviceroutinen -----------------------------------
  190.  
  191. isr_opentimer: ; Timer fuer Vereinzeler (Zeit fuer Oeffnung)
  192. push ax
  193. ; Ihr Programmcode
  194.  
  195. isr_opentimer_out: ; Ausgang aus dem Service
  196. mov al, eoi ; EOI an PIC
  197. out ocw_2_3, al
  198. pop ax
  199. iret
  200.  
  201. isr_lt: ; Lichttaster
  202. push ax
  203. ; Ihr Programmcode
  204. mov al, byte [status] ; Einlesung Statusbyte
  205. times 4 shr al,1 ;2^7 bis 2^4 nibble nach rechts schieben zu 2^3 bis 2^0
  206. dec al
  207.  
  208. cmp al, 0
  209. jge noch_nicht_null
  210.  
  211. mov al, 00001000b
  212. times 4 shl al,1 ;2^3 bis 2^0 nibble nach links schieben zu 2^7 bis 2^4
  213. out leds, al
  214. jmp isr_lt_out
  215.  
  216. noch_nicht_null: ;
  217. times 4 shl al,1 ;2^3 bis 2^0 nibble nach links schieben zu 2^7 bis 2^4
  218. mov ah, byte [status] ;unteres nibble des status bytes sichern
  219. and ah, 0x0F
  220. or al, ah
  221. out leds, al
  222.  
  223.  
  224. isr_lt_out: ; Ausgang aus dem Service
  225. mov [status], al
  226. mov al, eoi ; EOI an PIC
  227. out ocw_2_3, al
  228. pop ax
  229. iret
  230.  
  231. isr_servotimer: ; Timer fuer Servo (Vereinzeler)
  232. push ax
  233. ; Ihr Programmcode
  234.  
  235. isr_servotimer_out: ; Ausgang aus dem Service
  236. mov al, eoi ; EOI an PIC
  237. out ocw_2_3, al
  238. pop ax
  239. iret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement