DataMuseum.dk

Presents historical artifacts from the history of:

RC3500

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about RC3500

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦4934739fa⟧ TextFileVerbose

    Length: 4608 (0x1200)
    Types: TextFileVerbose
    Names: »tsch5job«

Derivation

└─⟦a41ae585a⟧ Bits:30001842 SW-save af projekt 1000, Alarm-system
    └─⟦72244f0ef⟧ 
        └─⟦this⟧ »tsch5job« 

TextFileVerbose

job nla 7 200 perm mini1 100 10 time 11 59 area 9 size 120000
mode list.yes
( source = copy 25.1
templist = indent source mark lc
outlist = cross templist
clear temp templist
o errors
pascal80 spacing.1200 codesize.1200 alarmenvc source
o c
lookup pass6code
if ok.yes
( tsch5bin = set 1 mini1
tsch5bin = move pass6code
scope user tsch5bin )
tsch5lst = set 1 mini1
tsch5lst = copy outlist errors
scope user tsch5lst
convert errors
finis )

prefix check5;


function check5(
             var msg: reference; (* reference to telegram in question *)
             dowhat: what           (* what must be generate or check *)
             ): boolean;            (* false if check says fault *)

(********************************************************************
*
* function:   the check5 module either inserts a calcula-
*             ted checksum into a telegram or controls the tele-
*             gram with the aid of the checksum.      
*
* externals:  none.                    
*
* parameters: msg is the reference to the telegram to check or to generate
*             checkbits in
*             dowhat says insert a checksum (=generate) or control the
*             telegram of the buffer (=check).    
*
* semaphores: none.               
*
* version:     1/04
*
* programmed  may 1980 by srs             
*
********************************************************************)

\f


type

telegram_type = set of 0..15;   (* 16 bits *)

(*   0 1 2 3 4 5 6 7 8 9 A B C D E F      *
 *   I---------------I---I-I---------I     *
 *   I     data       opc l   check  I     *
 *   I---------------I---I-I---------I     *
 *                                         *
 *                                         *)

 
var
check_telegram ,
calculated_sum ,
add_to_sum     : telegram_type;
bit_c5         ,
bitno          : integer;
 
 
\f


function getbit( i: integer ): telegram_type;
(* Here we have the checkcode table *)
begin
case i of
0:  getbit:= (. 11..15 .);            (* 11111 *)
1:  getbit:= (. 12..15 .);            (* 01111 *)
2:  getbit:= (. 11,13,15 .);          (* 10101 *)
3:  getbit:= (. 13..15 .);            (* 00111 *)
4:  getbit:= (. 11,12,14,15 .);       (* 11011 *)
5:  getbit:= (. 12,14,15 .);          (* 01011 *)
6:  getbit:= (. 11,14,15 .);          (* 10011 *)
7:  getbit:= (. 11,12,13,15 .);       (* 11101 *)
8:  getbit:= (. 12,13,15 .);          (* 01101 *)
9:  getbit:= (. 11,13,14,15 .);       (* 10111 *)
10: getbit:= (. 11,12,15 .)           (* 11001 *)
end (* case *);
end (* of getbit function *);


\f


function xor( a, b: telegram_type ): telegram_type;
 
(************************************************************
* This Exclusive OR function operates on 16-bits at the     *
* same time by use of set operations.                       *
************************************************************)
 
begin
xor:= (a+b)-(a*b);
end (* of xor function *);

\f


begin        (**************************************
              ***                                ***
              *** the body of the check5 module  ***
              ***                                ***
              **************************************)

calculated_sum:= (. 12,14 .);    (* (12,14) corresponds to 01010 *)

lock msg as telegram: telegram_type do
begin
 
(***************************************************
* the meaning of the next for-statement:
*  step through the telegram. for every one bit
*  change the checksum with a tabular value belon-
*  ging to that bitposition.       
***************************************************)
 
for bitno:=0 to 10 do
if bitno in telegram then
begin
add_to_sum:= getbit( bitno );
calculated_sum:= xor( calculated_sum, add_to_sum )
end;
 
(*********** adjust bit_c5 ***********************)

bit_c5 := 0;
for bitno := 11 to 15 do
if bitno in calculated_sum then
bit_c5 := bit_c5 + 1;

if (bit_c5 mod 2) = 0 then
calculated_sum := calculated_sum - (. 15 .)
else
calculated_sum := calculated_sum + (. 15 .);

(****** the generated telegram ******************)

check_telegram := (telegram - (. 11..15 .)) + calculated_sum;

check5:= true;
 
if dowhat = generate then        (* apply the checksum to the telegram *)
telegram := check_telegram
else                         (* check the telegram *)
begin
add_to_sum:= xor( telegram, check_telegram );
if add_to_sum = (..) then
check5:= true
else
check5:= false;
end
end (* of lock statement *)
end (* of check5 function *);.

«eof»