汇编-实现基本链表

来源:互联网 发布:vba 数据库 编辑:程序博客网 时间:2024/06/06 04:54

学习汇编的时候写的,有点粗糙

写于2008年

mAlloc proc nSize:dword        add nSize,4    invoke GlobalAlloc,GMEM_ZEROINIT or GMEM_FIXED,nSize             retmAlloc endp  init_L proc _struct1LOCAL _headaddress    invoke mAlloc,sizeof _struct        mov _headaddress,eax        assume eax:ptr _struct        mov [eax].address,eax              assume eax:NOTHING        mov eax,_headaddress       retinit_L endp    getdata_L proc _L,_i        xor ecx,ecx    mov eax,_L    .while ecx<=65536          assume eax:ptr _struct          .if ecx==_i                  mov eax,eax                  .break                  ret        .endif                   mov eax,[eax].next           inc ecx               .endw    retgetdata_L endpinsert_L proc   _L,_iLOCAL _firstaddressLOCAL _posaddress         mov eax,_L    mov _firstaddress,eax    xor ecx,ecx    .while ecx<_i        push ecx        assume eax:ptr _struct            invoke mAlloc,sizeof _struct        mov _posaddress,eax        mov [eax].address,eax        m2m [eax].back,_firstaddress        mov eax,_firstaddress        m2m [eax].next,_posaddress        m2m _firstaddress,_posaddress                       pop ecx                                inc ecx    .endw               mov eax,_L    retinsert_L endpdelete_L proc    _L,_i LOCAL _address        mov eax,_L        xor ecx,ecx        .while ecx<65536            push ecx                        assume eax:ptr _struct            .if ecx==_i                                   m2m _address,[eax].next                 mov eax,[eax].back                 m2m [eax].next,_address                 .break                ret            .endif            mov eax,[eax].next                        pop ecx            inc ecx        .endw    retdelete_L endp  

0 0
原创粉丝点击