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 #500h, 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
- routine0: JNR dev0, routine0 ; [BUSY WAITING] Copies data from each device until the related device counter hits zero
- INL dev0, (R4)+ ; Updates the memory location with each following operation
- SUBB #1h, R0 ; Updates the counter
- JNZ routine0 ; Follows on with the next instruction when the counter hits zero
- start1: JNR dev1, start1
- START dev1
- routine1: JNR dev1, routine1
- INL dev1, (R4)+
- SUBB #1h, R1
- JNZ routine1
- start2: JNR dev2, start2
- START dev2
- routine2: JNR dev2, routine2
- INL dev2, (R4)+
- SUBB #1h, R2
- JNZ routine2
- start3: JNR dev3, start3
- START dev3
- routine3: JNR dev3, routine3
- INL dev3, (R4)+
- SUBB #1h, R3
- JNZ routine3
- 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