Questions tagged [fasm]

The Flat ASseMbler (FASM) is a fast and efficient self-assembling x86 assembler for DOS, Windows and Linux operating systems.

Flat assembler is a fast assembly language compiler for the x86 architecture processors, which does multiple passes to optimize the size of generated machine code. It is self-compilable and uses intel syntax.

There are versions for Windows, DOS, Linux and other Unix-like operating systems. The DOS and Windows versions also include an editor with integrated syntax-highlighting to edit, compile and execute programs from one place.

This tag should also be used for posts that do not relate directly to FASM, but make extensive use of language features and FASM-specific macros.

Related tags:

  • The more general for posts in assembly language, including
    • for 16-bit programming
    • for 32-bit programming
    • for 64-bit programming

Further links:

350 questions
2
votes
3 answers

Logical AND implementation in x86_64 Linux assembly

I'm trying to implement logical NOT and logical AND in assembly, I did logical NOT already using x < 1 but I can't think of how to implement AND, I can use binary and but that's broken for negative numbers (it assumes -1 is true) and it doesn't make…
Ari157
  • 95
  • 4
  • 16
2
votes
1 answer

Is there a way to clone `n` amount of elements on the stack to the stack in x86_64 linux assembly?

Basically you can 'remove' elements from the stack by adding to rsp register n * 8, but if you try the opposite (rsp - (n * 8)) it doesn't work, which seems obvious but still So if I push to the stack using push like this: push 10 push 20 So the…
Ari157
  • 95
  • 4
  • 16
2
votes
0 answers

How to read the contents of a file on linux in FASM x86_64 assembly?

I'm trying to learn how to use FASM, and currently looking into manipulating files using it. But all resources I could find for it seem to be windows-only. How could I obtain a pointer to the contents of the file, or loop over each of its lines?
c-devhax
  • 21
  • 1
2
votes
0 answers

Bootloader - LBA28 in Long Mode not working

After entering long mode from bootloader, copying the second sector in memory using LBA28 crashes the PC. The second sector was copied successfully in memory in 32 bit mode. The crash happens when executing the instruction rep insw Is there a…
MikeS
  • 47
  • 6
2
votes
1 answer

Small x86-16 beep in QEMU

I am creating a small pong game using x86-16 assembly in a boot sector to run in QEMU on Ubuntu 20.04.2. I want to make a console beep when the ball hits a paddle. What would be a space efficient way to create a beep sound of any kind in x86-16? I'm…
Frundok
  • 21
  • 1
2
votes
1 answer

How to avoid using PUSH without POP?

I'm currently writing x86 assembly (FASM) by hand and one typical mistake I often make is to push an argument on the stack, but return before the pop is executed. This causes the stack offset to change for the caller, which will make the program…
bytecode77
  • 14,163
  • 30
  • 110
  • 141
2
votes
1 answer

How is FASM a low level assembler and NASM a high level assembler?

Wikipedia states: High-level assemblers in computing are assemblers for assembly language that incorporate features found in high-level programming languages. It goes on to say: High-level assemblers typically provide instructions that directly…
mediocrevegetable1
  • 4,086
  • 1
  • 11
  • 33
2
votes
1 answer

I do not understand either Microsoft x64 calling convention or FASM's implementation of it

I've written a short PE32+ program in FASM that writes "Hello World!" to stdout and quits. format PE64 console include 'win64wx.inc' .code start: invoke WriteFile,,hello,hello.length,dummy,0 invoke…
Alexey
  • 1,354
  • 13
  • 30
2
votes
1 answer

Sorting a list through a procedure in flat assembly

I'm pretty new to fasm and I just recently started learning about procedures. My problem is that I have a proc and I want it to sort my list in a certain way. But when I run my code it just seems to sort some random numbers from memory. I don't…
alangalt
  • 25
  • 6
2
votes
1 answer

"Error LNK2019: unresolved external symbol _long_add@12 referenced in function _main" when using an Assembly function in C++

I'm trying to use an Assembly(FASM) program as a function in C++, but it doesn't seem to be working, even though I linked the compiled object. Any advice? C++ program: #define _CRT_SECURE_NO_WARNINGS #include #include #include…
2
votes
1 answer

Comparing 80 bit floats in FASM with given accuracy

I am writing a program that calculates Pi using the Nilakantha Series in a loop with an accuracy of at least 0.05%. The exit condition for this loop should be when the current calculated value res and the previously calculated value prev fit |res -…
DuckMaster
  • 23
  • 1
  • 3
2
votes
1 answer

How to set MP and TS flags of register CR0? x86 Fasm

How to set MP and TS flags of register CR0? I only know how To set PE flag: mov eax, cr0 or eax, 1 mov cr0, eax
xDarylx91
  • 23
  • 3
2
votes
1 answer

Fasm x64 MsgBox

I want to compile x64 app with simple MsgBox using Fasm. I've wrote the code, it compiles successfully, but when I run it nothing is shown and the program just ends. What's wrong? format PE64 GUI 4.0 entry main include 'win64a.inc' main: invoke…
Qwertiy
  • 19,681
  • 15
  • 61
  • 128
2
votes
1 answer

How to get the square of a number in assembly

I am trying to get the square of a number between 0 and 9, and then I will use that number to create the height of the rectangle. What I've tried is using the sum method Ex: 5*5 = 25 and 5+5+5+5+5 = 25 ;Keyboard Input mov ah, 3Fh mov bx, 0 mov cx,…
Andrej Hatzi
  • 312
  • 4
  • 18
2
votes
1 answer

FASM align 32 section is not aligned enough

im using FASM and this is my program format ELF64 section '.text' executable public func func: vmovaps ymm0, YWORD [.table] xor rax, rax ret align 32 .table: DQ 1024 …
Jason
  • 75
  • 1
  • 6