test version
This commit is contained in:
parent
bcef249f6a
commit
3cc43f71d0
243
src/asm/a4_bla.asm
Normal file
243
src/asm/a4_bla.asm
Normal file
@ -0,0 +1,243 @@
|
||||
|
||||
|
||||
org 100h
|
||||
cpu 8086
|
||||
|
||||
jmp start
|
||||
|
||||
; Variablen
|
||||
status db 00000000b ; Statusbyte
|
||||
; xxxx x
|
||||
; |||| |
|
||||
; |||| +--------> Vereinzeler (1, auf) / (0, zu) bzw.
|
||||
; |||| Verzoegerung aktiv
|
||||
; ++++------------> Anzahl Teile binaer (8-0)
|
||||
|
||||
statusAlt db 0
|
||||
takt db 0
|
||||
|
||||
tcounts db 0 ; Impulszaehler fuer Servo, Vorwaertszaehler
|
||||
tcounto db 0
|
||||
tcountv dw 100 * twait ; Impulszaehler fuer Verzoegerung * 10ms
|
||||
; Rueckwaertszaehler
|
||||
direction db 20
|
||||
frei db 'frei ', 0 ; Texte
|
||||
belegt db 'belegt ', 0
|
||||
|
||||
; Konstanten
|
||||
??? equ 0 ; Platzhalter fuer Ihre Zeitkonstante1
|
||||
????? equ 0 ; Platzhalter fuer Ihre Zeitkonstante2
|
||||
VE_aktiv equ 1 << 0 ; Vereinzeler bzw. Verzoegerung aktiv
|
||||
intab0 equ 20h ; Adresse Interrupttabelle PIT, Kanal 1
|
||||
intab1 equ intab0 + 1 * 4 ; Adresse Interrupttabelle PIT, Kanal 2
|
||||
intab7 equ intab0 + 7 * 4 ; Adresse Interrupttabelle Lichttaster
|
||||
eoi equ 20h ; End Of Interrupt (EOI)
|
||||
clrscr equ 0 ; Clear Screen
|
||||
getkey equ 1 ; Funktion auf Tastatureingabe warten
|
||||
ascii equ 2 ; Funktion ASCII-Zeichenausgabe
|
||||
hexbyte equ 4 ; HEX-Byte Ausgabe
|
||||
conin equ 5 ; Console IN
|
||||
conout equ 6 ; Console OUT
|
||||
pitc equ 0a6h ; Steuerkanal PIT
|
||||
pit1 equ 0a2h ; Counter 1 PIT
|
||||
pit2 equ 0a4h ; Counter 2 PIT
|
||||
ppi_ctl equ 0b6h ; Steuerkanal PPI (Parallelinterface)
|
||||
ppi_a equ 0b0h ; Kanal A PPI
|
||||
ppi_pa0 equ 1 ; LED 0
|
||||
ppi_pa1 equ 2 ; LED 1
|
||||
ppi_pa2 equ 4 ; LED 2
|
||||
ppi_pa3 equ 8 ; Lautsprecher
|
||||
ppi_pa6 equ 1 << 6 ; Servomotor
|
||||
ppi_b equ 0b2h ; Kanal B PPI
|
||||
ppi_c equ 0b4h ; Kanal C PPI
|
||||
ocw_2_3 equ 0c0h ; PIC (Interruptcontroller), OCW2,3
|
||||
ocw_1 equ 0c2h ; PIC (Interruptcontroller), OCW1
|
||||
icw_1 equ 0c0h ; PIC (Interruptcontroller), ICW1
|
||||
icw_2_4 equ 0c2h ; PIC (Interruptcontroller), ICW2,4
|
||||
leds equ 0 ; LED Port
|
||||
schalter equ 0 ; Schalterport
|
||||
keybd equ 80h ; SBC-86 Tastatur
|
||||
gokey equ 11h ; Taste "GO"
|
||||
outkey equ 15h ; Taste "OUT"
|
||||
sseg7 equ 9eh ; Segmentanzeige 7
|
||||
tcpwm equ 184 ; 1843200 Hz / ??? = ca. 10000 Hz = 0.1 ms
|
||||
; Taktzyklus
|
||||
; Zeitkonstante fuer PWM-Interrupt
|
||||
tpwm equ 200 ; Periodendauer des PWM-Signals * 0.1 ms
|
||||
tlinks equ 10 ; Impulsdauer fuer "ZU" * 0.1 ms
|
||||
trechts equ 20 ; Impulsdauer fuer "AUF" * 0.1 ms
|
||||
tcwait equ 18432 ; 1843200 Hz / ????? = 100 Hz => 10 ms
|
||||
; Zeitkonstante fuer Wartezeitinterrupt
|
||||
twait equ 1 ; Wartezeit fuer offenen Vereinzeler (s)
|
||||
shcnt equ 4 ; Shiftcount Anzahl Teile
|
||||
pieces equ 8 ; Anzahl Teile initial
|
||||
|
||||
start:
|
||||
|
||||
; Initialisierung
|
||||
|
||||
call init ; Controller und Interruptsystem scharfmachen
|
||||
|
||||
mov ah, clrscr ; Anzeige aus
|
||||
int conout
|
||||
|
||||
mov byte [status], pieces << shcnt ; Init. Statusbyte und alle LEDs
|
||||
mov al, 0
|
||||
out ppi_a, al
|
||||
out leds, al
|
||||
|
||||
; Hintergrundprogramm (ist immer aktiv, wenn im Service nichts zu tun ist)
|
||||
; Hier sollten Ausgaben auf das Display getätigt werden, Zählung der Teile, etc.
|
||||
|
||||
again:
|
||||
|
||||
mov ah, 02
|
||||
mov dl, 07
|
||||
mov al, [status]
|
||||
add al, 0x10
|
||||
jc VOLL
|
||||
mov bx, frei
|
||||
jmp AUS
|
||||
|
||||
VOLL: mov bx, belegt
|
||||
|
||||
AUS: INT 6
|
||||
mov al, [status]
|
||||
out leds, al
|
||||
jmp again
|
||||
; Initialisierung Controller und Interruptsystem
|
||||
|
||||
|
||||
|
||||
init:
|
||||
cli ; Interrupts aus
|
||||
|
||||
; PIT-Init.
|
||||
|
||||
mov al, 01110110b ; Kanal 1, Mode 3, 16-Bit ZK
|
||||
out pitc, al ; Steuerkanal
|
||||
mov al, tcpwm & 0ffh ; Low-Teil Zeitkonstante
|
||||
out pit1, al
|
||||
mov al, tcpwm >> 8 ; High-Teil Zeitkonstante
|
||||
out pit1, al
|
||||
mov al, 10110110b ; Kanal 2, Mode 3, 16-Bit ZK
|
||||
out pitc, al ; Steuerkanal
|
||||
mov al, tcwait & 0ffh ; Low-Teil Zeitkonstante
|
||||
out pit2, al
|
||||
mov al, tcwait >> 8 ; High-Teil Zeitkonstante
|
||||
out pit2, al
|
||||
|
||||
|
||||
; PPI-Init.
|
||||
mov al, 10001011b ; PPI A/B/C Mode 0, A Output, sonst Input
|
||||
out ppi_ctl, al
|
||||
jmp short $+2 ; I/O-Delay
|
||||
mov al, 0 ; LED's aus (high aktiv)
|
||||
out ppi_a, al
|
||||
|
||||
; PIC-Init.
|
||||
mov al, 00010011b ; ICW1, ICW4 benoetigt, Bit 2 egal,
|
||||
; Flankentriggerung
|
||||
out icw_1, al
|
||||
jmp short $+2 ; I/O-Delay
|
||||
mov al, 00001000b ; ICW2, auf INT 8 gemapped
|
||||
out icw_2_4, al
|
||||
jmp short $+2 ; I/O-Delay
|
||||
mov al, 00010001b ; ICW4, MCS-86, EOI, non-buffered,
|
||||
; fully nested
|
||||
out icw_2_4, al
|
||||
jmp short $+2 ; I/O-Delay
|
||||
mov al, 01111100b ; Kanal 0, 1 + 7 am PIC demaskieren
|
||||
; PIT K1, K2 und Lichttaster
|
||||
out ocw_1, al
|
||||
|
||||
; Interrupttabelle init.
|
||||
mov word [intab7], isr_lt ; Interrupttabelle (Lichttaster)
|
||||
; initialisieren (Offset)
|
||||
mov [intab7 + 2], cs ; (Segmentadresse)
|
||||
|
||||
mov word [intab0], isr_servotimer ; Interrupttabelle (Timer K1)
|
||||
; initialisieren (Offset)
|
||||
mov [intab0 + 2], cs ; (Segmentadresse)
|
||||
|
||||
mov word [intab1], isr_opentimer ; Interrupttabelle (Timer K2)
|
||||
; initialisieren (Offset)
|
||||
mov [intab1 + 2], cs ; (Segmentadresse)
|
||||
|
||||
sti ; ab jetzt Interrupts
|
||||
ret
|
||||
|
||||
;------------------------ Serviceroutinen -----------------------------------
|
||||
|
||||
isr_opentimer: ; Timer fuer Vereinzeler (Zeit fuer Oeffnung)
|
||||
push ax
|
||||
mov ah, [tcounto]
|
||||
mov al, [status]
|
||||
test al, 0x01
|
||||
jz isr_opentimer_out
|
||||
inc ah
|
||||
cmp ah, [tcountv]
|
||||
jnz isr_opentimer_out
|
||||
mov ah, 0
|
||||
mov byte[direction], trechts
|
||||
and al, 0xfe
|
||||
|
||||
isr_opentimer_out: ; Ausgang aus dem Service
|
||||
mov [status], al
|
||||
mov [tcounto], ah
|
||||
mov al, eoi ; EOI an PIC
|
||||
out ocw_2_3, al
|
||||
pop ax
|
||||
iret
|
||||
|
||||
isr_lt: ; Lichttaster
|
||||
push ax
|
||||
mov al, [status]
|
||||
test al, 0x01
|
||||
jnz isr_lt_out
|
||||
mov byte[direction], tlinks
|
||||
or al, 0x01
|
||||
add al, 0x10
|
||||
jnc isr_lt_out
|
||||
mov al, pieces << shcnt
|
||||
and al, 0xfe
|
||||
mov byte[direction], trechts
|
||||
|
||||
|
||||
|
||||
isr_lt_out: ; Ausgang aus dem Service
|
||||
mov [status], al
|
||||
mov al, eoi ; EOI an PIC
|
||||
out ocw_2_3, al
|
||||
pop ax
|
||||
iret
|
||||
|
||||
isr_servotimer: ; Timer fuer Servo (Vereinzeler)
|
||||
push ax
|
||||
mov ah, [tcounts]
|
||||
inc ah
|
||||
cmp ah, [direction]
|
||||
jnz if_direction
|
||||
mov al, 0
|
||||
out ppi_a, al
|
||||
|
||||
if_direction:
|
||||
cmp ah, tpwm
|
||||
jnz isr_servotimer_out
|
||||
mov al, ppi_pa6
|
||||
out ppi_a, al
|
||||
mov ah, 0
|
||||
|
||||
|
||||
|
||||
|
||||
isr_servotimer_out: ; Ausgang aus dem Service
|
||||
mov [tcounts], ah
|
||||
mov al, eoi ; EOI an PIC
|
||||
out ocw_2_3, al
|
||||
pop ax
|
||||
iret
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user