Category Archives: Assembler
Programming with FASM – reading from file.
In the last article tutorial, I wrote about how to write a message to a text file named file.txt. Now, I will show you how to read that message. You must use the ReadFile function defined after fileapi.h, in WIN32AX.INC. The text is shown in modal dialog – has some limitations in terms of mode… Read More »
Programming with FASM – writing to file.
In this simple example, I will show how to write a file using the assembly programming language with FASM, known as flat assembler. You can use the FASM editor with the FASMW.EXE executable. Open this editor and use this commented source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ;define format of exe file format pe console 4.0 ;include file WIN32AX ;http://flatassembler.net/docs.php?article=win32 include 'INCLUDE/WIN32AX.INC' ; define data for code .data ;this will be the filename of file filename db 'file.txt',0 ; this string will be write on the file buffer_text db 'This is a test by Catalin!' ; this is the size for WriteFile based on buffer_text buffer_size = $ - buffer_text ; define a space bytes_to_write dd ? ; the code for running .code main: invoke CreateFile,filename, GENERIC_WRITE, 0, 0, 4, FILE_ATTRIBUTE_NORMAL, 0 ;https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefile invoke WriteFile, eax, buffer_text, buffer_size, bytes_to_write, 0 ;https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-exitprocess invoke ExitProcess, 0 .end main |
Each step is describe in the source code. Run and test with… Read More »
Programming with FASM – OpenAI and FASM programming.
The entire world map praises OpenAI for its ability to analyze, sort, and give correct feedback on a defined issue. I do not completely agree, there are still reminders related to the way of solving complex tasks. An example is creating source code in an assembler for FASM. Although FASM is very strict in terms… Read More »
Programming with FASM – ComboBox Control – part 002.
In the last FASM tutorial I add a simple ComboBox without items. In this tutorial I will add two items and one button to show the output of selected ComboBox. The source code is similar with the source code from the last tutorial. I commented the source code rows for a good image of development… Read More »
Programming with FASM – divide / multiply in Linux – part 009 .
Today I will show you how to use the MMX instructions. SSE stands for Streaming SIMD Extensions and uses 128-bit registers: XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 The capabilities of the XMM registers are: 2 64-bit floating points (double precision) 2 64-bit integers 4 32-bit floating points (single-precision) 4 32-bit integers 8 16-bit… Read More »
Programming with FASM – read / display character in Linux – part 008 .
I haven’t worked with FASM, Linux, and system functions for a while. Here is an extremely simple example for beginners with output on my nickname: mythcat.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | format ELF executable 3 entry start segment readable executable BYTES = 255 ;number of byte 255 start: ;read a char from input char_read: mov eax,3 mov ebx,0 ;0 stdin, 1 stdout, 2 stderr mov ecx,char_Buffer mov edx,BYTES int 0x80 ;write byte read to output char_write: mov eax,4 mov ebx,1 mov ecx,char_Buffer mov dl,[CharRead] int 0x80 jmp char_read ;exit from program exit: mov eax,1 ; System call 'exit' xor ebx,ebx ; 'xor ebx,ebx' int 0x80 segment readable writeable char_Buffer db BYTES dup(0) CharRead db 1 |
The result is … as follows:
1 2 3 4 5 6 7 8 9 10 11 12 | [mythcat@desk fasm]$ ./fasm char_write.asm flat assembler version 1.73.24 (16384 kilobytes memory) 3 passes, 428 bytes. [mythcat@desk fasm]$ ./char_write m my yt th hc ca at t^C |
Programming with FASM – the format ELF executable – part 007 .
The tutorial for today is about debugging and FASM with fdbg tool. For debugging and testing you can use any debugger, but you can use the You can here all version for these operating system: GUI for Windows x64, Windows x64, Linux x64 and UEFI x64. I used the Linux x64 version for this tutorial.… Read More »