; list_part.asm a direct coding of list.c (list.c included as comments) ; standard function entry and exit used, not optimized ; Compile: nasm -f elf list.asm ; link: gcc -o test_list_str test_list_str.c list.o ; run: test_list_str ; list.c this or however you wish, is the functions of list.asm ; #include ; extern printf in list.asm extern printf ; static char heap[20000] ; space to store strings, do not reuse or free ; static char *hp = heap; ; pointer to next available heap space ; static int list[1000]; ; space to store list block (2 index+ pointer) ; static int lp=1; ; index to next available list space ; static char *q; ; a variable pointer ; static int i; ; a variable index section .bss heap: resb 20000 list: resd 1000 q: resd 1 ; may be just in esi i: resd 1 ; may be just in edi section .data hp: dd heap ; [hp] is pointer to next free heap lp: dd 1 fmt1: db "%s",10,0 ; "%s\n" for printf ; +-----------------+ +-----------------+ +-----------------+ ; L[0]-> | index to next----->| index to next----->| 0 | ; | 0 |<-----index to prev |<-----index to prev |<-L[1] ; | ptr to heap str | | ptr to heap str | | ptr to heap str | ; +-----------------+ +-----------------+ +-----------------+ ; The pointers to heap strings are character pointes to terminated strings. ; The "index" values couls be pointers rather than indices. ; void clear(int *L) ; initialize front and back pointers to zero ; { global clear clear: push ebp ; save ebp mov ebp, esp ; ebp is callers stack push ebx ; save registers push edi push esi ; L[0]=0; ; later, will be index into "front" of list ; L[1]=0; ; later, will be index into "back" of list mov edi,[ebp+8] ; get address of L into edi mov eax,0 ; get a 32-bit zero mov [edi],eax ; L[0]=0 mov [edi+4],eax ; L[1]=0 pop esi ; restore registers pop edi ; in reverse order pop ebx mov esp,ebp ; restore callers stack frame pop ebp ret ; return ; } ; void print(int *L) ; { global print print: ... project 2, implement the remaining "C" code ; void pop_back(int *L) ; { global pop_back pop_back: ... implement last function ; end list_part.asm file