1. a. 1-bit Inverter
Main:
P0.0 = Not P1.0
Goto Main
b. 8-bit Buffer
P1 = 0
P0 = 0
Do
P0 = P1
Loop
c. 8-bit Inverter
P1 = &HFF
P2 = &HFF
Main:
P1.0 = Not P2.0
P1.1 = Not P2.1
P1.2 = Not P2.2
P1.3 = Not P2.3
P1.4 = Not P2.4
P1.5 = Not P2.5
P1.6 = Not P2.6
P1.7 = Not P2.7
Goto Main
d. 8-input AND Gate
Dim Var As Byte
Main:
If P0 = 255 Then
P1.0 = 1
Else
P1.0 = 0
End If
Goto Main
e. 8-input OR Gate
Dim Var As Byte
Main:
If P0 = 0 Then
P1.0 = 0
Else
P1.0 = 1
End If
Goto Main
f. 8-input NAND Gate
Dim Var As Byte
Main:
If P0 = 255 Then
P1 = 0
Else
P1 = 1
End If
Goto Main
g. 8-bit XOR Gate
Dim A As Bit
Do
A = P0.0 Xor P0.1
A = A Xor P0.2
A = A Xor P0.3
A = A Xor P0.4
A = A Xor P0.5
A = A Xor P0.6
A = A Xor P0.7
P1.0 = A
Loop
1. Write a routine for an open door alarm system that continually monitors the doors of a four door car sedan.
P0 = &B1111
P1.0 = 1
'Door is CLOSED = 0
'Alarm is OFF = 0
Main:
If P0 = 0000 Then
P1.0 = 0
Else
P1.0 = 1
End If
Goto Main
2. Write the program for a system that will turn ON a LED when the PBNO switch is pressed. Pressing and then releasing again this PBNO switch will turn the LED OFF.
'P3.0 = LED
'P2.0 = PBNO Switch
Do
P3.0 = P2.0
Loop
3. Write the program for a system that will turn ON a LED when the PBNO switch 1 is pressed. Pressing and then releasing PBNO switch 2 will turn the LED OFF.
'P0.0 = LED
'P1.0 = Switch 1
'P2.0 = Switch 2
P0.0 = 0
P1.0 = 0
P2.0 = 0
Do
If P1.0 = 1 Then
P0.0 = 1
End If
If P2.0 = 1 Then
P0.0 = 0
End If
Loop
4. Write the program for a system that will switch ON the AC power generator as soon as the main AC source is OFF. Switch OFF the AC power generator when the main AC power is ON.
Main_ac Alias P0.0
Ac_generator Alias P1.0
Do
Ac_generator = Not Main_ac
Loop
5. Write the program for a