/* test_list_str.c simple use of "list" functions */ /* function prototypes for functions to be written in assembly language: */ void clear(int *L); /* initialize list to empty */ void print(int *L); /* print the strings, one per line */ void push_front(int *L, char *s); /* put string s on front of list */ void push_back(int *L, char *s); /* put string s on back of list */ void pop_front(int *L); /* remove string from front of list */ void pop_back(int *L); /* remove string from back of list */ /* The assembly language program must be in a single file list.asm */ /* The following sequence of commands must run correctly on linux.gl */ /* nasm -f elf list.asm */ /* gcc -o test_list_str.c list.o */ /* test_list_str */ /* partial credit based on how far it executes before segfault or error */ int main() { int L1[2]; /* allocate space for two pointers for list L1 */ int L2[2]; /* allocate space for two pointers for list L2 */ char hello[]="Hello"; /* just a string for use later */ clear(L1); /* address of L1, space for two pointers */ print(L1); /* should print blank line */ push_back(L1,"front"); print(L1); /* 25% of project credit */ push_back(L1,"middle"); print(L1); push_back(L1,"last"); print(L1); /* 50% of project credit */ clear(L2); push_front(L2, "end"); print(L2); push_front(L2, "center"); push_front(L2, "start"); print(L2); /* 75% of project credit */ pop_front(L1); /* removes first item on list */ pop_back(L1); /* removes last item on list */ print(L1); /* 90% of project credit */ push_front(L1, hello); hello[0]='g'; hello[1]='o'; hello[2]='o'; hello[3]='d'; hello[4]=' '; push_back(L1, hello); print(L1); print(L2); /* 100% of project credit */ return 0; } /* Output of this program is: front front middle front middle last end start center end middle Hello middle good start center end */