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 ( student
, shirt
)
149 printf("student id : %d\t", student
);
150 printf("shirt color : ");
152 case BLACK
: printf("BLACK\n");
154 case BLUE
: printf("BLUE\n");
156 case BROWN
: printf("BROWN\n");
158 case ECRUE
: printf("ECRUE\n");
160 case GOLD
: printf("GOLD\n");
162 case GRAY
: printf("GRAY\n");
164 case GREEN
: printf("GREEN\n");
166 case IVORY
: printf("IVORY\n");
168 case MAUVE
: printf("MAUVE\n");
170 case ORANGE
: printf("ORANGE\n");
172 case PINK
: printf("PINK\n");
174 case PURPLE
: printf("PURPLE\n");
176 case RED
: printf("RED\n");
178 case SILVER
: printf("SILVER\n");
180 case TAN
: printf("TAN\n");
182 case VIOLET
: printf("VIOLET\n");
184 case WHITE
: printf("WHITE\n");
186 case YELLOW
: printf("YELLOW\n");
191 /*****************************************************************
193 * IN char array_c[] -- character array
194 *****************************************************************/
195 void print_char_array ( array_c
)
202 printf("array_c :\n");
203 printf("=========\n\n");
204 for (index
= 0; index
< 120; index
++) {
205 printf("%1c", array_c
[index
]);
206 if ((index
%50) == 0) printf("\n");
211 /*****************************************************************
212 * PRINT_DOUBLE_ARRAY :
213 * IN double array_d[] -- array of doubles
214 *****************************************************************/
215 void print_double_array (array_d
)
222 printf("array_d :\n");
223 printf("=========\n\n");
224 for (index
= 0; index
< 100; index
++) {
225 printf("%f ", array_d
[index
]);
226 if ((index
%8) == 0) printf("\n");
231 /*****************************************************************
233 * IN float array_f[] -- array of floats
234 *****************************************************************/
235 void print_float_array ( array_f
)
242 printf("array_f :\n");
243 printf("=========\n\n");
244 for (index
= 0; index
< 15; index
++) {
245 printf("%f ", array_f
[index
]);
246 if ((index
%8) == 0) printf("\n");
252 /*****************************************************************
254 * IN int array_i[] -- array of integers
255 *****************************************************************/
256 void print_int_array ( array_i
)
263 printf("array_i :\n");
264 printf("=========\n\n");
265 for (index
= 0; index
< 50; index
++) {
266 printf("%d ", array_i
[index
]);
267 if ((index
%8) == 0) printf("\n");
273 /*****************************************************************
275 * IN int array_i[] -- array of integers
276 * IN char array_c[] -- array of characters
277 * IN float array_f[] -- array of floats
278 * IN double array_d[] -- array of doubles
279 *****************************************************************/
280 void print_all_arrays( array_i
, array_c
, array_f
, array_d
)
287 print_int_array(array_i
);
288 print_char_array(array_c
);
289 print_float_array(array_f
);
290 print_double_array(array_d
);
293 /*****************************************************************
295 * A do nothing function. Used to provide a point at which calls can be made.
296 *****************************************************************/
301 for (index
=0; index
<4; index
++);
304 /*****************************************************************
305 * COMPUTE_WITH_SMALL_STRUCTS :
306 * A do nothing function. Used to provide a point at which calls can be made.
308 *****************************************************************/
309 void compute_with_small_structs ( seed
)
313 struct small_rep_info_t array
[4];
316 for (index
= 0; index
< 4; index
++) {
317 array
[index
].value
= index
*seed
;
318 array
[index
].head
= (index
+1)*seed
;
321 for (index
= 1; index
< 4; index
++) {
322 array
[index
].value
= array
[index
].value
+ array
[index
-1].value
;
323 array
[index
].head
= array
[index
].head
+ array
[index
-1].head
;
327 /*****************************************************************
329 * Initializes a bit_flags_t structure. Can call this function see
330 * the call command behavior when integer arguments do not fit into
331 * registers and must be placed on the stack.
332 * OUT struct bit_flags_t *bit_flags -- structure to be filled
333 * IN unsigned a -- 0 or 1
334 * IN unsigned b -- 0 or 1
335 * IN unsigned g -- 0 or 1
336 * IN unsigned d -- 0 or 1
337 * IN unsigned e -- 0 or 1
338 * IN unsigned o -- 0 or 1
339 *****************************************************************/
340 void init_bit_flags ( bit_flags
, a
, b
, g
, d
, e
, o
)
341 struct bit_flags_t
*bit_flags
;
350 bit_flags
->alpha
= a
;
352 bit_flags
->gamma
= g
;
353 bit_flags
->delta
= d
;
354 bit_flags
->epsilon
= e
;
355 bit_flags
->omega
= o
;
358 /*****************************************************************
359 * INIT_BIT_FLAGS_COMBO :
360 * Initializes a bit_flags_combo_t structure. Can call this function
361 * to see the call command behavior when integer and character arguments
362 * do not fit into registers and must be placed on the stack.
363 * OUT struct bit_flags_combo_t *bit_flags_combo -- structure to fill
364 * IN unsigned a -- 0 or 1
365 * IN unsigned b -- 0 or 1
367 * IN unsigned g -- 0 or 1
368 * IN unsigned d -- 0 or 1
370 * IN unsigned e -- 0 or 1
371 * IN unsigned o -- 0 or 1
372 *****************************************************************/
373 void init_bit_flags_combo ( bit_flags_combo
, a
, b
, ch1
, g
, d
, ch2
, e
, o
)
374 struct bit_flags_combo_t
*bit_flags_combo
;
385 bit_flags_combo
->alpha
= a
;
386 bit_flags_combo
->beta
= b
;
387 bit_flags_combo
->ch1
= ch1
;
388 bit_flags_combo
->gamma
= g
;
389 bit_flags_combo
->delta
= d
;
390 bit_flags_combo
->ch2
= ch2
;
391 bit_flags_combo
->epsilon
= e
;
392 bit_flags_combo
->omega
= o
;
396 /*****************************************************************
398 * OUT struct one_double_t *one_double -- structure to fill
400 *****************************************************************/
401 void init_one_double ( one_double
, init_val
)
402 struct one_double_t
*one_double
;
406 one_double
->double1
= init_val
;
409 /*****************************************************************
411 * OUT struct two_floats_t *two_floats -- structure to be filled
414 *****************************************************************/
415 void init_two_floats ( two_floats
, init_val1
, init_val2
)
416 struct two_floats_t
*two_floats
;
420 two_floats
->float1
= init_val1
;
421 two_floats
->float2
= init_val2
;
424 /*****************************************************************
426 * OUT struct two_char_t *two_char -- structure to be filled
429 *****************************************************************/
430 void init_two_chars ( two_char
, init_val1
, init_val2
)
431 struct two_char_t
*two_char
;
436 two_char
->ch1
= init_val1
;
437 two_char
->ch2
= init_val2
;
440 /*****************************************************************
442 * OUT struct three_char_t *three_char -- structure to be filled
446 *****************************************************************/
447 void init_three_chars ( three_char
, init_val1
, init_val2
, init_val3
)
448 struct three_char_t
*three_char
;
454 three_char
->ch1
= init_val1
;
455 three_char
->ch2
= init_val2
;
456 three_char
->ch3
= init_val3
;
459 /*****************************************************************
461 * OUT struct five_char_t *five_char -- structure to be filled
467 *****************************************************************/
468 void init_five_chars ( five_char
, init_val1
, init_val2
, init_val3
,init_val4
,init_val5
)
469 struct five_char_t
*five_char
;
476 five_char
->ch1
= init_val1
;
477 five_char
->ch2
= init_val2
;
478 five_char
->ch3
= init_val3
;
479 five_char
->ch4
= init_val4
;
480 five_char
->ch5
= init_val5
;
483 /*****************************************************************
484 * INIT_INT_CHAR_COMBO :
485 * OUT struct int_char_combo_t *combo -- structure to be filled
488 *****************************************************************/
489 void init_int_char_combo ( combo
, init_val1
, init_val2
)
490 struct int_char_combo_t
*combo
;
495 combo
->int1
= init_val1
;
496 combo
->ch1
= init_val2
;
499 /*****************************************************************
501 * OUT struct small_rep_into_t *small_struct -- structure to be filled
503 *****************************************************************/
504 void init_struct_rep( small_struct
, seed
)
505 struct small_rep_info_t
*small_struct
;
510 small_struct
->value
= 2 + (seed
*2);
511 small_struct
->head
= 0;
514 /*****************************************************************
515 * INIT_SMALL_STRUCTS :
516 * Takes all the small structures as input and calls the appropriate
517 * initialization routine for each structure
518 *****************************************************************/
519 void init_small_structs (struct1
, struct2
, struct3
,struct4
,flags
,flags_combo
,
520 three_char
, five_char
,int_char_combo
, d1
, d2
,d3
,f1
,f2
,f3
)
521 struct small_rep_info_t
*struct1
;
522 struct small_rep_info_t
*struct2
;
523 struct small_rep_info_t
*struct3
;
524 struct small_rep_info_t
*struct4
;
525 struct bit_flags_t
*flags
;
526 struct bit_flags_combo_t
*flags_combo
;
527 struct three_char_t
*three_char
;
528 struct five_char_t
*five_char
;
529 struct int_char_combo_t
*int_char_combo
;
530 struct one_double_t
*d1
;
531 struct one_double_t
*d2
;
532 struct one_double_t
*d3
;
533 struct two_floats_t
*f1
;
534 struct two_floats_t
*f2
;
535 struct two_floats_t
*f3
;
539 init_bit_flags(flags
, (unsigned)1, (unsigned)0, (unsigned)1,
540 (unsigned)0, (unsigned)1, (unsigned)0 );
541 init_bit_flags_combo(flags_combo
, (unsigned)1, (unsigned)0, 'y',
542 (unsigned)1, (unsigned)0, 'n',
543 (unsigned)1, (unsigned)0 );
544 init_three_chars(three_char
, 'a', 'b', 'c');
545 init_five_chars(five_char
, 'l', 'm', 'n', 'o', 'p');
546 init_int_char_combo(int_char_combo
, 123, 'z');
547 init_struct_rep(struct1
, 2);
548 init_struct_rep(struct2
, 4);
549 init_struct_rep(struct3
, 5);
550 init_struct_rep(struct4
, 6);
551 init_one_double ( d1
, 10.5);
552 init_one_double ( d2
, -3.34);
553 init_one_double ( d3
, 675.09123);
554 init_two_floats ( f1
, 45.234, 43.6);
555 init_two_floats ( f2
, 78.01, 122.10);
556 init_two_floats ( f3
, -1232.345, -199.21);
559 /*****************************************************************
560 * PRINT_TEN_DOUBLES :
561 * ?????????????????????????????
562 ****************************************************************/
563 void print_ten_doubles ( d1
, d2
, d3
, d4
, d5
, d6
, d7
, d8
, d9
, d10
)
576 printf("Two Doubles : %f\t%f\n", d1
, d2
);
577 printf("Two Doubles : %f\t%f\n", d3
, d4
);
578 printf("Two Doubles : %f\t%f\n", d5
, d6
);
579 printf("Two Doubles : %f\t%f\n", d7
, d8
);
580 printf("Two Doubles : %f\t%f\n", d9
, d10
);
583 /*****************************************************************
585 * IN struct bit_flags_t bit_flags
586 ****************************************************************/
587 void print_bit_flags ( bit_flags
)
588 struct bit_flags_t bit_flags
;
591 if (bit_flags
.alpha
) printf("alpha\n");
592 if (bit_flags
.beta
) printf("beta\n");
593 if (bit_flags
.gamma
) printf("gamma\n");
594 if (bit_flags
.delta
) printf("delta\n");
595 if (bit_flags
.epsilon
) printf("epsilon\n");
596 if (bit_flags
.omega
) printf("omega\n");
599 /*****************************************************************
600 * PRINT_BIT_FLAGS_COMBO :
601 * IN struct bit_flags_combo_t bit_flags_combo
602 ****************************************************************/
603 void print_bit_flags_combo ( bit_flags_combo
)
604 struct bit_flags_combo_t bit_flags_combo
;
607 if (bit_flags_combo
.alpha
) printf("alpha\n");
608 if (bit_flags_combo
.beta
) printf("beta\n");
609 if (bit_flags_combo
.gamma
) printf("gamma\n");
610 if (bit_flags_combo
.delta
) printf("delta\n");
611 if (bit_flags_combo
.epsilon
) printf("epsilon\n");
612 if (bit_flags_combo
.omega
) printf("omega\n");
613 printf("ch1: %c\tch2: %c\n", bit_flags_combo
.ch1
, bit_flags_combo
.ch2
);
616 /*****************************************************************
618 * IN struct one_double_t one_double
619 ****************************************************************/
620 void print_one_double ( one_double
)
621 struct one_double_t one_double
;
624 printf("Contents of one_double_t: \n\n");
625 printf("%f\n", one_double
.double1
);
628 /*****************************************************************
630 * IN struct two_floats_t two_floats
631 ****************************************************************/
632 void print_two_floats ( two_floats
)
633 struct two_floats_t two_floats
;
636 printf("Contents of two_floats_t: \n\n");
637 printf("%f\t%f\n", two_floats
.float1
, two_floats
.float2
);
640 /*****************************************************************
642 * IN struct two_char_t two_char
643 ****************************************************************/
644 void print_two_chars ( two_char
)
645 struct two_char_t two_char
;
648 printf("Contents of two_char_t: \n\n");
649 printf("%c\t%c\n", two_char
.ch1
, two_char
.ch2
);
652 /*****************************************************************
653 * PRINT_THREE_CHARS :
654 * IN struct three_char_t three_char
655 ****************************************************************/
656 void print_three_chars ( three_char
)
657 struct three_char_t three_char
;
660 printf("Contents of three_char_t: \n\n");
661 printf("%c\t%c\t%c\n", three_char
.ch1
, three_char
.ch2
, three_char
.ch3
);
664 /*****************************************************************
666 * IN struct five_char_t five_char
667 ****************************************************************/
668 void print_five_chars ( five_char
)
669 struct five_char_t five_char
;
672 printf("Contents of five_char_t: \n\n");
673 printf("%c\t%c\t%c\t%c\t%c\n", five_char
.ch1
, five_char
.ch2
,
674 five_char
.ch3
, five_char
.ch4
,
678 /*****************************************************************
679 * PRINT_INT_CHAR_COMBO :
680 * IN struct int_char_combo_t int_char_combo
681 ****************************************************************/
682 void print_int_char_combo ( int_char_combo
)
683 struct int_char_combo_t int_char_combo
;
686 printf("Contents of int_char_combo_t: \n\n");
687 printf("%d\t%c\n", int_char_combo
.int1
, int_char_combo
.ch1
);
690 /*****************************************************************
692 * The last parameter must go onto the stack rather than into a register.
693 * This is a good function to call to test small structures.
694 * IN struct small_rep_info_t struct1
695 * IN struct small_rep_info_t struct2
696 * IN struct small_rep_info_t struct3
697 ****************************************************************/
698 void print_struct_rep( struct1
, struct2
, struct3
)
699 struct small_rep_info_t struct1
;
700 struct small_rep_info_t struct2
;
701 struct small_rep_info_t struct3
;
706 printf("Contents of struct1: \n\n");
707 printf("%10d%10d\n", struct1
.value
, struct1
.head
);
708 printf("Contents of struct2: \n\n");
709 printf("%10d%10d\n", struct2
.value
, struct2
.head
);
710 printf("Contents of struct3: \n\n");
711 printf("%10d%10d\n", struct3
.value
, struct3
.head
);
715 /*****************************************************************
717 * The last two parameters must go onto the stack rather than into a register.
718 * This is a good function to call to test small structures.
719 * IN struct small_rep_info_t struct1
720 * IN struct small_rep_info_t struct2
721 * IN struct small_rep_info_t struct3
722 * IN struct small_rep_info_t struct4
723 ****************************************************************/
724 void sum_struct_print ( seed
, struct1
, struct2
, struct3
, struct4
)
726 struct small_rep_info_t struct1
;
727 struct small_rep_info_t struct2
;
728 struct small_rep_info_t struct3
;
729 struct small_rep_info_t struct4
;
734 printf("Sum of the 4 struct values and seed : \n\n");
735 sum
= seed
+ struct1
.value
+ struct2
.value
+ struct3
.value
+ struct4
.value
;
736 printf("%10d\n", sum
);
739 /*****************************************************************
740 * PRINT_SMALL_STRUCTS :
741 * This is a good function to call to test small structures.
742 * All of the small structures of odd sizes (40 bits, 8bits, etc.)
743 * are pushed onto the stack.
744 ****************************************************************/
745 void print_small_structs ( struct1
, struct2
, struct3
, struct4
, flags
,
746 flags_combo
, three_char
, five_char
, int_char_combo
, d1
, d2
,d3
,f1
,f2
,f3
)
747 struct small_rep_info_t struct1
;
748 struct small_rep_info_t struct2
;
749 struct small_rep_info_t struct3
;
750 struct small_rep_info_t struct4
;
751 struct bit_flags_t flags
;
752 struct bit_flags_combo_t flags_combo
;
753 struct three_char_t three_char
;
754 struct five_char_t five_char
;
755 struct int_char_combo_t int_char_combo
;
756 struct one_double_t d1
;
757 struct one_double_t d2
;
758 struct one_double_t d3
;
759 struct two_floats_t f1
;
760 struct two_floats_t f2
;
761 struct two_floats_t f3
;
763 print_bit_flags(flags
);
764 print_bit_flags_combo(flags_combo
);
765 print_three_chars(three_char
);
766 print_five_chars(five_char
);
767 print_int_char_combo(int_char_combo
);
768 sum_struct_print(10, struct1
, struct2
, struct3
, struct4
);
769 print_struct_rep(struct1
, struct2
, struct3
);
770 print_one_double(d1
);
771 print_one_double(d2
);
772 print_one_double(d3
);
773 print_two_floats(f1
);
774 print_two_floats(f2
);
775 print_two_floats(f3
);
778 /*****************************************************************
779 * PRINT_LONG_ARG_LIST :
780 * This is a good function to call to test small structures.
781 * The first two parameters ( the doubles ) go into registers. The
782 * remaining arguments are pushed onto the stack. Depending on where
783 * print_long_arg_list is called from, the size of the argument list
784 * may force more space to be pushed onto the stack as part of the callers
786 ****************************************************************/
787 void print_long_arg_list ( a
, b
, c
, d
, e
, f
, struct1
, struct2
, struct3
,
788 struct4
, flags
, flags_combo
, three_char
, five_char
, int_char_combo
, d1
,d2
,d3
,
796 struct small_rep_info_t struct1
;
797 struct small_rep_info_t struct2
;
798 struct small_rep_info_t struct3
;
799 struct small_rep_info_t struct4
;
800 struct bit_flags_t flags
;
801 struct bit_flags_combo_t flags_combo
;
802 struct three_char_t three_char
;
803 struct five_char_t five_char
;
804 struct int_char_combo_t int_char_combo
;
805 struct one_double_t d1
;
806 struct one_double_t d2
;
807 struct one_double_t d3
;
808 struct two_floats_t f1
;
809 struct two_floats_t f2
;
810 struct two_floats_t f3
;
813 printf("double : %f\n", a
);
814 printf("double : %f\n", b
);
815 printf("int : %d\n", c
);
816 printf("int : %d\n", d
);
817 printf("int : %d\n", e
);
818 printf("int : %d\n", f
);
819 print_small_structs( struct1
, struct2
, struct3
, struct4
, flags
, flags_combo
,
820 three_char
, five_char
, int_char_combo
, d1
, d2
, d3
,
825 void print_one_large_struct( linked_list1
)
826 struct array_rep_info_t linked_list1
;
830 /* printf("Contents of linked list1: \n\n");
831 printf("Element Value | Index of Next Element\n");
832 printf("-------------------------------------\n");
834 /*for (index = 0; index < 10; index++) {*/
836 printf("%10d%10d\n", linked_list1
.values
[0],
837 linked_list1
.next_index
[0]);
841 /*****************************************************************
843 * The three structure parameters should fit into registers.
844 * IN struct array_rep_info_t linked_list1
845 * IN struct array_rep_info_t linked_list2
846 * IN struct array_rep_info_t linked_list3
847 ****************************************************************/
848 void print_array_rep( linked_list1
, linked_list2
, linked_list3
)
849 struct array_rep_info_t linked_list1
;
850 struct array_rep_info_t linked_list2
;
851 struct array_rep_info_t linked_list3
;
857 printf("Contents of linked list1: \n\n");
858 printf("Element Value | Index of Next Element\n");
859 printf("-------------------------------------\n");
861 for (index
= 0; index
< 10; index
++) {
863 printf("%10d%10d\n", linked_list1
.values
[index
],
864 linked_list1
.next_index
[index
]);
867 printf("Contents of linked list2: \n\n");
868 printf("Element Value | Index of Next Element\n");
869 printf("-------------------------------------\n");
871 for (index
= 0; index
< 10; index
++) {
873 printf("%10d%10d\n", linked_list2
.values
[index
],
874 linked_list2
.next_index
[index
]);
877 printf("Contents of linked list3: \n\n");
878 printf("Element Value | Index of Next Element\n");
879 printf("-------------------------------------\n");
881 for (index
= 0; index
< 10; index
++) {
883 printf("%10d%10d\n", linked_list3
.values
[index
],
884 linked_list3
.next_index
[index
]);
889 /*****************************************************************
891 * The last structure parameter must be pushed onto the stack
893 * IN struct array_rep_info_t linked_list1
894 * IN struct array_rep_info_t linked_list2
895 * IN struct array_rep_info_t linked_list3
896 * IN struct array_rep_info_t linked_list4
897 ****************************************************************/
898 void sum_array_print ( seed
, linked_list1
, linked_list2
, linked_list3
,linked_list4
)
900 struct array_rep_info_t linked_list1
;
901 struct array_rep_info_t linked_list2
;
902 struct array_rep_info_t linked_list3
;
903 struct array_rep_info_t linked_list4
;
909 printf("Sum of 4 arrays, by element (add in seed as well): \n\n");
910 printf("Seed: %d\n", seed
);
911 printf("Element Index | Sum \n");
912 printf("-------------------------\n");
915 for (index
= 0; index
< 10; index
++) {
917 sum
= seed
+ linked_list1
.values
[index
] + linked_list2
.values
[index
] +
918 linked_list3
.values
[index
] + linked_list4
.values
[index
];
919 printf("%10d%10d\n", index
, sum
);
923 /*****************************************************************
925 * IN struct array_rep_info_t *linked_list
927 ****************************************************************/
928 void init_array_rep( linked_list
, seed
)
929 struct array_rep_info_t
*linked_list
;
936 for (index
= 0; index
< 10; index
++) {
938 linked_list
->values
[index
] = (2*index
) + (seed
*2);
939 linked_list
->next_index
[index
] = index
+ 1;
941 linked_list
->head
= 0;
947 /* variables for array and enumerated type testing
949 char char_array
[121];
950 double double_array
[100];
951 float float_array
[15];
952 int integer_array
[50];
954 id_int student_id
= 23;
955 colors my_shirt
= YELLOW
;
957 /* variables for large structure testing
960 struct array_rep_info_t
*list1
;
961 struct array_rep_info_t
*list2
;
962 struct array_rep_info_t
*list3
;
963 struct array_rep_info_t
*list4
;
965 /* variables for testing a very long argument list
974 /* variables for testing a small structures and a very long argument list
976 struct small_rep_info_t
*struct1
;
977 struct small_rep_info_t
*struct2
;
978 struct small_rep_info_t
*struct3
;
979 struct small_rep_info_t
*struct4
;
980 struct bit_flags_t
*flags
;
981 struct bit_flags_combo_t
*flags_combo
;
982 struct three_char_t
*three_char
;
983 struct five_char_t
*five_char
;
984 struct int_char_combo_t
*int_char_combo
;
985 struct one_double_t
*d1
;
986 struct one_double_t
*d2
;
987 struct one_double_t
*d3
;
988 struct two_floats_t
*f1
;
989 struct two_floats_t
*f2
;
990 struct two_floats_t
*f3
;
994 for (index
= 0; index
< 120; index
++) {
995 if ((index
%2) == 0) char_array
[index
] = 'Z';
996 else char_array
[index
] = 'a';
997 } /* call-ar-st.exp uses line numbers everywhere */ char_array
[120] = '\0';
999 for (index
= 0; index
< 100; index
++) {
1000 double_array
[index
] = index
*23.4567;
1003 for (index
= 0; index
< 15; index
++) {
1004 float_array
[index
] = index
/7.02;
1007 for (index
= 0; index
< 50; index
++) {
1008 integer_array
[index
] = -index
;
1013 print_char_array(char_array
);
1014 print_double_array(double_array
);
1015 print_float_array(float_array
);
1016 print_student_id_shirt_color(student_id
, my_shirt
);
1017 print_int_array(integer_array
);
1018 print_all_arrays(integer_array
, char_array
, float_array
, double_array
);
1020 /* Allocate space for large structures
1022 list1
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
1023 list2
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
1024 list3
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
1025 list4
= (struct array_rep_info_t
*)malloc(sizeof(struct array_rep_info_t
));
1027 /* Initialize large structures
1029 init_array_rep(list1
, 2);
1030 init_array_rep(list2
, 4);
1031 init_array_rep(list3
, 5);
1032 init_array_rep(list4
, 10);
1033 printf("HELLO WORLD\n");
1034 printf("BYE BYE FOR NOW\n");
1035 printf("VERY GREEN GRASS\n");
1037 /* Print large structures
1039 sum_array_print(10, *list1
, *list2
, *list3
, *list4
);
1040 print_array_rep(*list1
, *list2
, *list3
);
1041 print_one_large_struct(*list1
);
1043 /* Allocate space for small structures
1045 struct1
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
1046 struct2
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
1047 struct3
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
1048 struct4
= (struct small_rep_info_t
*)malloc(sizeof(struct small_rep_info_t
));
1049 flags
= (struct bit_flags_t
*)malloc(sizeof(struct bit_flags_t
));
1050 flags_combo
= (struct bit_flags_combo_t
*)malloc(sizeof(struct bit_flags_combo_t
));
1051 three_char
= (struct three_char_t
*)malloc(sizeof(struct three_char_t
));
1052 five_char
= (struct five_char_t
*)malloc(sizeof(struct five_char_t
));
1053 int_char_combo
= (struct int_char_combo_t
*)malloc(sizeof(struct int_char_combo_t
));
1055 d1
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
1056 d2
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
1057 d3
= (struct one_double_t
*)malloc(sizeof(struct one_double_t
));
1059 f1
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
1060 f2
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
1061 f3
= (struct two_floats_t
*)malloc(sizeof(struct two_floats_t
));
1063 /* Initialize small structures
1065 init_small_structs ( struct1
, struct2
, struct3
, struct4
, flags
,
1066 flags_combo
, three_char
, five_char
, int_char_combo
,
1067 d1
, d2
, d3
, f1
, f2
, f3
);
1069 /* Print small structures
1071 print_small_structs ( *struct1
, *struct2
, *struct3
, *struct4
, *flags
,
1072 *flags_combo
, *three_char
, *five_char
, *int_char_combo
,
1073 *d1
, *d2
, *d3
, *f1
, *f2
, *f3
);
1075 /* Print a very long arg list
1084 print_long_arg_list ( a
, b
, c
, d
, e
, f
, *struct1
, *struct2
, *struct3
, *struct4
,
1085 *flags
, *flags_combo
, *three_char
, *five_char
, *int_char_combo
,
1086 *d1
, *d2
, *d3
, *f1
, *f2
, *f3
);
1088 /* Initialize small structures
1090 init_one_double ( d1
, 1.11111);
1091 init_one_double ( d2
, -345.34);
1092 init_one_double ( d3
, 546464.2);
1093 init_two_floats ( f1
, 0.234, 453.1);
1094 init_two_floats ( f2
, 78.345, 23.09);
1095 init_two_floats ( f3
, -2.345, 1.0);
1096 init_bit_flags(flags
, (unsigned)1, (unsigned)0, (unsigned)1,
1097 (unsigned)0, (unsigned)1, (unsigned)0 );
1098 init_bit_flags_combo(flags_combo
, (unsigned)1, (unsigned)0, 'y',
1099 (unsigned)1, (unsigned)0, 'n',
1100 (unsigned)1, (unsigned)0 );
1101 init_three_chars(three_char
, 'x', 'y', 'z');
1102 init_five_chars(five_char
, 'h', 'e', 'l', 'l', 'o');
1103 init_int_char_combo(int_char_combo
, 13, '!');
1104 init_struct_rep(struct1
, 10);
1105 init_struct_rep(struct2
, 20);
1106 init_struct_rep(struct3
, 30);
1107 init_struct_rep(struct4
, 40);
1109 compute_with_small_structs(35);
1111 printf("HELLO WORLD\n");
1112 printf("BYE BYE FOR NOW\n");
1113 printf("VERY GREEN GRASS\n");
1115 /* Print small structures
1117 print_one_double(*d1
);
1118 print_one_double(*d2
);
1119 print_one_double(*d3
);
1120 print_two_floats(*f1
);
1121 print_two_floats(*f2
);
1122 print_two_floats(*f3
);
1123 print_bit_flags(*flags
);
1124 print_bit_flags_combo(*flags_combo
);
1125 print_three_chars(*three_char
);
1126 print_five_chars(*five_char
);
1127 print_int_char_combo(*int_char_combo
);
1128 sum_struct_print(10, *struct1
, *struct2
, *struct3
, *struct4
);
1129 print_struct_rep(*struct1
, *struct2
, *struct3
);