Chinaunix首页 | 论坛 | 博客
  • 博客访问: 39880
  • 博文数量: 64
  • 博客积分: 2640
  • 博客等级: 少校
  • 技术积分: 670
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-26 13:15
文章分类
文章存档

2010年(64)

我的朋友
最近访客

分类:

2010-01-26 14:18:25

对齐有点恶心。。。。。。

                                    .386
                                    .model    flat,stdcall
                                    option     casemap:none
                                    
include                        windows.inc
include                        user32.inc
includelib                user32.lib
include                        kernel32.inc
includelib                kernel32.lib


                                    .data
szCaption                    byte                'File Err',0
szText                        byte                'Cannot create file!',0

BigNum                        byte                1,4000 dup (0)
LenB                            dword                1
Temp                            byte                2,10 dup (0)
LenT                            dword                1
TR                                byte                4000 dup(0)
LenR                            dword                1

szFileName                byte                'output.txt',0
hFile                            dword                ?


                                    .code                                                                        
OutIt                            proc                BN:dword,Len:dword
                                    local                Num:dword,endl:byte

                                    pushf
                                    pushad
                                                    
                                    mov                    esi,BN
                                    mov                    edi,esi
                                    add                    edi,Len
                                    dec                    edi
                                    
while1:                        cmp                    esi,edi
                                    jns                    endwhile1
                                    
                                    mov                    al,[esi]
                                    mov                    bl,[edi]
                                    mov                    [esi],bl
                                    mov                    [edi],al
                                    
                                    inc                    esi
                                    dec                    edi
                                    jmp                    while1
endwhile1:
                                    
                                    xor                    ecx,ecx
while2:                        cmp                    ecx,Len
                                    jz                    endwhile2
                                    
                                    mov                    eax,BN
                                    add                    eax,ecx
                                    add                    byte ptr [eax],'0'
                                    
                                    inc                    ecx
                                    jmp                    while2
endwhile2:                
                                    
                                    lea                    esi,Num
                                    invoke            WriteFile,hFile,BN,Len,esi,0

                                    mov                    al,10
                                    mov                    endl,al
                                    invoke            WriteFile,hFile,addr endl,1,esi,0
                                    
                                    popad
                                    popf
                                    
                                    ret
OutIt                            endp



Multi                            proc                BN1:dword,Len1:dword,BN2:dword,Len2:dword
                                    local                ten:byte

                                    pushf
                                    pushad
                                    
                                    xor                    ecx,ecx
Init:                            cmp                    ecx,4000
                                    jz                    EndInit
                                    
                                    mov                    TR[ecx],0
                                    
                                    inc                    ecx
                                    jmp                    Init
EndInit:                    
                                    
                                    xor                    ecx,ecx
                                    mov                    esi,BN1
For1:                            cmp                    ecx,Len1
                                    jz                    EndFor1
                                    
                                    xor                    edx,edx
                                    mov                    edi,BN2
            For2:                cmp                    edx,Len2
                                    jz                    EndFor2
                                    
                                 mov                    al,[esi]
                                    mul                    byte ptr [edi]
                                    mov                    ebx,ecx
                                    add                    ebx,edx
                                    add                    TR[ebx],al
                                    
                                    inc                    edi
                                    inc                    edx
                                    jmp                    For2
            EndFor2:
                                    
                                    inc                    esi
                                    inc                    ecx
                                    jmp                    For1
EndFor1:                    
                                    
                                    mov                    eax,Len1
                                    add                    eax,Len2
                                    mov                    LenR,eax
                                    mov                    ten,10
                                                                
                                    lea                    esi,TR
                                    xor                    ecx,ecx
For3:                            cmp                    ecx,LenR
                                    jz                    EndFor3
                                    
                                    mov                    al,[esi]
                                    cbw
                                    div                    ten
                                    mov                    [esi],ah
                                    
                                    inc                    esi
                                    add                    [esi],al
                                    
                                     inc                    ecx
                                    jmp                    For3
EndFor3:
                                    
                                    mov                    ecx,LenR
For4:                 mov                    al,TR[ecx]
                                    test                al,al
                                    jnz                    EndFor4
                                    
                                    dec                    ecx
                                    jmp                    For4
EndFor4:
                                    inc                    ecx
                                    mov                    LenR,ecx
                                    
                                    popad
                                    popf
                                    ret
Multi                            endp



CopyTRto                    proc                BN:dword,adrLen:dword
                                    pushf
                                    pushad
                                    
                                    mov                    edi,BN
                                    lea                    esi,TR
                                    
                                    xor                    ecx,ecx
while1:                        cmp                    ecx,LenR
                                    jz                    endwhile1
                                    
                                    mov                    al,[esi]
                                    mov                    [edi],al
                                    
                                    inc                    esi
                                    inc                    edi
                                    inc                    ecx
                                    
                                    jmp                    while1
endwhile1:
                                    
                                    mov                    esi,adrLen
                                    mov                    [esi],ecx
                                    
                                    popad
                                    popf
                                    ret
CopyTRto                    endp



calc                 proc                exp:dword
                                    pushf
                                    pushad
                                    
                                    mov                    ecx,exp
while1:                        jecxz                endwhile1
                                    
                                    invoke            Multi,offset BigNum,LenB,offset Temp,LenT
                                    invoke            CopyTRto,offset BigNum,offset LenB
                                    
                                    dec                    ecx
                 jmp                 while1
endwhile1:                
                                    
                                    popad
                                    popf
                                    ret
calc                             endp



start:    
                                    invoke            CreateFile,offset    szFileName,GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0
                                    mov                    hFile,eax
                                    
                                    cmp                    eax,INVALID_HANDLE_VALUE
                                    jnz                    next
                                    invoke            MessageBox,0,offset szText,offset szCaption,MB_OK
                                    invoke            CloseHandle,eax
                                    jmp                    Exit
next:
                                    invoke            calc,10000
                                    invoke            OutIt,offset BigNum,LenB
Exit:                            invoke             CloseHandle,hFile
                                    invoke            ExitProcess,0
end    start


阅读(238) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~