Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 400h
- dev0 EQU 0h ; Declares all devices as constants for future use
- dev1 EQU 4h
- dev2 EQU 8h
- dev3 EQU 12h
- code
- MOVB #64h, R0 ; Initializes a counter per device (each device contains 100 data to be copied)
- MOVB #64h, R1
- MOVB #64h, R2
- MOVB #64h, R3
- MOVL #600h, R4 ; Stores the memory location to start copying data to (works as a memory counter)
- JSR files ; Jumps to the subroutine that copies data from devices
- files: PUSH R0 ; Saves the counters
- PUSH R1
- PUSH R2
- PUSH R3
- PUSH R4
- start0: JNR dev0, start0 ; [BUSY WAITING] Starts each device when it's ready
- START dev0
- start1: JNR dev1, start1
- START dev1
- start2: JNR dev2, start2
- START dev2
- start3: JNR dev3, start3
- START dev3
- routine0: JNR dev0, routine1 ; [POLLING] Copies data from each device until the related device counter hits zero
- ADDB #0h, R0 ; Dual check: prevents overflow (data might be transferred more than 100 times)
- JZ check
- INL dev0, (R4)+ ; Updates the memory location with each following operation
- SUBB #1h, R0 ; Updates the counter
- JMP check ; Checks all counters
- routine1: JNR dev1, routine2
- ADDB #0h, R1
- JZ check
- INL dev1, (R4)+
- SUBB #1h, R1
- JMP check
- routine2: JNR dev2, routine3
- ADDB #0h, R2
- JZ check
- INL dev2, (R4)+
- SUBB #1h, R2
- JMP check
- routine3: JNR dev3, routine0
- ADDB #0h, R3
- JZ check
- INL dev3, (R4)+
- SUBB #1h, R3
- check: ADDB #0h, R0 ; Adds 0 to each register to check if they are all empty
- JNZ routine0 ; Keeps skipping routines until data transfers are over
- ADDB #0h, R1
- JNZ routine1
- ADDB #0h, R2
- JNZ routine2
- ADDB #0h, R3
- JNZ routine3
- exit: POP R4 ; Restores the registers used in the subroutine to their original state
- POP R3
- POP R2
- POP R1
- POP R0
- RET ; Returns from subroutine and continues program execution
- halt
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement