Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;TIMER e MOUSE sono due periferiche interfacciate direttamente al processore PD32. TIMER lancia interruzioni ogni TOT nanosecondi verso il PD32. Il servizio associato all'interruzione è il seguente: il processore legge in maniera sincrona dalla periferica MOUSE le nuove coordinate X,Y (espressa ognuna come word) e le memorizza sequenzialmente in un buffer in memoria formato da 100 longword a partire dalla locazione ABCDh. Ogni longword è costituita dalla coppia (XY). Ogni 100 letture il driver calcola il massimo, come longword, tra le coppie memorizzate e lo memorizza all'indirizzo DDDDh e resetta il puntatore per sovrascrivere i prossimi 100 valori a partire nuovamente dall'indirizzo ABCDh.
- ;Si noti che il driver ad ogni lettura legge una sola coordinata (la prima volta la X e la seconda la Y). Il servizio di acquisizione e calcolo della media è ciclico e non prevede arresto. Progettare l'interfaccia di MOUSE e TIMER. La routine di inizializzazione ed il driver per la gestione delle interruzioni di TIMER. Progettare:
- ;- Il SCA dell’interfaccia tra MOUSE, TIMER e PD32;
- ;- Il software di attivazione per TIMER e il relativo driver.
- org 400h
- timer equ 0h ;Timer, interrupts every #tot seconds
- mouse equ 1h ;Mouse, provides X and Y coordinates
- buffer equ 0ABCDh ;Memory buffer
- max equ 0DDDDh ;Maximum value obtained
- tot equ ? ;Nanoseconds in between timer interrupts (not specified in task)
- jsr init
- seti
- main: jmp main ;Loops until interrupt
- halt
- init: movl #tot, R0 ;Initializes devices
- outl timer, R0 ;Sets timer delay
- start timer
- ret
- setmax: push R0 ;Calculates and stores maximum
- push R1
- push R2
- push R3
- movl #100, R0 ;R0 = WC
- movl buffer, R1 ;R1 = CAR
- findmax: movl (R1)+, R2 ;Acquires a longword and forwards address pointer
- cmpl #max, R2 ;Checks if current longword is greater than maximum
- jn skip ;If not, skips updating maximum
- movl R2, #max ;If so, updates maximum
- skip: subl #1, R0 ;Updates counter
- jnz findmax ;Loops subroutine until counter hits zero
- pop R3
- pop R2
- pop R1
- pop R0
- ret
- driver 0, 700h ;Timer driver
- push R0
- push R1
- push R2
- push R3
- push R4
- movl #mouse, R0
- movl #100, R1 ;R1 = WC
- movl buffer, R2 ;R2 = CAR
- data: inw R0, R3 ;Imports X coordinate
- inw R0, R4 ;Imports Y coordinate
- asll #16, R3 ;Moves X coordinate to first longword part
- addl R3, R4 ;Sums X and Y
- movl R4, (R2)+ ;Moves to memory location
- subl #1, R1 ;Updates counter
- jnz data ;Keeps acquiring data until counter hits zero
- jsr setmax ;When counter hits zero, updates maximum
- pop R4
- pop R3
- pop R2
- pop R1
- pop R0
- rti
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement