Advertisement
heavenriver

DataTransfer.asm (Polling)

Apr 28th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 400h
  2. dev0 EQU 0h                                 ; Declares all devices as constants for future use
  3. dev1 EQU 4h
  4. dev2 EQU 8h
  5. dev3 EQU 12h
  6. code
  7. MOVB #64h, R0                               ; Initializes a counter per device (each device contains 100 data to be copied)
  8. MOVB #64h, R1
  9. MOVB #64h, R2
  10. MOVB #64h, R3
  11. MOVL #600h, R4                              ; Stores the memory location to start copying data to (works as a memory counter)
  12. JSR files                                   ; Jumps to the subroutine that copies data from devices
  13. files: PUSH R0                              ; Saves the counters
  14. PUSH R1
  15. PUSH R2
  16. PUSH R3
  17. PUSH R4
  18. start0: JNR dev0, start0                    ; [BUSY WAITING] Starts each device when it's ready
  19. START dev0
  20. start1: JNR dev1, start1
  21. START dev1
  22. start2: JNR dev2, start2
  23. START dev2
  24. start3: JNR dev3, start3
  25. START dev3
  26. routine0: JNR dev0, routine1                ; [POLLING] Copies data from each device until the related device counter hits zero
  27. ADDB #0h, R0                                ; Dual check: prevents overflow (data might be transferred more than 100 times)
  28. JZ check
  29. INL dev0, (R4)+                             ; Updates the memory location with each following operation
  30. SUBB #1h, R0                                ; Updates the counter
  31. JMP check                                   ; Checks all counters
  32. routine1: JNR dev1, routine2
  33. ADDB #0h, R1
  34. JZ check
  35. INL dev1, (R4)+
  36. SUBB #1h, R1
  37. JMP check
  38. routine2: JNR dev2, routine3
  39. ADDB #0h, R2
  40. JZ check
  41. INL dev2, (R4)+
  42. SUBB #1h, R2
  43. JMP check
  44. routine3: JNR dev3, routine0
  45. ADDB #0h, R3
  46. JZ check
  47. INL dev3, (R4)+
  48. SUBB #1h, R3
  49. check: ADDB #0h, R0                         ; Adds 0 to each register to check if they are all empty
  50. JNZ routine0                                ; Keeps skipping routines until data transfers are over
  51. ADDB #0h, R1
  52. JNZ routine1
  53. ADDB #0h, R2
  54. JNZ routine2
  55. ADDB #0h, R3
  56. JNZ routine3
  57. exit: POP R4                                ; Restores the registers used in the subroutine to their original state
  58. POP R3
  59. POP R2
  60. POP R1
  61. POP R0
  62. RET                                         ; Returns from subroutine and continues program execution
  63. halt
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement