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
15
votes
0answers
181 views

Multiplying big numbers using Karatsuba's method

The Karatsuba algorithm, first published in 1962, aims to speed up the multiplication of big numbers by reducing the number of 'single-digit-multiplications' involved. Because of its complexity (...
13
votes
1answer
82 views

Loading a file from a FAT32 filesystem in 16 bit real mode on x86 (Intel syntax assembly)

I am writing a bootloader that needs to load a file from a FAT32 filesytem. Since I need to load both the root directory first to find the start of the file, and then the actual file, I wrote a ...
10
votes
1answer
1k views

string length in x64 assembly (fasm)

Please critique this very, very basic routine which returns the length of a given char buffer or "string." ...
9
votes
2answers
172 views

Caesar cipher in i686 assembly + MMX

I have written the following implementation of the Caesar cipher for an old Linux computer with a Pentium MMX chip. The code has been written with the following design goals in mind: the code should ...
7
votes
3answers
179 views

String routines

These are a few string routines (just the mem* ones). I've tried to optimize them the best I can without having them be too big, but I'm unsure if I've done a good ...
7
votes
1answer
49 views

X86 Feature detection in preparation for Long Mode

These are the three steps that need to be taken in order to successfully activate Long Mode. Error reporting is sparse as most real hardware for developing an OS is 64 bit but probably still a good ...
6
votes
4answers
214 views

Find some X^2 - Y^2 equal to a given Z

Request input (Z) from user, \$-65535 \leq Z \leq 65535\$. Check if \$(X^2)-(Y^2)=Z\$ (while \$0 \leq X,Y \leq 1000\$). I wrote a code which will receive Z from user, if it's negative, store the ...
6
votes
2answers
274 views

Hex Dump Utility in x86-64 Assembly, under Linux

As a relative newbie to Assembly programming, although I can get my programs to work, I have no idea if they are disastrously constructed or not. I have created a simple Hex Dump Utility, using x86-...
6
votes
1answer
961 views

Convert unsigned Integer to ASCII in x86 assembly

This is my best effort to code an x86 32 bits to get an unsigned int (4 bytes) and convert it into a string. My strategy was successively divide the number by ten and fulfill the remainder of the <...
5
votes
2answers
79 views

Find the maximum number in an array of numbers

The task is to find the maximum number in an array of numbers. I have taken every number in the array to be byte-sized. I have written the code such that the result is stored in ...
5
votes
2answers
88 views

Multiplying big numbers using Long Multiplication

Three weeks ago I posted Multiplying big numbers using Karatsuba's method where I made reference to my version of the classical long multiplication. That's what I'm posting today so people can compare ...
5
votes
1answer
535 views

Dynamic Fibonacci algorithm in x86 (MASM)

My task was to implement this algorithm that uses memoization to calculate fibonnaci numbers: ...
5
votes
1answer
79 views

Console TicTacToe implementation

I am new to assembly and I want to know how I can improve this implementation both by speed and/or binary size optimization and making code to read and support easily. Platform: Linux, x64 Assembler:...
4
votes
3answers
138 views

A simple shellcode that will kill all your processes GNU/Linux x86_64

So I made a simple shellcode that will kill all your process. Now I would like to know, can it be done in some better way? It contains 13 bytes. Thanks for all your feedback Assembly: ...
4
votes
3answers
617 views

strlen and strcmp implementation in x86 FASM assembly

I wrote my own implementation of strlen and strcmp from C in x86 FASM and I would like to know is there anything that should be changed or improved. strlen needs string in eax and is returning length ...
4
votes
2answers
114 views

Test whether a number is a Harshad Number

A little code I wrote that will check if the entered 4-digit number is Harshad or not (Harshad number is one which divided by the sum of its digits will leave no remainder, special Harshad is the same ...
4
votes
1answer
126 views

Main loop in assembly for a Brainfuck interpreter

I have written 2 Brainfuck interpreters, one in C++, then another in C++ with Assembly inner loop. My interpreter code can be found here (C++/ASM, requires MSVC and MASM) and here (C++). Both are ...
4
votes
1answer
100 views

Expand every bit into a byte

I have the following code: ...
4
votes
0answers
79 views

Collatz Conjecture Disprover Unit - Googol Edition

The Wikipedia article about the Collatz Conjecture has these quotes: If the conjecture is false, it can only be because there is some starting number which gives rise to a sequence that does not ...
3
votes
3answers
802 views

Simple puts() function in x64 assembly

I'm trying to write as simple I/O library in x64 using linux syscalls ...
3
votes
1answer
146 views

Hex Dump Utility in x86-64 Assembly: Version 1.1

I recently posted a code review and received some very useful feedback. I have spent some time implementing the suggested improvements/fixes, and wish to post a follow up review, with the new and ...
3
votes
1answer
65 views

Generating random number from a binomial distribution

In my application of Monte Carlo simulation, the crucial part is to generate a random number from a binomial distribution with parameters n = size and p = 0.5. Here is my current implementation ...
3
votes
1answer
111 views

Reading all file contents via x64 assembly

I have come up with the following snippet by building upon the answers given to my StackOverflow question. Just trying to get some other eyeballs to review things so that they can point out any ...
2
votes
1answer
33 views

Transposing a square matrix (n x n)

I wish to transpose a square matrix, permanently overwriting it. This is not the same as creating a 2nd matrix with the transposed contents of the 1st matrix. I call the procedure with 3 parameters: ...
1
vote
1answer
624 views

Linked List in x86 assembly(MASM)

Module 1: ...
1
vote
0answers
66 views

No performance gain with SIMD 3D vector for ray tracer

I wrote two versions of vector class for my ray tracer. Non-SIMD version and SIMD version. You can find the code below. I want to ask what things should I keep in mind to get max performance with SIMD....
0
votes
1answer
71 views

Converting Array of `UINT8` (`unsigned char`) to Array of `Float32` (`float`) Using AVX2

Given input array of UINT8 (unsigned char) with numElements how could one efficiently ...
-3
votes
2answers
109 views

Converting Array of `Float32` (`float`) to Array of `UINT8` (`unsigned char`) Using AVX2 [closed]

Given input array of Float32 (float) with numElements how could one efficiently convert it ...