Advertisement
heavenriver

ExEsame2009giu11a.asm

Jun 17th, 2012
430
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;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.
  2. ;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:
  3. ;- Il SCA dell’interfaccia tra MOUSE, TIMER e PD32;
  4. ;- Il software di attivazione per TIMER e il relativo driver.
  5.  
  6. org 400h
  7. timer equ 0h            ;Timer, interrupts every #tot seconds
  8. mouse equ 1h            ;Mouse, provides X and Y coordinates
  9. buffer equ 0ABCDh       ;Memory buffer
  10. max equ 0DDDDh          ;Maximum value obtained
  11. tot equ ?               ;Nanoseconds in between timer interrupts (not specified in task)
  12. jsr init
  13. seti
  14. main: jmp main          ;Loops until interrupt
  15. halt
  16. init: movl #tot, R0     ;Initializes devices
  17. outl timer, R0          ;Sets timer delay
  18. start timer
  19. ret
  20. setmax: push R0         ;Calculates and stores maximum
  21. push R1
  22. push R2
  23. push R3
  24. movl #100, R0           ;R0 = WC
  25. movl buffer, R1         ;R1 = CAR
  26. findmax: movl (R1)+, R2 ;Acquires a longword and forwards address pointer
  27. cmpl #max, R2           ;Checks if current longword is greater than maximum
  28. jn skip                 ;If not, skips updating maximum
  29. movl R2, #max           ;If so, updates maximum
  30. skip: subl #1, R0       ;Updates counter
  31. jnz findmax             ;Loops subroutine until counter hits zero
  32. pop R3
  33. pop R2
  34. pop R1
  35. pop R0
  36. ret
  37. driver 0, 700h          ;Timer driver
  38. push R0
  39. push R1
  40. push R2
  41. push R3
  42. push R4
  43. movl #mouse, R0
  44. movl #100, R1           ;R1 = WC
  45. movl buffer, R2         ;R2 = CAR
  46. data: inw R0, R3        ;Imports X coordinate
  47. inw R0, R4              ;Imports Y coordinate
  48. asll #16, R3            ;Moves X coordinate to first longword part
  49. addl R3, R4             ;Sums X and Y
  50. movl R4, (R2)+          ;Moves to memory location
  51. subl #1, R1             ;Updates counter
  52. jnz data                ;Keeps acquiring data until counter hits zero
  53. jsr setmax              ;When counter hits zero, updates maximum
  54. pop R4
  55. pop R3
  56. pop R2
  57. pop R1
  58. pop R0
  59. rti
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement