If you have activated a logical file as the current output channel (using CHKOUT
or $FFC9
), you reset both active input and output channels to default using CLRCHN
a.k.a. CLRCH
, $FFCC
.
After that, BSOUT
$FFD2
will print to the screen.
This will not have closed the file, it is still open. You can re-activate it again with CHKOUT
and eventually close it with CLOSE
, $FFC3
.
There is no need to use any of the bus-related functions such as TALK
or LISTEN
: they are the wrong abstraction level here. They come in handy if you want to talk to a disk drive or printer but not use the file administration for it.
Another answer confuses the device number for the screen (which is 3) with logical file numbers. If you open a file, you basically create a mapping from a LFN (logical file number) to a device number (and possibly a secondary address, but those are too far out of the scope of printing to the screen).
There are various books available about machine language programming on the 64, such as "(Compute's) Programming the Commodore 64, The definitive guide" by Raeto Collin West. I have "Programming the PET/CBM" by the same author and it is very thorough.
Here on archive.org are some more.