If you're talking about doing this in hardware, it's called a UART. Your PC has one or two for its COM ports.
It you're talking about doing this in software, it's some data manipulation in a loop involving shift registers and logical shifts (or multiplication) and addition. See the attached LabView 6.1 example.