Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [x86]

Code which runs on any of the x86 family of instruction set architectures. Questions should also be tagged for the source language (typically [assembly], though others are possible).

Filter by
Sorted by
Tagged with
1 vote
1 answer
41 views

An example of a bootloader that changes color in a loop in assembly x86

In short, this bootloader code loads sectors from the disk into memory, sets the video mode and prints a message on the screen. After that, it goes into an infinite loop, keeping the system running. <...
Bruno Ciccarino's user avatar
4 votes
1 answer
152 views

Find minimum element plus index between 8 zmm registers

I want to find the first minimal element and its index of a 64 element long array with the avx512 instuction set. The code works and is in the context of a function that is faster than the equivalent ...
Balthasar's user avatar
2 votes
1 answer
54 views

Solving the N Queens Puzzle in AEC using stack

N Queens Puzzle is a puzzle which asks you to place N chess queens on an NxN chess board so that no two queens are attacking each other. Two queens are attacking each other if they are on the same row,...
FlatAssembler's user avatar
5 votes
1 answer
866 views

Speed up strlen using SWAR in x86-64 assembly

The asm function strlen receives the link to a string as a char - Array. To do so, the function may use SWAR on general purpose register, but without using ...
HeapUnderStop's user avatar
5 votes
2 answers
102 views

Replace specific characters (CR and LF) in a file

Context This program has been created to "fix" files originating from Cobol databases. In Cobol, files extracted via something called a "copy" have the same number of characters ...
Itération 122442's user avatar
3 votes
2 answers
246 views

Print decimal integer

This is an x86-64 Linux program to print a non-negative decimal integer. I would appreciate any simple optimizations for size and readability. I am aware that division by a constant is usually done by ...
qwr's user avatar
  • 1,055
5 votes
2 answers
166 views

Base64 Encoder in Assembly X86-64

I am a beginner in assembly and would like to know ways I could improve my code. I am talking more about assembly specific things and less the logic e.g. what I could've written better, like loops <...
Jocomol's user avatar
  • 151
2 votes
1 answer
251 views

Multiply two huge base-10 numbers in assembly

This post is a second part of my original post, Add two huge base-10 numbers, which deals with adding two huge base-10 numbers. However, in this case, I'm multiplying two non-negative whole numbers. ...
avighnac's user avatar
  • 309
4 votes
1 answer
134 views

Add two huge base-10 numbers

This is some assembly code I've written to add two base-10 numbers. The input and output are represented as null-terminated ASCII strings, with digits in big-endian order. I have also provided ...
avighnac's user avatar
  • 309
6 votes
3 answers
1k views

Space encoder for URL

I’m starting to learn C++ by doing a lot of exercises. I want you to point me to where/what improvements I can do to make my code better. The exercise: write a URLencode function that takes a string ...
April Morrison's user avatar
3 votes
1 answer
244 views

UEFI bootloader

UEFI bootloader. It reads the file kernel.elf on the disk image, reads through the program headers, copies the LOAD segments into memory, and finally calls ...
runningupthatroad's user avatar
2 votes
1 answer
278 views

Hack assembler/disassembler in x86_64 assembly language

Starting from this answer I thought I would show a fully worked example of how to create a data-driven version of the assembler for the Hack assembly language. As I noted in that answer, having ...
Edward's user avatar
  • 66.4k
4 votes
1 answer
802 views

First assembly program: working with strings and integers

I started learning assembly some days ago and I wrote my first program today. Nothing exceptional here: some user inputs, strings manipulations, integer to string conversion etc... The only purpose ...
Etienne Armangau's user avatar
4 votes
1 answer
399 views

Assembler made in assembly

I made an assembler for the "hack" assembly language, here's an example of what it looks like: ...
elonma1234's user avatar
1 vote
1 answer
342 views

File dump in assembly

This is a file dump program written in assembly that displays 320 bytes at a time in 20 lines. It shows the hex code for each character and also the string At the start of the program it asks for the ...
user259137's user avatar
3 votes
2 answers
630 views

Sieve of Eratosthenes in x86 assembly

Hello I made a sieve of Eratosthenes algorithm on x86 assembly using NASM. The highest number it can take is about 2 million and it takes like 2 seconds to complete. Here's the code: ...
user259137's user avatar
3 votes
1 answer
1k views

Sum two vectors in x86 assembly

I recently made a program with C++ and ASM. Can anyone help me make this code a more efficient one, in the ASM part or both. I would really appreciate it because I don't know every ASM instruction and ...
Luis Barros's user avatar
5 votes
0 answers
181 views

Single-threaded coroutine in C (Linux x86-64)

Background Story I crafted a simple single-threaded coroutine in C, running on Linux x86-64. Short Technical Explanation 1) Task There are two types of tasks in this implementation. Main task. This ...
Ammar Faizi's user avatar
4 votes
1 answer
229 views

A Brainfuck compiler that creates a small x86_64 Linux executable from scratch

This program compiles Brainfuck source code to an x86_64 ELF executable. It doesn't rely on any backend, just raw binary stream to a functional executable. In the implementation, each cell holds an 8-...
xiver77's user avatar
  • 421
19 votes
4 answers
4k views

Minimal `printf` for integer types in x86 assembly

I'm writing a minimal C runtime targeting an old 32-bit Windows XP machine as a personal project. The C runtime provided by compilers is quite bloated. I wouldn't mind some library bloats up to ...
xiver77's user avatar
  • 421
3 votes
2 answers
150 views

Beating the compiler with a simple program finding the longest collatz sequence

I found this question in Stackoverflow asking why his/her assembly program isn't faster than the C++ program. In his/her assembly program I saw the lines ...
xiver77's user avatar
  • 421
0 votes
2 answers
59 views

Tips to Finetuning to increase the GFLOPS of a SIMD kernel

Given an Image I with dimensions as {rows, columns}, for every pixel in the image, the following needs to be computed - ...
Atharva Dubey's user avatar
4 votes
1 answer
644 views

GNU assembly (AT&T syntax) bootloader load the next sector from floppy

I'm playing with the Real mode and was trying to code something when suddenly I exceeded the 510 boundary (.org 510) of the <...
Peter Badida's user avatar
1 vote
1 answer
813 views

Printing one to ten in (GAS/AT&T x86/x64) assembly

I've started my journey of learning assembly on my Mac. As a start, I've decided to write a program to print the numbers one through ten to the console, then a final string signifying the end of the ...
Linny's user avatar
  • 10.1k
4 votes
1 answer
2k views

4x4 double precision matrix multiply using AVX intrinsics (inc. benchmarks)

Benchmark An optimised 4x4 double precision matrix multiply using intel AVX intrinsics. Two different variations. Gist For quick benchmark (with a compatible system) copy paste the command below. Runs ...
Julius's user avatar
  • 171
6 votes
1 answer
414 views

Assembler. Algorithm for incrementing a decimal number

I share an algorithm that I have written myself. It is useful for incrementing any digit of a decimal number. That way, a conversion to decimal is not necessary. Please excuse the mistakes. I am ...
FER31's user avatar
  • 63
1 vote
0 answers
475 views

81 variations of the rounded rectangle

If we apply outward curving, inward curving, and no curving at all, individually to each of the 4 corners of the rectangle, we get next 81 variations: The code implements next BASIC command: ...
Sep Roland's user avatar
  • 4,448
0 votes
1 answer
3k views

Writing a recursive factorial function in x86-64

The following assembly program works to print the factorial of a number: ...
David542's user avatar
  • 409
5 votes
2 answers
1k views

Sobel Operator - SIMD x86 Intrinsics Implementation

I'm learning C# .NET 5 Intrinsics and interested in best practices. It's really hard now to find enough information about how SIMD instructions (logically/internally) work in .NET. In addition i'm not ...
aepot's user avatar
  • 2,019
5 votes
0 answers
301 views

Optimizing bit-matching performance using AVX compiler intrinsic

We are working on a complicated math problem, very detailed question with description of the problem is here: C++ multi-threaded determination of curling numbers in vectors. That code is now converted ...
Vlad Feinstein's user avatar
25 votes
4 answers
4k views

x86-64 Assembly - Sum of multiples of 3 or 5

I'm trying to learn some basic x86 assembly and so I've begun solving Project Euler problems. I was hoping for some critique of my code that, hopefully, includes either the efficiency of the ...
sdasdadas's user avatar
  • 557
3 votes
2 answers
439 views

Very simple OS in Assembly

I made a very simple OS in Assembly. But my code is too long. I want to make my code shorter. Here is my code: ...
Arian's user avatar
  • 65
5 votes
1 answer
85 views

Find all the digits in a string

S is a given character string, then I have to find all the digits characters of S. Did I make it unnecessarily complicated? <...
just1frustredstudent's user avatar
6 votes
1 answer
112 views

Given a byte string S of length l, obtain the string D of length l-1 as D(i) = S(i) * S(i+1)

