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 'NOT
Locate 1 , 1
Lcd "NOT "
Locate 1 , 9
Lcd " "
Locate 2 , 1
Lcd "RABETE "
Locate 2 , 8
Lcd "F=A' "
Locate 1 , 5
Lcd " A="
Locate 1 , 8
Lcd A
N = Not A
Locate 1 , 14
Lcd "F="
Locate 1 , 16
Lcd N
Portd.3 = N
'^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^
Case 2 'AND
Locate 1 , 1
Lcd "AND "
Locate 2 , 1
Lcd "RABETE "
Locate 2 , 8
Lcd "F=(A.B) "
Locate 1 , 5
Lcd " A="
Locate 1 , 10
Lcd "B="
Locate 1 , 8
Lcd A
Locate 1 , 12
Lcd B
M = A And B
Locate 1 , 14
Lcd "F="
Locate 1 , 16
Lcd M
Portd.3 = M
'^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^
Case 3 'NAND
Locate 1 , 1
Lcd "NAND"
Locate 2 , 1
Lcd "RABETE "
Locate 2 , 8
Lcd "F=(A.B)'"
Locate 1 , 5
Lcd " A="
Locate 1 , 10
Lcd "B="
Locate 1 , 8
Lcd A
Locate 1 , 12
Lcd B
M = A And B
N = Not M
Locate 1 , 14
Lcd "F="
Locate 1 , 16
Lcd N
Portd.3 = N
'^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^
Case 4 'OR
Locate 1 , 1
Lcd "OR "
Locate 2 , 1
Lcd "RABETE "
Locate 2 , 8
Lcd "F=(A+B) "
Locate 1 , 5
Lcd " A="
Locate 1 , 10
Lcd "B="
Locate 1 , 8
Lcd A
Locate 1 , 12
Lcd B
M = A Or B
Locate 1 , 14
Lcd "F="
Locate 1 , 16
Lcd M
Portd.3 = M
'^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^
Case 5 'NOR
Locate 1 , 1
Lcd "NOR "
Locate 2 , 1
Lcd "RABETE "
Locate 2 , 8
Lcd "F=(A+B)'"
Locate 1 , 5
Lcd " A="
Locate 1 , 10
Lcd "B="
Locate 1 , 8
Lcd A
Locate 1 , 12
Lcd B
M = A Or B
N = Not M
Locate 1 , 14
Lcd "F="
Locate 1 , 16
Lcd N
Portd.3 = N
'^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^
Case 6 'XOR
Locate 1 , 1
Lcd "XOR "
Locate 2 , 1
Lcd "RABETE "
Locate 1 , 5
Lcd " A="
Locate 2 , 8
Lcd "F=(A"
Locate 2 , 12
Lcd Chr(1)
Locate 2 , 13
Lcd "B) "
Locate 1 , 10
Lcd "B="
Locate 1 , 8
Lcd A
Locate 1 , 12
Lcd B
M = A Xor B
Locate 1 , 14
Lcd "F="
Locate 1 , 16
Lcd M
Portd.3 = M
'^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^ ^_^
Case 7 'XNOR
Locate 1 , 1
Lcd "XNOR"
Locate 2 , 1
Lcd "RABETE "
Locate 2 , 8
Lcd "F=(A"
Locate 2 , 12
Lcd Chr(1)
Locate 2 , 13
Lcd "B)'"
Locate 1 , 5
Lcd " A="
Locate 1 , 10
Lcd "B="
Locate 1 , 8
Lcd A
Locate 1 , 12
Lcd B
M = A Xor B
N = Not M
Locate 1 , 14
Lcd "F="
Locate 1 , 16
Lcd N
Portd.3 = N
'^_^ ^_^ ^_^ ^_^ ^_^ ^_^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