Home

IBM 5150  -  Test of SW1 and SW2 via BASIC


SW1 and SW2 are the two switch blocks on an IBM 5150 motherboard.

Although there will be DOS based diagnostic programs that test SW1 and SW2, sometimes 5150 users are in the situation of being able to boot to BASIC, but not DOS.
The tests below will allow such users to determine, via BASIC, if faulty SW1/SW2 circuitry is the possible reason why they can't boot to DOS.

Failure of a test below indicates either a faulty switch block or failure of the associated circuitry that selects/reads the switch blocks.

These tests are not applicable to the IBM 5160:
   * SW1 is wired up differently on a 5160 motherboard.
   * SW2 is not present on a 5160 motherboard.


--------------------------------------------------------------------------------------------------------------------------------------------------
TEST 1 OF 2  -  Switch block SW1 (closest to board center)
--------------------------------------------------------------------------------------------------------------------------------------------------

1. Take a note of what the switches on SW1 are presently set to.

2. Boot to cassette BASIC

3. Enter the following 3 lines of program:

   10 out &h61,&hcc
   20 print inp(&h60)
   30 out &h61,&h4c

Note: Later, when you run the program, a side effect of line 10 is that the keyboard gets disabled (because SW1 reading and keyboard reading can't be done at the same time).
         Line 30 re-enables the keyboard.


4. Set all switches on SW1 to OFF.
5. Run the program (enter RUN). You should see "255" displayed.

6. Set all switches on SW1 to ON.
7. Run the program. You should see "0" displayed.

8. Set SW1 so that switch 1 is the only switch OFF.
9. Run the program. You should see "1" displayed.

10. Repeat steps 8 and 9 for each of the remaining 7 switches:
        switch 2 is only one OFF - should see "2"
        switch 3 is only one OFF - should see "4"
        switch 4 is only one OFF - should see "8"
        switch 5 is only one OFF - should see "16"
        switch 6 is only one OFF - should see "32"
        switch 7 is only one OFF - should see "64"
        switch 8 is only one OFF - should see "128"

11. Set SW1 so that switches 1,3,5,7 are ON and switches 2,4,6,8 are OFF.
12. Run the program. You should see "170" displayed.                                    [ 170 decimal = 10101010 binary ]

13. Set SW1 so that switches 1,3,5,7 are OFF and switches 2,4,6,8 are ON.
14. Run the program. You should see "85" displayed.                                    [ 85 decimal = 01010101 binary ]

15. Set SW1 back to the settings that you noted in step 1.

16. Reboot the 5150.



--------------------------------------------------------------------------------------------------------------------------------------------------
TEST 2 OF 2  -  Switch block SW2 (block closest to board edge)
--------------------------------------------------------------------------------------------------------------------------------------------------

INFO: Only the first 5 switches in SW2 are connected.
INFO: Not all 5 can be read at once - the first 4 are read in one operation and the 5th in another. The BASIC program below deals with that.

1. Take a note of what the switches on SW2 are presently set to.

2. Boot to cassette BASIC

3. Enter the following 5 lines of program:

   10 out &h61,&h4c
   20 lower4 = inp(&h62) and &h0f
   30 out &h61,&h48
   40 switch5 = inp(&h62) and &h01
   50 print 16 * switch5 + lower4

4. Set switches 1 to 5 on SW2 to OFF (remaining switches on SW2 do nothing).
5. Run the program. You should see "31" displayed.

6. Set switches 1 to 5 on SW2 to ON.
7. Run the program. You should see "0" displayed.

8. Set SW1 so that switch 1 is OFF and switches 2 to 5 are ON.
9. Run the program. You should see "1" displayed.

10. Repeat steps 8 and 9 for each of the remaining 4 switches:
        switch 2 is only one OFF - should see "2"
        switch 3 is only one OFF - should see "4"
        switch 4 is only one OFF - should see "8"
        switch 5 is only one OFF - should see "16"

11. Set SW2 so that switches 1,3,5 are ON and switches 2 and 4 are OFF.
12. Run the program. You should see "10" displayed.                                    [ 10 decimal = 01010 binary ]

13. Set SW2 so that switches 1,3,5 are OFF and switches 2 and 4 are ON.
14. Run the program. You should see "21" displayed.                                    [ 21 decimal = 10101 binary ]

15. Set SW2 back to the settings that you noted in step 1.

16. Reboot the 5150.