KLASPORT ;NEW PROGRAM [ 08/11/92 3:53 PM ]
;;
SET ;set and clear IO port bits
K DIR S (XS,XC)=""
I IO=IO(0) W !,"IO=IO(0) not a good idea !",! S X=$$TERMINAL^%HOSTCMD("stty -a")
W !!!,"***** DEVICE = ",IO D ZA
I IO=157 W ! S X=$$TERMINAL^%HOSTCMD("stty -a < /dev/tty57")
K DIR
W ! S DIR(0)="LO^0:23",DIR("A")="Set bits ? : " D ^DIR
K PWZ F I=1:1 S Z=$P(Y,",",I) Q:Z="" S:'$D(PWZ(Z)) XS=$G(XS)+(2**$P(Y,",",I)),PWZ(Z)=""
W !,XS S X=XS D EN
K DIR
W ! S DIR(0)="LO:23",DIR("A")="Clear bits ? : " D ^DIR
K PWZ F I=1:1 S Z=$P(Y,",",I) Q:Z="" S:'$D(PWZ(Z)) XC=$G(XC)+(2**$P(Y,",",I)),PWZ(Z)=""
W !,XC S X=XC D EN
I XS="",XC="" Q
I XC]"" S PWX="U IO:(::::"_XS_":"_XC_")"
E S PWX="U IO:(::::"_XS_")"
W !!,PWX X PWX D ZA
G SET
; --------------------------
EN U IO(0) W !,"BITS : "
F I=25:-1:0 I X'<(2**I) W " ",I S X=X-(2**I)
Q
ZA U IO S ZA=$ZA,X=ZA D EN
Q
READ ;decimal binary to bit map of binary
F R !,"decimal number ? ",X Q:X'>0 D EN
Q
TBL ;generate bit - decimal map
F I=0:1:25 W !,I,?5,2**I
Q
PORT U IO:(::::8388608+2097152+4096+512+1:4194304+262144) ;set passall;ctrl/O as data;assert DTR;no echo;;input buffer XON;7b data
Q
KLASPORT ;NEW PROGRAM [ 08/11/92 3:53 PM ]
+1 ;;
SET ;set and clear IO port bits
+1 KILL DIR
SET (XS,XC)=""
+2 IF IO=IO(0)
WRITE !,"IO=IO(0) not a good idea !",!
SET X=$$TERMINAL^%HOSTCMD("stty -a")
+3 WRITE !!!,"***** DEVICE = ",IO
DO ZA
+4 IF IO=157
WRITE !
SET X=$$TERMINAL^%HOSTCMD("stty -a < /dev/tty57")
+5 KILL DIR
+6 WRITE !
SET DIR(0)="LO^0:23"
SET DIR("A")="Set bits ? : "
DO ^DIR
+7 KILL PWZ
FOR I=1:1
SET Z=$PIECE(Y,",",I)
IF Z=""
QUIT
IF '$DATA(PWZ(Z))
SET XS=$GET(XS)+(2**$PIECE(Y,",",I))
SET PWZ(Z)=""
+8 WRITE !,XS
SET X=XS
DO EN
+9 KILL DIR
+10 WRITE !
SET DIR(0)="LO:23"
SET DIR("A")="Clear bits ? : "
DO ^DIR
+11 KILL PWZ
FOR I=1:1
SET Z=$PIECE(Y,",",I)
IF Z=""
QUIT
IF '$DATA(PWZ(Z))
SET XC=$GET(XC)+(2**$PIECE(Y,",",I))
SET PWZ(Z)=""
+12 WRITE !,XC
SET X=XC
DO EN
+13 IF XS=""
IF XC=""
QUIT
+14 IF XC]""
SET PWX="U IO:(::::"_XS_":"_XC_")"
+15 IF '$TEST
SET PWX="U IO:(::::"_XS_")"
+16 WRITE !!,PWX
XECUTE PWX
DO ZA
+17 GOTO SET
+18 ; --------------------------
EN USE IO(0)
WRITE !,"BITS : "
+1 FOR I=25:-1:0
IF X'<(2**I)
WRITE " ",I
SET X=X-(2**I)
+2 QUIT
ZA USE IO
SET ZA=$ZA
SET X=ZA
DO EN
+1 QUIT
READ ;decimal binary to bit map of binary
+1 FOR
READ !,"decimal number ? ",X
IF X'>0
QUIT
DO EN
+2 QUIT
TBL ;generate bit - decimal map
+1 FOR I=0:1:25
WRITE !,I,?5,2**I
+2 QUIT
PORT ;set passall;ctrl/O as data;assert DTR;no echo;;input buffer XON;7b data
USE IO:(::::8388608+2097152+4096+512+1:4194304+262144)
+1 QUIT