Advertisement
heavenriver

ExEsame9.asm

Jun 14th, 2012
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Exercise on slide 9: July 13th, 2000 exam
  2.  
  3. org 400h
  4. timer1 equ 0h
  5. timer2 equ 1h
  6. synch equ 0AAAAh         ;Initialized to 0, put to 1 when synching (when interrupt1 reaches), checked if 1 when synched (when interrupt2 reaches)
  7.                          ;Is put to 0 in that case, else CPU imports a longword from timer2 set at buffer and system is reset
  8. time1 equ 0BBBBh         ;Time in between interruptions (timer1 interrupts)
  9. time2 equ 0CCCCh         ;Time in between interruptions (timer2 interrupts)
  10. buffer equ 0DDDDh        ;Memory buffer
  11. code
  12. jsr init                 ;Initializes devices
  13. main: jmp main           ;Stalls until interrupt is received
  14. halt
  15. init: movb #0, synch     ;Initializes synch to 0, then starts devices
  16. outb time1, timer1       ;Initializes timers to respective time counters
  17. outb time2, timer2
  18. start timer1
  19. start timer2
  20. seti
  21. setim timer1
  22. setim timer2
  23. ret
  24. driver 0, 700h           ;Driver for timer1
  25. clrim timer2
  26. movb #1, synch           ;Sets synch byte to 1 and returns to main
  27. start timer1
  28. rti
  29. driver 1, 1100h          ;Driver for timer2
  30. push R0
  31. clrim timer1             ;Disables timer1 interrupts for driver execution
  32. movb #1, R0
  33. cmpb synch, R0           ;Checks if current synch value is 1
  34. jz unsynch               ;If so, resets it to 0
  35. inl timer2, buffer       ;If not, imports longword from timer
  36. jsr init                 ;Restarts devices
  37. unsynch: movb #0, synch  ;Unsynchs devices
  38. start timer2
  39. resume: setim timer1     ;Returns from driver
  40. pop R0
  41. rti
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement