Home | History | Annotate | Download | only in tls
      1 /*
      2  * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
      3  * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
      4  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
      5  */
      6 
      7 /*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/bitter.c,v 1.1 1992/10/28 00:28:39 jutta Exp $*/
      8 
      9 /* Generate code to pack a bit array from a name:#bits description */
     10 
     11 #include	<stdio.h>
     12 #include	"taste.h"
     13 #include	"proto.h"
     14 
     15 void write_code P2((s_spex, n_spex), struct spex * s_spex, int n_spex)
     16 {
     17 	struct spex	* sp = s_spex;
     18 	int		bits = 8;
     19 	int		vars;
     20 
     21 	if (!n_spex) return;
     22 
     23 	vars = sp->varsize;
     24 
     25 	while (n_spex) {
     26 
     27 		if (bits == 8) printf("\t*c++ =   ");
     28 		else printf("\t       | ");
     29 
     30 		if (vars == bits) {
     31 
     32 			printf( (bits==8? "%s & 0x%lX;\n" : "(%s & 0x%lX);\n"),
     33 				sp->var,
     34 				~(0xfffffffe << (bits - 1)));
     35 			if (!-- n_spex) break;
     36 			sp++;
     37 
     38 			vars = sp->varsize;
     39 			bits = 8;
     40 
     41 		} else if (vars < bits) {
     42 
     43 			printf( "((%s & 0x%lX) << %d)",
     44 				sp->var,
     45 				~(0xfffffffe << (vars - 1)),
     46 				bits - vars);
     47 			bits -= vars;
     48 			if (!--n_spex) {
     49 				puts(";");
     50 				break;
     51 			}
     52 			else putchar('\n');
     53 			sp++;
     54 			vars = sp->varsize;
     55 
     56 		} else {
     57 			printf("((%s >> %d) & 0x%X);\n",
     58 				sp->var,
     59 				vars - bits,
     60 				~(0xfffffffe << (bits - 1)));
     61 
     62 			vars -= bits;
     63 			bits = 8;
     64 		}
     65 	}
     66 }
     67