Advertisement
heavenriver

DataTransfer.asm (Busy Waiting)

Apr 23rd, 2012
99
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 #500h, 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. routine0: JNR dev0, routine0                ; [BUSY WAITING] Copies data from each device until the related device counter hits zero
  21. INL dev0, (R4)+                             ; Updates the memory location with each following operation
  22. SUBB #1h, R0                                ; Updates the counter
  23. JNZ routine0                                ; Follows on with the next instruction when the counter hits zero
  24. start1: JNR dev1, start1
  25. START dev1
  26. routine1: JNR dev1, routine1
  27. INL dev1, (R4)+
  28. SUBB #1h, R1
  29. JNZ routine1
  30. start2: JNR dev2, start2
  31. START dev2
  32. routine2: JNR dev2, routine2
  33. INL dev2, (R4)+
  34. SUBB #1h, R2
  35. JNZ routine2
  36. start3: JNR dev3, start3
  37. START dev3
  38. routine3: JNR dev3, routine3
  39. INL dev3, (R4)+
  40. SUBB #1h, R3
  41. JNZ routine3
  42. POP R4                                      ; Restores the registers used in the subroutine to their original state
  43. POP R3
  44. POP R2
  45. POP R1
  46. POP R0
  47. RET                                         ; Returns from subroutine and continues program execution
  48. halt
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement