Under CP/M 2, input and output device selection are performed by the BIOS. Some BIOSes may implement a feature called the IOBYTE which allows the user to change which device the screen, printer etc. output go to.
The IOBYTE lives at address 3 (in the Zero Page) and should be changed using BDOS calls 7 and 8 (get/set IOBYTE). The value is bitmapped:
     Bits      Bits 6,7    Bits 4,5    Bits 2,3    Bits 0,1
     Device    LIST        PUNCH       READER      CONSOLE
     Value
       00      TTY:        TTY:        TTY:        TTY:
       01      CRT:        PTP:        PTR:        CRT:
       10      LPT:        UP1:        UR1:        BAT:
       11      UL1:        UP2:        UR2:        UC1:
BAT = batch mode.  Use the current Reader for console input, and 
he current List (printer) device as the console output.
CRT = Standard console (keyboard and terminal screen).
LPT = Standard line printer.
PTP = Standard Paper Tape Punch.
PTR = Standard Paper Tape Reader.
TTY = Teletype device, eg a serial port.
UC1 = User defined (ie implementation dependent) console device.
UL1 = User defined (ie implementation dependent) printer device.
UPn = User defined (ie implementation dependent) output device.
URn = User defined (ie implementation dependent) input device.