=============================== Single Linked Lists and Quiz 15 [TOC] =============================== Implement the following C program in assembly: ---- CODE (file=session15/list/list.c, fold) ----------------------------------- #include struct ListNode { struct ListNode *next; char id; }; struct ListNode c, a, b; int printList(const struct ListNode *listNode); int main(void) { a.id = 'a'; a.next = &b; b.id = 'b'; b.next = &c; c.id = 'c'; c.next = 0; printList(&a); putchar('\n'); } int printList(const struct ListNode *listNode) { for (; listNode; listNode = listNode->next) { putchar(listNode->id); } return 1; // because we need to return something } -------------------------------------------------------------------------------- Of course the function call _putchar()_ can be realized with a _putc_ instruction. You program should generate the same output as the assmbler program created by gcc: ---- SHELL (path=session15/list) ----------------------------------------------- gcc list.c ./a.out -------------------------------------------------------------------------------- Or ucc: ---- SHELL (path=session15/list) ----------------------------------------------- ucc list.c ./a.out -------------------------------------------------------------------------------- Submit your assembly program _list.s- with: ---- CODE (type=sh) ----------------------- submit hpc quiz15 isa.txt list.s ------------------------------------------- There are no automatic tests (no message/email means your submit succeeded). Provided Material: Skeleton =========================== You can use the instruction set from Session 14 and this skeleton: :import: session15/list/list_quiz15.s [fold] In _list_quiz15.s_ the definition ---- CODE (type=c) ------------------------------------------------------------- struct ListNode c, a, b; -------------------------------------------------------------------------------- of the uninitialized global variables _a_, _b_ and _c_ in the BSS segment is already realized. Also the statement ---- CODE (type=s) ------------------------------------------------------------- a.id = 'a'; -------------------------------------------------------------------------------- is already implemented.