Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- .Model Flat,stdcall
- ;stale
- GENERIC_READ equ 80000000h
- GENERIC_WRITE equ 40000000h
- CREATE_NEW equ 1
- CREATE_ALWAYS equ 2
- OPEN_EXISTING equ 3
- OPEN_ALWAYS equ 4
- ;plik
- CloseHandle PROTO:DWORD
- CreateFileA PROTO:DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
- WriteFile PROTO:DWORD, :DWORD, :DWORD, :DWORD, :DWORD
- ;normal
- GetStdHandle PROTO:DWORD
- ReadConsoleA PROTO:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
- ExitProcess PROTO:DWORD
- ;random
- GetTickCount PROTO
- nseed PROTO:DWORD
- nrandom PROTO:DWORD
- includelib masm32.lib
- .data
- ;plik
- handle_ZAMKNIECIE DWORD 0
- path byte "MyFile.txt",0
- handle_plik DWORD 0
- zapisane DWORD ?
- ;normal
- odczyt DWORD 0
- varRange DWORD 0
- znaki DWORD 0
- tabRandom byte 20 dup(0)
- pomoc byte 0
- .code
- main proc
- Invoke GetStdHandle,-10
- mov odczyt,eax
- invoke ReadConsoleA,odczyt,offset varRange,13,offset znaki,0
- mov ebx, offset varRange
- add ebx,znaki
- mov [ebx-2],BYTE PTR 0
- push offset varRange
- call atoi
- mov varRange,eax ;zamiana RANGE na normalna liczbe
- invoke GetTickCount
- invoke nseed,eax
- mov ebx,0
- mov ecx,10
- petla:
- push ecx
- invoke nrandom,varRange
- add al,48
- mov tabRandom[ebx],al
- add ebx,1
- mov tabRandom[ebx],0Ah
- add ebx,1
- pop ecx
- LOOP petla
- ;plik teraz
- INVOKE CreateFileA , OFFSET path , GENERIC_READ OR GENERIC_WRITE, 0 , 0 ,CREATE_ALWAYS, 0 , 0
- mov handle_plik,eax
- invoke WriteFile, handle_plik,offset tabRandom, lengthof tabRandom, offset zapisane,0
- invoke CloseHandle, handle_plik
- invoke ExitProcess,0
- main endp
- atoi proc uses esi edx inputBuffAddr:DWORD
- mov esi, inputBuffAddr
- xor edx, edx
- xor EAX, EAX
- mov AL, BYTE PTR [esi]
- cmp eax, 2dh
- je parseNegative
- .Repeat
- lodsb
- .Break .if !eax
- imul edx, edx, 10
- sub eax, "0"
- add edx, eax
- .Until 0
- mov EAX, EDX
- jmp endatoi
- parseNegative:
- inc esi
- .Repeat
- lodsb
- .Break .if !eax
- imul edx, edx, 10
- sub eax, "0"
- add edx, eax
- .Until 0
- xor EAX,EAX
- sub EAX, EDX
- jmp endatoi
- endatoi:
- ret
- atoi endp
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement