6 /**************************************************************************
8 * -- function arguments that are enumerated types
9 * -- small structure arguments ( <= 64 bits )
10 * -- stored in registers
11 * -- stored on the stack
12 * -- large structure arguments ( > 64 bits )
13 * -- stored in registers
14 * -- stored on the stack
16 * -- caller is a leaf routine :
17 * -- use the call command from within an init routine (i.e.
18 * init_bit_flags, init_bit_flags_combo, init_array_rep)
19 * -- caller doesn't have enough space for all the function arguments :
20 * -- call print_long_arg_list from inside print_small_structs
21 ***************************************************************************/
23 /* Some enumerated types -- used to test that the structureal data type is
24 * retrieved for function arguments with typedef data types.
48 /* A large structure (> 64 bits) used to test passing large structures as
52 struct array_rep_info_t
{
58 /*****************************************************************************
59 * Small structures ( <= 64 bits). These are used to test passing small
60 * structures as parameters and test argument size promotion.
61 *****************************************************************************/
65 struct small_rep_info_t
{
70 /* 6 bits : really fits in 8 bits and is promoted to 32 bits
81 /* 22 bits : really fits in 40 bits and is promoted to 64 bits
83 struct bit_flags_combo_t
{
102 struct two_floats_t
{
107 /* 16 bits : promoted to 32 bits
114 /* 24 bits : promoted to 32 bits
116 struct three_char_t
{
122 /* 40 bits : promoted to 64 bits
132 /* 40 bits : promoted to 64 bits
134 struct int_char_combo_t
{
139 /*****************************************************************
140 * PRINT_STUDENT_ID_SHIRT_COLOR :
141 * IN id_int student -- enumerated type
142 * IN colors shirt -- enumerated type
143 *****************************************************************/
144 void print_student_id_shirt_color (id_int student
, colors shirt
)
147 printf("student id : %d\t", student
);
148 printf("shirt color : ");
150 case BLACK
: printf("BLACK\n");
152 case BLUE
: printf("BLUE\n");
154 case BROWN
: printf("BROWN\n");
156 case ECRUE
: printf("ECRUE\n");
158 case GOLD
: printf("GOLD\n");
160 case GRAY
: printf("GRAY\n");
162 case GREEN
: printf("GREEN\n");
164 case IVORY
: printf("IVORY\n");
166 case MAUVE
: printf("MAUVE\n");
168 case ORANGE
: printf("ORANGE\n");
170 case PINK
: printf("PINK\n");
172 case PURPLE
: printf("PURPLE\n");
174 case RED
: printf("RED\n");
176 case SILVER
: printf("SILVER\n");
178 case TAN
: printf("TAN\n");
180 case VIOLET
: printf("VIOLET\n");
182 case WHITE
: printf("WHITE\n");
184 case YELLOW
: printf("YELLOW\n");
189 /*****************************************************************
191 * IN char array_c[] -- character array
192 *****************************************************************/
193 void print_char_array (char array_c
[])
198 printf("array_c :\n");
199 printf("=========\n\n");
200 for (index
= 0; index
< 120; index
++) {
201 printf("%1c", array_c
[index
]);
202 if ((index
%50) == 0) printf("\n");
207 /*****************************************************************
208 * PRINT_DOUBLE_ARRAY :
209 * IN double array_d[] -- array of doubles
210 *****************************************************************/
211 void print_double_array (double array_d
[])
216 printf("array_d :\n");
217 printf("=========\n\n");
218 for (index
= 0; index
< 9; index
++) {
219 printf("%f ", array_d
[index
]);
220 if ((index
%8) == 0) printf("\n");
225 /*****************************************************************
227 * IN float array_f[] -- array of floats
228 *****************************************************************/
229 void print_float_array (float array_f
[])
234 printf("array_f :\n");
235 printf("=========\n\n");
236 for (index
= 0; index
< 15; index
++) {
237 printf("%f ", array_f
[index
]);
238 if ((index
%8) == 0) printf("\n");
244 /*****************************************************************
246 * IN int array_i[] -- array of integers
247 *****************************************************************/
248 void print_int_array (int array_i
[])
253 printf("array_i :\n");
254 printf("=========\n\n");
255 for (index
= 0; index
< 50; index
++) {
256 printf("%d ", array_i
[index
]);
257 if ((index
%8) == 0) printf("\n");
263 /*****************************************************************
265 * IN int array_i[] -- array of integers
266 * IN char array_c[] -- array of characters
267 * IN float array_f[] -- array of floats
268 * IN double array_d[] -- array of doubles
269 *****************************************************************/
270 void print_all_arrays(int array_i
[], char array_c
[], float array_f
[], double array_d
[])
272 print_int_array(array_i
); /* -step1- */
273 print_char_array(array_c
); /* -next1- */
274 print_float_array(array_f
);
275 print_double_array(array_d
);
278 /*****************************************************************
280 * A do nothing function. Used to provide a point at which calls can be made.
281 *****************************************************************/
286 for (index
=0; index
<4; index
++);
289 /*****************************************************************
290 * COMPUTE_WITH_SMALL_STRUCTS :
291 * A do nothing function. Used to provide a point at which calls can be made.
293 *****************************************************************/
294 void compute_with_small_structs (int seed
)
297 struct small_rep_info_t array
[4];
300 for (index
= 0; index
< 4; index
++) {
301 array
[index
].value
= index
*seed
;
302 array
[index
].head
= (index
+1)*seed
;
305 for (index
= 1; index
< 4; index
++) {
306 array
[index
].value
= array
[index
].value
+ array
[index
-1].value
;
307 array
[index
].head
= array
[index
].head
+ array
[index
-1].head
;
311 /*****************************************************************
313 * Initializes a bit_flags_t structure. Can call this function see
314 * the call command behavior when integer arguments do not fit into
315 * registers and must be placed on the stack.
316 * OUT struct bit_flags_t *bit_flags -- structure to be filled
317 * IN unsigned a -- 0 or 1
318 * IN unsigned b -- 0 or 1
319 * IN unsigned g -- 0 or 1
320 * IN unsigned d -- 0 or 1
321 * IN unsigned e -- 0 or 1
322 * IN unsigned o -- 0 or 1
323 *****************************************************************/
324 void init_bit_flags (struct bit_flags_t
*bit_flags
, unsigned a
, unsigned b
, unsigned g
, unsigned d
, unsigned e
, unsigned o
)
327 bit_flags
->alpha
= a
;
329 bit_flags
->gamma
= g
;
330 bit_flags
->delta
= d
;
331 bit_flags
->epsilon
= e
;
332 bit_flags
->omega
= o
;
335 /*****************************************************************
336 * INIT_BIT_FLAGS_COMBO :
337 * Initializes a bit_flags_combo_t structure. Can call this function
338 * to see the call command behavior when integer and character arguments
339 * do not fit into registers and must be placed on the stack.
340 * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
341 * IN unsigned a -- 0 or 1
342 * IN unsigned b -- 0 or 1
344 * IN unsigned g -- 0 or 1
345 * IN unsigned d -- 0 or 1
347 * IN unsigned e -- 0 or 1
348 * IN unsigned o -- 0 or 1
349 *****************************************************************/
350 void init_bit_flags_combo (struct bit_flags_combo_t
*bit_flags_combo
, unsigned a
, unsigned b
, char ch1
, unsigned g
, unsigned d
, char ch2
, unsigned e
, unsigned o
)
353 bit_flags_combo
->alpha
= a
; /* -step3- */
354 bit_flags_combo
->beta
= b
;
355 bit_flags_combo
->ch1
= ch1
;
356 bit_flags_combo
->gamma
= g
;
357 bit_flags_combo
->delta
= d
;
358 bit_flags_combo
->ch2
= ch2
;
359 bit_flags_combo
->epsilon
= e
;
360 bit_flags_combo
->omega
= o
;
364 /*****************************************************************
366 * OUT struct one_double_t *one_double -- structure to fill
368 *****************************************************************/
369 void init_one_double (struct one_double_t
*one_double
, double init_val
)
372 one_double
->double1
= init_val
;
375 /*****************************************************************
377 * OUT struct two_floats_t *two_floats -- structure to be filled
380 *****************************************************************/
381 void init_two_floats (struct two_floats_t
*two_floats
, float init_val1
, float init_val2
)
383 two_floats
->float1
= init_val1
;
384 two_floats
->float2
= init_val2
;
387 /*****************************************************************
389 * OUT struct two_char_t *two_char -- structure to be filled
392 *****************************************************************/
393 void init_two_chars (struct two_char_t
*two_char
, char init_val1
, char init_val2
)
396 two_char
->ch1
= init_val1
;
397 two_char
->ch2
= init_val2
;
400 /*****************************************************************
402 * OUT struct three_char_t *three_char -- structure to be filled
406 *****************************************************************/
407 void init_three_chars (struct three_char_t
*three_char
, char init_val1
, char init_val2
, char init_val3
)
410 three_char
->ch1
= init_val1
;
411 three_char
->ch2
= init_val2
;
412 three_char
->ch3
= init_val3
;
415 /*****************************************************************
417 * OUT struct five_char_t *five_char -- structure to be filled
423 *****************************************************************/
424 void init_five_chars (struct five_char_t
*five_char
, char init_val1
, char init_val2
, char init_val3
, char init_val4
, char init_val5
)
426 five_char
->ch1
= init_val1
;
427 five_char
->ch2
= init_val2
;
428 five_char
->ch3
= init_val3
;
429 five_char
->ch4
= init_val4
;
430 five_char
->ch5
= init_val5
;
433 /*****************************************************************
434 * INIT_INT_CHAR_COMBO :
435 * OUT struct int_char_combo_t *combo -- structure to be filled
438 *****************************************************************/
439 void init_int_char_combo (struct int_char_combo_t
*combo
, int init_val1
, char init_val2
)
442 combo
->int1
= init_val1
;
443 combo
->ch1
= init_val2
;
446 /*****************************************************************
448 * OUT struct small_rep_into_t *small_struct -- structure to be filled
450 *****************************************************************/
451 void init_struct_rep(struct small_rep_info_t
*small_struct
, int seed
)
454 small_struct
->value
= 2 + (seed
*2);
455 small_struct
->head
= 0;
458 /*****************************************************************
459 * INIT_SMALL_STRUCTS :
460 * Takes all the small structures as input and calls the appropriate
461 * initialization routine for each structure
462 *****************************************************************/
463 void init_small_structs (
464 struct small_rep_info_t
*struct1
,
465 struct small_rep_info_t
*struct2
,
466 struct small_rep_info_t
*struct3
,
467 struct small_rep_info_t
*struct4
,
468 struct bit_flags_t
*flags
,
469 struct bit_flags_combo_t
*flags_combo
,
470 struct three_char_t
*three_char
,
471 struct five_char_t
*five_char
,
472 struct int_char_combo_t
*int_char_combo
,
473 struct one_double_t
*d1
,
474 struct one_double_t
*d2
,
475 struct one_double_t
*d3
,
476 struct two_floats_t
*f1
,
477 struct two_floats_t
*f2
,
478 struct two_floats_t
*f3
)
481 init_bit_flags(flags
, (unsigned)1, (unsigned)0, (unsigned)1,
482 (unsigned)0, (unsigned)1, (unsigned)0 );
483 init_bit_flags_combo(flags_combo
, (unsigned)1, (unsigned)0, 'y',
484 (unsigned)1, (unsigned)0, 'n',
485 (unsigned)1, (unsigned)0 );
486 init_three_chars(three_char
, 'a', 'b', 'c');
487 init_five_chars(five_char
, 'l', 'm', 'n', 'o', 'p');
488 init_int_char_combo(int_char_combo
, 123, 'z');
489 init_struct_rep(struct1
, 2);
490 init_struct_rep(struct2
, 4);
491 init_struct_rep(struct3
, 5);
492 init_struct_rep(struct4
, 6);
493 init_one_double ( d1
, 10.5);
494 init_one_double ( d2
, -3.375);
495 init_one_double ( d3
, 675.09375);
496 init_two_floats ( f1
, 45.234, 43.6);
497 init_two_floats ( f2
, 78.01, 122.10);
498 init_two_floats ( f3
, -1232.345, -199.21);
501 /*****************************************************************
502 * PRINT_TEN_DOUBLES :
503 * ?????????????????????????????
504 ****************************************************************/
505 void print_ten_doubles (
518 printf("Two Doubles : %f\t%f\n", d1
, d2
);
519 printf("Two Doubles : %f\t%f\n", d3
, d4
);
520 printf("Two Doubles : %f\t%f\n", d5
, d6
);
521 printf("Two Doubles : %f\t%f\n", d7
, d8
);
522 printf("Two Doubles : %f\t%f\n", d9
, d10
);
525 /*****************************************************************
527 * IN struct bit_flags_t bit_flags
528 ****************************************************************/
529 void print_bit_flags (struct bit_flags_t bit_flags
)
532 if (bit_flags
.alpha
) printf("alpha\n");
533 if (bit_flags
.beta
) printf("beta\n");
534 if (bit_flags
.gamma
) printf("gamma\n");
535 if (bit_flags
.delta
) printf("delta\n");
536 if (bit_flags
.epsilon
) printf("epsilon\n");
537 if (bit_flags
.omega
) printf("omega\n");
540 /*****************************************************************
541 * PRINT_BIT_FLAGS_COMBO :
542 * IN struct bit_flags_combo_t bit_flags_combo
543 ****************************************************************/
544 void print_bit_flags_combo (struct bit_flags_combo_t bit_flags_combo
)
547 if (bit_flags_combo
.alpha
) printf("alpha\n");
548 if (bit_flags_combo
.beta
) printf("beta\n");
549 if (bit_flags_combo
.gamma
) printf("gamma\n");
550 if (bit_flags_combo
.delta
) printf("delta\n");
551 if (bit_flags_combo
.epsilon
) printf("epsilon\n");
552 if (bit_flags_combo
.omega
) printf("omega\n");
553 printf("ch1: %c\tch2: %c\n", bit_flags_combo
.ch1
, bit_flags_combo
.ch2
);
556 /*****************************************************************
558 * IN struct one_double_t one_double
559 ****************************************************************/
560 void print_one_double (struct one_double_t one_double
)
563 printf("Contents of one_double_t: \n\n");
564 printf("%f\n", one_double
.double1
);
567 /*****************************************************************
569 * IN struct two_floats_t two_floats
570 ****************************************************************/
571 void print_two_floats (struct two_floats_t two_floats
)
574 printf("Contents of two_floats_t: \n\n");
575 printf("%f\t%f\n", two_floats
.float1
, two_floats
.float2
);
578 /*****************************************************************
580 * IN struct two_char_t two_char
581 ****************************************************************/
582 void print_two_chars (struct two_char_t two_char
)
585 printf("Contents of two_char_t: \n\n");
586 printf("%c\t%c\n", two_char
.ch1
, two_char
.ch2
);
589 /*****************************************************************
590 * PRINT_THREE_CHARS :
591 * IN struct three_char_t three_char
592 ****************************************************************/
593 void print_three_chars (struct three_char_t three_char
)
596 printf("Contents of three_char_t: \n\n");
597 printf("%c\t%c\t%c\n", three_char
.ch1
, three_char
.ch2
, three_char
.ch3
);
600 /*****************************************************************
602 * IN struct five_char_t five_char
603 ****************************************************************/
604 void print_five_chars (struct five_char_t five_char
)
607 printf("Contents of five_char_t: \n\n");
608 printf("%c\t%c\t%c\t%c\t%c\n", five_char
.ch1
, five_char
.ch2
,
609 five_char
.ch3
, five_char
.ch4
,
613 /*****************************************************************
614 * PRINT_INT_CHAR_COMBO :
615 * IN struct int_char_combo_t int_char_combo
616 ****************************************************************/
617 void print_int_char_combo (struct int_char_combo_t int_char_combo
)
620 printf("Contents of int_char_combo_t: \n\n");
621 printf("%d\t%c\n", int_char_combo
.int1
, int_char_combo
.ch1
);
624 /*****************************************************************
626 * The last parameter must go onto the stack rather than into a register.
627 * This is a good function to call to test small structures.
628 * IN struct small_rep_info_t struct1
629 * IN struct small_rep_info_t struct2
630 * IN struct small_rep_info_t struct3
631 ****************************************************************/
632 void print_struct_rep(
633 struct small_rep_info_t struct1
,
634 struct small_rep_info_t struct2
,
635 struct small_rep_info_t struct3
)
639 printf("Contents of struct1: \n\n");
640 printf("%10d%10d\n", struct1
.value
, struct1
.head
);
641 printf("Contents of struct2: \n\n");
642 printf("%10d%10d\n", struct2
.value
, struct2
.head
);
643 printf("Contents of struct3: \n\n");
644 printf("%10d%10d\n", struct3
.value
, struct3
.head
);
648 /*****************************************************************
650 * The last two parameters must go onto the stack rather than into a register.
651 * This is a good function to call to test small structures.
652 * IN struct small_rep_info_t struct1
653 * IN struct small_rep_info_t struct2
654 * IN struct small_rep_info_t struct3
655 * IN struct small_rep_info_t struct4
656 ****************************************************************/
657 void sum_struct_print (
659 struct small_rep_info_t struct1
,
660 struct small_rep_info_t struct2
,
661 struct small_rep_info_t struct3
,
662 struct small_rep_info_t struct4
)
666 printf("Sum of the 4 struct values and seed : \n\n");
667 sum
= seed
+ struct1
.value
+ struct2
.value
+ struct3
.value
+ struct4
.value
;
668 printf("%10d\n", sum
);
671 /*****************************************************************
672 * PRINT_SMALL_STRUCTS :
673 * This is a good function to call to test small structures.
674 * All of the small structures of odd sizes (40 bits, 8bits, etc.)
675 * are pushed onto the stack.
676 ****************************************************************/
677 void print_small_structs (
678 struct small_rep_info_t struct1
,
679 struct small_rep_info_t struct2
,
680 struct small_rep_info_t struct3
,
681 struct small_rep_info_t struct4
,
682 struct bit_flags_t flags
,
683 struct bit_flags_combo_t flags_combo
,
684 struct three_char_t three_char
,
685 struct five_char_t five_char
,
686 struct int_char_combo_t int_char_combo
,
687 struct one_double_t d1
,
688 struct one_double_t d2
,
689 struct one_double_t d3
,
690 struct two_floats_t f1
,
691 struct two_floats_t f2
,
692 struct two_floats_t f3
)
694 print_bit_flags(flags
);
695 print_bit_flags_combo(flags_combo
);
696 print_three_chars(three_char
);
697 print_five_chars(five_char
);
698 print_int_char_combo(int_char_combo
);
699 sum_struct_print(10, struct1
, struct2
, struct3
, struct4
);
700 print_struct_rep(struct1
, struct2
, struct3
);
701 print_one_double(d1
);
702 print_one_double(d2
);
703 print_one_double(d3
);
704 print_two_floats(f1
);
705 print_two_floats(f2
);
706 print_two_floats(f3
);
709 /*****************************************************************
710 * PRINT_LONG_ARG_LIST :
711 * This is a good function to call to test small structures.
712 * The first two parameters ( the doubles ) go into registers. The
713 * remaining arguments are pushed onto the stack. Depending on where
714 * print_long_arg_list is called from, the size of the argument list
715 * may force more space to be pushed onto the stack as part of the callers
717 ****************************************************************/
718 void print_long_arg_list (
725 struct small_rep_info_t struct1
,
726 struct small_rep_info_t struct2
,
727 struct small_rep_info_t struct3
,
728 struct small_rep_info_t struct4
,
729 struct bit_flags_t flags
,
730 struct bit_flags_combo_t flags_combo
,
731 struct three_char_t three_char
,
732 struct five_char_t five_char
,
733 struct int_char_combo_t int_char_combo
,
734 struct one_double_t d1
,
735 struct one_double_t d2
,
736 struct one_double_t d3
,
737 struct two_floats_t f1
,
738 struct two_floats_t f2
,
739 struct two_floats_t f3
)
741 printf("double : %f\n", a
); /* -step2- */
742 printf("double : %f\n", b
);
743 printf("int : %d\n", c
);
744 printf("int : %d\n", d
);
745 printf("int : %d\n", e
);
746 printf("int : %d\n", f
);
747 print_small_structs( struct1
, struct2
, struct3
, struct4
, flags
, flags_combo
,
748 three_char
, five_char
, int_char_combo
, d1
, d2
, d3
,
753 void print_one_large_struct (struct array_rep_info_t linked_list1
)
756 /* printf("Contents of linked list1: \n\n");
757 printf("Element Value | Index of Next Element\n");
758 printf("-------------------------------------\n");
760 /*for (index = 0; index < 10; index++) {*/
762 printf("%10d%10d\n", linked_list1
.values
[0],
763 linked_list1
.next_index
[0]);
767 /*****************************************************************
769 * The three structure parameters should fit into registers.
770 * IN struct array_rep_info_t linked_list1
771 * IN struct array_rep_info_t linked_list2
772 * IN struct array_rep_info_t linked_list3
773 ****************************************************************/
774 void print_array_rep(
775 struct array_rep_info_t linked_list1
,
776 struct array_rep_info_t linked_list2
,
777 struct array_rep_info_t linked_list3
)
782 printf("Contents of linked list1: \n\n");
783 printf("Element Value | Index of Next Element\n");
784 printf("-------------------------------------\n");
786 for (index
= 0; index
< 10; index
++) {
788 printf("%10d%10d\n", linked_list1
.values
[index
],
789 linked_list1
.next_index
[index
]);
792 printf("Contents of linked list2: \n\n");
793 printf("Element Value | Index of Next Element\n");
794 printf("-------------------------------------\n");
796 for (index
= 0; index
< 10; index
++) {
798 printf("%10d%10d\n", linked_list2
.values
[index
],
799 linked_list2
.next_index
[index
]);
802 printf("Contents of linked list3: \n\n");
803 printf("Element Value | Index of Next Element\n");
804 printf("-------------------------------------\n");
806 for (index
= 0; index
< 10; index
++) {
808 printf("%10d%10d\n", linked_list3
.values
[index
],
809 linked_list3
.next_index
[index
]);
814 /*****************************************************************
816 * The last structure parameter must be pushed onto the stack
818 * IN struct array_rep_info_t linked_list1
819 * IN struct array_rep_info_t linked_list2
820 * IN struct array_rep_info_t linked_list3
821 * IN struct array_rep_info_t linked_list4
822 ****************************************************************/
823 void sum_array_print (
825 struct array_rep_info_t linked_list1
,
826 struct array_rep_info_t linked_list2
,
827 struct array_rep_info_t linked_list3
,
828 struct array_rep_info_t linked_list4
)
833 printf("Sum of 4 arrays, by element (add in seed as well): \n\n");
834 printf("Seed: %d\n", seed
);
835 printf("Element Index | Sum \n");
836 printf("-------------------------\n");
839 for (index
= 0; index
< 10; index
++) {
841 sum
= seed
+ linked_list1
.values
[index
] + linked_list2
.values
[index
] +
842 linked_list3
.values
[index
] + linked_list4
.values
[index
];
843 printf("%10d%10d\n", index
, sum
);
847 /*****************************************************************
849 * IN struct array_rep_info_t *linked_list
851 ****************************************************************/
853 struct array_rep_info_t
*linked_list
,
859 for (index
= 0; index
< 10; index
++) {
861 linked_list
->values
[index
] = (2*index
) + (seed
*2);
862 linked_list
->next_index
[index
] = index
+ 1;
864 linked_list
->head
= 0;
870 /* variables for array and enumerated type testing
872 static char char_array
[121];
873 static double double_array
[9];
874 static float float_array
[15];
875 static int integer_array
[50];
877 static id_int student_id
= 23;
878 static colors my_shirt
= YELLOW
;
880 /* variables for large structure testing
882 static int number
= 10;
883 static struct array_rep_info_t
*list1
;
884 static struct array_rep_info_t
*list2
;
885 static struct array_rep_info_t
*list3
;
886 static struct array_rep_info_t
*list4
;
888 /* variables for testing a very long argument list
897 /* variables for testing a small structures and a very long argument list
899 static struct small_rep_info_t
*struct1
;
900 static struct small_rep_info_t
*struct2
;
901 static struct small_rep_info_t
*struct3
;
902 static struct small_rep_info_t
*struct4
;
903 static struct bit_flags_t
*flags
;
904 static struct bit_flags_combo_t
*flags_combo
;
905 static struct three_char_t
*three_char
;
906 static struct five_char_t
*five_char
;
907 static struct int_char_combo_t
*int_char_combo
;
908 static struct one_double_t
*d1
;
909 static struct one_double_t
*d2
;
910 static struct one_double_t
*d3
;
911 static struct two_floats_t
*f1
;
912 static struct two_floats_t
*f2
;
913 static struct two_floats_t
*f3
;
917 for (index
= 0; index
< 120; index
++) {
918 if ((index
%2) == 0) char_array
[index
] = 'Z';
919 else char_array
[index
] = 'a';
921 char_array
[120] = '\0';
923 for (index
= 0; index
< 9; index
++) {
924 double_array
[index
] = index
*23.4567;
927 for (index
= 0; index
< 15; index
++) {
928 float_array
[index
] = index
/7.02;
931 for (index
= 0; index
< 50; index
++) { /* -tbreak1- */
932 integer_array
[index
] = -index
;
937 print_char_array(char_array
);
938 print_double_array(double_array
); /* -tbreak2- */
939 print_float_array(float_array
);
940 print_student_id_shirt_color(student_id
, my_shirt
);
941 print_int_array(integer_array
);
942 print_all_arrays(integer_array
, char_array
, float_array
, double_array
); /* -tbreak3- */
944 /* Allocate space for large structures
946 list1
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
947 list2
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
948 list3
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
949 list4
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
951 /* Initialize large structures
953 init_array_rep(list1
, 2);
954 init_array_rep(list2
, 4);
955 init_array_rep(list3
, 5);
956 init_array_rep(list4
, 10);
957 printf("HELLO WORLD\n");
958 printf("BYE BYE FOR NOW\n"); /* -tbreak4- */
959 printf("VERY GREEN GRASS\n"); /* -next2- */
961 /* Print large structures
963 sum_array_print(10, *list1
, *list2
, *list3
, *list4
); /* -tbreak5- */
964 print_array_rep(*list1
, *list2
, *list3
);
965 print_one_large_struct(*list1
);
967 /* Allocate space for small structures
969 struct1
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
970 struct2
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
971 struct3
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
972 struct4
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
973 flags
= (struct bit_flags_t
*)malloc(sizeof(struct bit_flags_t
));
974 flags_combo
= (struct bit_flags_combo_t
*)malloc(sizeof(struct bit_flags_combo_t
));
975 three_char
= (struct three_char_t
*)malloc(sizeof(struct three_char_t
));
976 five_char
= (struct five_char_t
*)malloc(sizeof(struct five_char_t
));
977 int_char_combo
= (struct int_char_combo_t
*)malloc(sizeof(struct int_char_combo_t
));
979 d1
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
980 d2
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
981 d3
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
983 f1
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
984 f2
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
985 f3
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
987 /* Initialize small structures
989 init_small_structs ( struct1
, struct2
, struct3
, struct4
, flags
,
990 flags_combo
, three_char
, five_char
, int_char_combo
,
991 d1
, d2
, d3
, f1
, f2
, f3
);
993 /* Print small structures
995 print_small_structs ( *struct1
, *struct2
, *struct3
, *struct4
, *flags
,
996 *flags_combo
, *three_char
, *five_char
, *int_char_combo
,
997 *d1
, *d2
, *d3
, *f1
, *f2
, *f3
);
999 /* Print a very long arg list
1003 c
= 0; /* -tbreak6- */
1008 print_long_arg_list ( a
, b
, c
, d
, e
, f
, *struct1
, *struct2
, *struct3
, *struct4
, /* -tbreak7- */
1009 *flags
, *flags_combo
, *three_char
, *five_char
, *int_char_combo
,
1010 *d1
, *d2
, *d3
, *f1
, *f2
, *f3
);
1012 /* Initialize small structures
1014 init_one_double ( d1
, 1.11111);
1015 init_one_double ( d2
, -345.34);
1016 init_one_double ( d3
, 546464.2);
1017 init_two_floats ( f1
, 0.234, 453.1);
1018 init_two_floats ( f2
, 78.345, 23.09);
1019 init_two_floats ( f3
, -2.345, 1.0);
1020 init_bit_flags(flags
, (unsigned)1, (unsigned)0, (unsigned)1,
1021 (unsigned)0, (unsigned)1, (unsigned)0 );
1022 init_bit_flags_combo(flags_combo
, (unsigned)1, (unsigned)0, 'y', /* -tbreak8- */
1023 (unsigned)1, (unsigned)0, 'n',
1024 (unsigned)1, (unsigned)0 );
1025 init_three_chars(three_char
, 'x', 'y', 'z');
1026 init_five_chars(five_char
, 'h', 'e', 'l', 'l', 'o');
1027 init_int_char_combo(int_char_combo
, 13, '!'); /* -tbreak9- */
1028 init_struct_rep(struct1
, 10);
1029 init_struct_rep(struct2
, 20);
1030 init_struct_rep(struct3
, 30);
1031 init_struct_rep(struct4
, 40);
1033 compute_with_small_structs(35); /* -tbreak10- */
1035 printf("HELLO WORLD\n");
1036 printf("BYE BYE FOR NOW\n");
1037 printf("VERY GREEN GRASS\n");
1039 /* Print small structures
1041 print_one_double(*d1
);
1042 print_one_double(*d2
);
1043 print_one_double(*d3
);
1044 print_two_floats(*f1
);
1045 print_two_floats(*f2
);
1046 print_two_floats(*f3
);
1047 print_bit_flags(*flags
);
1048 print_bit_flags_combo(*flags_combo
);
1049 print_three_chars(*three_char
);
1050 print_five_chars(*five_char
);
1051 print_int_char_combo(*int_char_combo
);
1052 sum_struct_print(10, *struct1
, *struct2
, *struct3
, *struct4
);
1053 print_struct_rep(*struct1
, *struct2
, *struct3
);