The computer knows when the transmission is in either third or fourth gear. However, it has nothing to do with the shifter. There are switches inside the transmission that close when third or fourth gear are applied. The computer knows if those switches are closed or open. So, if neither switch is closed, the computer assumes that the transmission is in "low gear" (first or second). When the first switch closes, the computer knows that the transmission is in third gear. When the other switch closes, the computer knows that the transmission is in fourth gear. The shifter position does not affect the operation of the third and fourth gear switches inside the transmission.
The computer also knows when the transmission is in park/neutral. I'm not sure if it gets that signal from the neutral safety switch or somewhere else.
Sent from my SCH-I535 using Turbo Buick