36 lines
880 B
Plaintext
36 lines
880 B
Plaintext
func OctIn(Dev); \Input from device value of sequence of octets
|
|
int Dev, N, Oct;
|
|
[N:= 0;
|
|
repeat Oct:= HexIn(Dev);
|
|
N:= N<<7 + (Oct&$7F);
|
|
until (Oct&$80) = 0;
|
|
return N;
|
|
];
|
|
|
|
proc OctOut(Dev, Num, Lev); \Output value to device as sequence of octets
|
|
int Dev, Num, Lev, Rem;
|
|
[Rem:= Num & $7F;
|
|
Num:= Num >> 7;
|
|
if Num # 0 then OctOut(Dev, Num, Lev+1);
|
|
if Lev > 0 then Rem:= Rem + $80;
|
|
SetHexDigits(2);
|
|
HexOut(Dev, Rem);
|
|
ChOut(Dev, ^ );
|
|
];
|
|
|
|
\Device 8 is a circular buffer that can be written and read back.
|
|
int N;
|
|
[for N:= 0 to $40_0000 do
|
|
[OctOut(8, N, 0);
|
|
if N # OctIn(8) then
|
|
[Text(0, "Error!"); exit];
|
|
];
|
|
OctOut(0, $1F_FFFF, 0); CrLf(0);
|
|
OctOut(0, $20_0000, 0); CrLf(0);
|
|
OctOut(0, $7F, 0); CrLf(0);
|
|
OctOut(0, $4000, 0); CrLf(0);
|
|
OctOut(0, 0, 0); CrLf(0);
|
|
OctOut(0, $3F_FFFE, 0); CrLf(0);
|
|
OctOut(0, $FFFF_FFFF, 0); CrLf(0);
|
|
]
|