.section .rodata
.LC0:.string "%d "
//struct node
//{
// int value;
// struct node *pre;
// struct node *next;
//}
//
//
//struct list
//{
// struct node nod;
// int count;
//}
.section .text
//void init(struct list *ls);
init:
pushl %ebp
movl %esp,%ebp
movl 8(%ebp),%eax
movl $0,(%eax)
movl %eax,4(%eax)
movl %eax,8(%eax)
movl $0,12(%eax)
movl %ebp,%esp
popl %ebp
ret
//void add(struct list *ls,int val)
add:
pushl %ebp
movl %esp,%ebp
pushl $12
call malloc
addl $4,%esp
movl 12(%ebp),%ecx
movl %ecx,(%eax)
movl 8(%ebp),%ecx
movl 4(%ecx),%edx
// edx eax ecx
movl %edx,4(%eax)
movl %ecx,8(%eax)
movl %eax,4(%ecx)
movl %eax,8(%edx)
addl $1,16(%eax)
movl %ebp,%esp
popl %ebp
ret
//void print(list *ls)
print:
pushl %ebp
movl %esp,%ebp
pushl %esi
pushl %edi
movl 8(%ebp),%eax
movl %eax,%esi
movl 8(%eax),%edi
jmp .L1
.L2:
pushl (%edi)
pushl $.LC0
call printf
addl $8,%esp
movl 8(%edi),%edi
.L1:
cmpl %esi,%ed