CLS
base0 = &H378
OUT base0, &H80: OUT base0 + 2, 11
FOR N = 0 TO 7
Dout(N) = 0
NEXT N
Dout = 0
start:
CLS
INPUT "which output do you want to toggle"; N
IF N OR N > 7 THEN GOTO start
N = FIX(N)
Dout(N) = ABS(NOT (N))
FOR N = 0 TO 7
IF Dout(N) = 0 THEN
Dout = Dout AND NOT (2 ^ N)
ELSE
Dout = Dout OR 2 ^ N
END IF
NEXT N
FOR bit = 1 TO 8
b = 8 - bit
byte = ((Dout AND 2 ^ b) / 2 ^ b) OR &H80
OUT base0, byte
OUT base0, byte OR 2
OUT base0, byte
NEXT bit
FOR bit = 9 TO 24
OUT base0, &H82
OUT base0, &H80
NEXT bit
OUT base0, &H90
OUT base0, &H80
GOTO start