Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Flat Assembler
- format PE console
- entry start
- include 'C:\Users\Student\Documents\dos\8086\FASM\INCLUDE\win32a.inc'
- section '.text' code executable
- start:
- push hello
- call [printf]
- pop ecx
- push 0
- call [ExitProcess]
- section '.rdata' data readable
- hello db 'Hello world!', 10, 0
- section '.idata' data readable import
- library kernel32, 'kernel32.dll', \
- msvcrt, 'msvcrt.dll'
- import kernel32, ExitProcess, 'ExitProcess'
- import msvcrt, printf, 'printf'
- ////////////////////////////////////////////////////////////////////////////
- include 'c:\users\student\documents\dos\include\win32wxp.inc'
- .code
- start:
- invoke AllocConsole
- invoke WriteConsole, <invoke GetStdHandle, STD_OUTPUT_HANDLE>,tex,12,dummy,0
- invoke Sleep,-1
- invoke ExitProcess,0
- .end start
- .data
- tex TCHAR 'Hello Wordl!'
- dummy rd 1
- //////////////////////////////////////////////////////////////////////////// ODCZYT PLIKU
- format pe console 4.0
- include 'c:\users\student\documents\dos\include\win32wxp.inc'
- .data
- FileTitle db 'qwerty.txt',0
- hFile dd ?
- nSize dd ?
- lpBytesRead dd ?
- lpBuffer rb 8192
- MessageBoxCaption db 'Output:',0
- .code
- main:
- invoke CreateFile, FileTitle, GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ; open the file
- mov [hFile], eax ;Save the file's handle to hFile
- invoke GetFileSize, [hFile], 0 ; Determine the file size
- mov [nSize], eax ; Save the file size given by EAX
- invoke ReadFile, [hFile], lpBuffer, [nSize], lpBytesRead, 0 ;now read the full file
- invoke CloseHandle, [hFile] ; Handle should be close after the file has been read
- invoke MessageBox, NULL, addr lpBuffer, addr MessageBoxCaption, MB_OK ;easy way of outputing the text
- invoke ExitProcess,0
- .end main
- ////////////////////////////////////////////////////////////////////////////
- format pe console 4.0
- include 'c:\users\student\documents\dos\include\win32wxp.inc'
- .data
- buf db 'plik testowy'
- bufsize = $ - buf ;zczytywanie dlugosci stringa
- byteswritten dd ?
- .code
- main:
- invoke CreateFile, 'test.txt', GENERIC_WRITE, 0, 0, 4, FILE_ATTRIBUTE_NORMAL, 0
- invoke WriteFile, eax, buf, bufsize, byteswritten, 0
- invoke ExitProcess, 0
- .end main
- ////////////////////////////////////////////////////////////////////////////
- format pe console 4.0
- entry start
- include 'c:\users\student\documents\dos\include\win32wxp.inc'
- ;;;;
- section '.code' code readable executable
- ;;;;
- start:
- invoke Beep, 750, 300
- ccall [getchar]
- stdcall [ExitProcess], 0
- section '.idata' import data readable
- library kernel, 'kernel32.dll',\
- msvcrt, 'msvcrt.dll'
- import kernel, \
- Beep, 'Beep',\
- ExitProcess, 'ExitProcess'
- ; symbol \ oznacz przedluzenie linii
- import msvcrt, \
- getchar, '_fgetchar'
- ////////////////////////////////////////////////////////////////////////////
- ;WYWOLANIE FUNKCJI MESSAGEBOX
- include 'c:\users\student\documents\dos\include\win32wxp.inc'
- .data
- tekst_w_oknie db ' Program w assemblerze pod WINDOWS ',0
- tekst_okna db ' Okienko w asemblerze ',0
- wynik dd 0
- .code
- start:
- push MB_ICONQUESTION+MB_DEFBUTTON1
- push tekst_w_oknie
- push tekst_okna
- push 0
- call [MessageBoxA]
- invoke MessageBox, HWND_DESKTOP,'Test drugi', 'DRUGIE OKNO', MB_RETRYCANCEL+MB_ICONEXCLAMATION+MB_RIGHT
- koniec:
- invoke ExitProcess,0
- .end start
- ////////////////////////////////////////////////////////////////////////////
- include 'c:\users\student\documents\dos\include\win32wxp.inc'
- .data
- MsgBoxCaption db 'An example of cancel, retry, continue',0
- MsgBoxText db 'hello message box!',0
- .code
- start:
- invoke MessageBox, HWND_DESKTOP, 'hello message box!' , 'An example of cancel, retry, continue',MB_ICONERROR OR MB_ABORTRETRYIGNORE OR MB_ICONWARNING
- .if eax = IDABORT
- ;abort was pressed
- invoke MessageBox, HWND_DESKTOP, 'ABORT', 'WIN ABORT', MB_OK
- .elseif eax=IDRETRY
- ;retry was pressed
- invoke MessageBox, HWND_DESKTOP, 'RETRY', 'WIN RETRY', MB_OK
- .elseif eax = IDCANCEL
- ;cancel was pressed
- .endif
- invoke ExitProcess,0
- .end start
- ////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement