a4: Testat bestanden
This commit is contained in:
parent
f30cd03674
commit
949a74f52c
121
src/asm/a4.asm
121
src/asm/a4.asm
|
@ -16,9 +16,10 @@ tcountv dw 100 * twait ; Impulszaehler fuer Verzoegerung * 10ms
|
|||
; Rueckwaertszaehler
|
||||
frei db 'frei ', 0 ; Texte
|
||||
belegt db 'belegt ', 0
|
||||
divider db 0
|
||||
|
||||
; Konstanten
|
||||
divider equ 0 ; Platzhalter fuer Ihre Zeitkonstante1
|
||||
??? 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
|
||||
|
@ -84,20 +85,18 @@ start:
|
|||
|
||||
again:
|
||||
|
||||
; Ihr Programmcode...
|
||||
mov al, [status]
|
||||
out leds, al
|
||||
|
||||
mov ax, [status]
|
||||
out leds, ax
|
||||
times shcnt shr al, 1
|
||||
|
||||
times shcnt shr ax, 1
|
||||
|
||||
cmp ax, 0x0
|
||||
cmp al, 0x0
|
||||
jz ifzero
|
||||
|
||||
cmp ax, 0x8
|
||||
cmp al, 0x8
|
||||
ja ifbelowzero
|
||||
|
||||
cmp ax, 0x0
|
||||
cmp al, 0x0
|
||||
ja ifnotzero
|
||||
|
||||
jmp again
|
||||
|
@ -120,13 +119,9 @@ ifzero:
|
|||
|
||||
ifbelowzero:
|
||||
|
||||
mov dx, pieces << shcnt
|
||||
and dx, 10000001b
|
||||
mov [status], dx
|
||||
|
||||
|
||||
jmp again
|
||||
|
||||
mov dl, pieces << shcnt
|
||||
and dl, 10000001b
|
||||
mov [status], dl
|
||||
|
||||
jmp again
|
||||
|
||||
|
@ -195,23 +190,25 @@ init:
|
|||
|
||||
isr_opentimer: ; Timer fuer Vereinzeler (Zeit fuer Oeffnung)
|
||||
push ax
|
||||
push bx
|
||||
|
||||
inc byte [divider]
|
||||
cmp byte [divider], tcountv
|
||||
jne isr_opentimer_out
|
||||
test byte[status], 1
|
||||
jz isr_opentimer_out
|
||||
|
||||
mov ax, [status]
|
||||
and ax, 11111110b
|
||||
mov [status], ax
|
||||
mov bl, [tcountv]
|
||||
dec bl
|
||||
mov [tcountv], bl
|
||||
jnz isr_opentimer_out
|
||||
mov word[tcountv], 100*twait
|
||||
|
||||
|
||||
|
||||
|
||||
; Ihr Programmcode
|
||||
mov al, [status]
|
||||
and al, 11111110b
|
||||
mov [status], al
|
||||
|
||||
isr_opentimer_out: ; Ausgang aus dem Service
|
||||
mov al, eoi ; EOI an PIC
|
||||
out ocw_2_3, al
|
||||
pop bx
|
||||
pop ax
|
||||
iret
|
||||
|
||||
|
@ -219,21 +216,19 @@ isr_lt: ; Lichttaster
|
|||
push ax
|
||||
|
||||
mov al, [status]
|
||||
test al, 00000001b
|
||||
jne isr_lt_out
|
||||
|
||||
times shcnt shr al, 1
|
||||
dec al
|
||||
|
||||
times shcnt shl al, 1
|
||||
and byte [status], 00001111b
|
||||
or [status], al
|
||||
|
||||
|
||||
; Ihr Programmcode
|
||||
|
||||
isr_lt_out: ; Ausgang aus dem Service
|
||||
or al, 00000001b
|
||||
mov [status], al
|
||||
|
||||
mov [status], al
|
||||
isr_lt_out: ; Ausgang aus dem Service
|
||||
mov al, eoi ; EOI an PIC
|
||||
out ocw_2_3, al
|
||||
pop ax
|
||||
|
@ -241,56 +236,40 @@ isr_lt_out: ; Ausgang aus dem Service
|
|||
|
||||
isr_servotimer: ; Timer fuer Servo (Vereinzeler)
|
||||
push ax
|
||||
push cx
|
||||
push bx
|
||||
|
||||
mov al, [tcounts]
|
||||
inc al
|
||||
mov [tcounts], al
|
||||
mov ah, [tcounts]
|
||||
inc ah
|
||||
cmp ah, [tpwm]
|
||||
je reset
|
||||
|
||||
;send zero all the time
|
||||
push ax
|
||||
mov al, 0
|
||||
out ppi_a, al
|
||||
pop ax
|
||||
;jmp isr_servotimer_out
|
||||
mov [tcounts], ah
|
||||
|
||||
mov cl, tpwm
|
||||
|
||||
mov ah, [status]
|
||||
cmp ah, 0x0
|
||||
jz left
|
||||
mov bh, [status]
|
||||
test bh, 00000001b
|
||||
jnz right
|
||||
|
||||
left: mov bl, [tlinks]
|
||||
jmp move
|
||||
|
||||
right: mov bl, [trechts]
|
||||
|
||||
move: cmp ah, bl
|
||||
jne isr_servotimer_out
|
||||
|
||||
off: mov al, ppi_pa6
|
||||
out ppi_a, al
|
||||
jmp isr_servotimer_out
|
||||
|
||||
left: cmp al, tlinks
|
||||
jne cycle
|
||||
in al, ppi_a
|
||||
and al, ~ppi_pa6
|
||||
reset: mov byte[tcounts], 0
|
||||
mov al, 0
|
||||
out ppi_a, al
|
||||
jmp cycle
|
||||
|
||||
|
||||
right: cmp al, trechts
|
||||
jne cycle
|
||||
in al, ppi_a
|
||||
and al, ~ppi_pa6
|
||||
out ppi_a, al
|
||||
|
||||
cycle: cmp al, tpwm
|
||||
jnz isr_servotimer_out
|
||||
|
||||
in al, ppi_a
|
||||
or al, ppi_pa6
|
||||
out ppi_a, al
|
||||
|
||||
|
||||
|
||||
; Ihr Programmcode
|
||||
|
||||
isr_servotimer_out: ; Ausgang aus dem Service
|
||||
mov byte[tcounts], 0
|
||||
mov al, eoi ; EOI an PIC
|
||||
out ocw_2_3, al
|
||||
pop cx
|
||||
pop bx
|
||||
pop ax
|
||||
iret
|
||||
|
||||
|
|
|
@ -1,243 +0,0 @@
|
|||
|
||||
|
||||
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