Given a byte string S of length l, obtain the string D of length l-1 as D(i) = S(i) * S(i+1) (each element of D is the product of two consecutive elements of S). ...
just1frustredstudent's user avatar
5 votes
2 answers
1k views

x86_64 nasm criticism on malloc and free implementation

I have made my own malloc implementation using this resource as a guide https://danluu.com/malloc-tutorial/ I was hoping to receive some feed back on how I can improve upon it, and If I did any major ...
CLox's user avatar
  • 419
7 votes
1 answer
105 views

x / 2 + 100 * (a + b) - 3 / (c + d) + e * e in assembly

write an algorithm for: x / 2 + 100 * (a + b) - 3 / (c + d) + e * e knowing that: a, c - word, b, d - byte, e - doubleword, x - qword ...
just1frustredstudent's user avatar
1 vote
1 answer
99 views

Criticism on x86_64 nasm printBigInt and bigPow implementation

The first "method" I have coded is _bigPow which can pow(x, y) on any number which is really big. And the _printBigInt prints a very big integer. Plus I have tried to comment most parts of ...
CLox's user avatar
  • 419
3 votes
0 answers
465 views

Printing a decimal number as a string

I've written a short script to print a number to a string. This actually was very difficult for me to do -- I'm not sure if this is actually a tricky task or just because I'm so new to asm I was ...
samuelbrody1249's user avatar
4 votes
1 answer
2k views

Print a list of strings in assembly

How does the following program look to print a list of strings? What places can I improve? Are there easier ways to print something like a linebreak after each string rather than hardcoding the ...
samuelbrody1249's user avatar
2 votes
1 answer
106 views

Program to find the maximum number/factor in a list

I have written the following basic assembly program to find the maximum number in a list divisible by a number. Here is what I have thus far: ...
samuelbrody1249's user avatar
2 votes
1 answer
2k views

x86 program to do an exponent

For continuity, my last question was with adding numbers together with a function call: Example x86-64 program. In this one I've tried to apply the lessons pointed out in the previous answer (stack ...
samuelbrody1249's user avatar
4 votes
2 answers
342 views

Criticism on x86_64 nasm assembly strToInt and printInt implementation

I am pretty new to assembly I would like criticism on two "methods" I have written. One converts string to int and the other prints an int to stdout. Any advise helps out. ...
CLox's user avatar
  • 419
3 votes
1 answer
338 views

Example x86-64 program

I wrote the following x86 program to make sure I'm following the correct practices in calling a function and then exiting to the OS: ...
samuelbrody1249's user avatar
6 votes
1 answer
13k views

Simple input and output in assembly x86_64

I am new assembly programming in Linux (x86_64) and I want to make sure that I am programing in a correct way. I wrote a program that just takes an input from the user and then writes his input to ...
Ha ones be Eilat's user avatar
7 votes
1 answer
256 views

Project Euler #1 AT&T Assembly

To practice learning x64 AT&T Assembly (GAS), I implemented three solutions for Project Euler Problem 1 (find the sum of all the multiples of 3 or 5 below 1000). The codes and a rough pseudocode ...
Jonathan Lam's user avatar
4 votes
1 answer
1k views

Selection sort algorithm in x86_64 Yasm assembler

I returned to study assembly language. And this is actually my first function written in Yasm. Implementing this function is a suggested project from this book. I slightly modified the pseudo code ...
LRDPRDX's user avatar
  • 831
4 votes
1 answer
157 views

A very fast Game of Life

The rules of John Conway's Game of Life are simple: An OFF pixel that has 3 live neighbours is turned ON. An ON pixel that has anything other than 2 or 3 live neighbours is turned OFF. Many people ...
Sep Roland's user avatar
  • 4,448
5 votes
2 answers
438 views

x86 Single Stage Bootloader

I'm learning OS development and have written a single stage bootloader that loads the kernel, enters to protected mode and finally jumps to the kernel. I'll very appreciate any feedback and ...
eanmos's user avatar
  • 405
3 votes
1 answer
83 views

A fast generator of palindrome dates in chronological order

02/02/2020 is a palindrome day because reading the date left-to-right or right-to-left still refers to the same calendar date. And because it doesn't matter whether you use the DD/MM/YYYY format or ...
Sep Roland's user avatar
  • 4,448
5 votes
1 answer
3k views

Program for string length in x86

It takes in a string from the command line. prints out the length of the string. I'm mostly looking for tips and general convention suggestions But I'm open to any other criticism also. Roast it ...
DNS_Jeezus's user avatar