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
3
votes
1answer
49 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 <...
1
vote
1answer
29 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 ...
4
votes
1answer
309 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 ...
6
votes
1answer
90 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 ...
1
vote
0answers
31 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: ...
0
votes
1answer
253 views

Writing a recursive factorial function in x86-64

The following assembly program works to print the factorial of a number: ...
5
votes
2answers
306 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 ...
6
votes
0answers
167 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 ...
24
votes
4answers
3k 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 ...
3
votes
2answers
158 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: ...
5
votes
1answer
78 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? <...
6
votes
1answer
77 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). ...
4
votes
2answers
301 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 ...
7
votes
1answer
89 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 ...
1
vote
1answer
61 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 ...
3
votes
0answers
57 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 ...
4
votes
1answer
167 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 ...
2
votes
1answer
66 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: ...
2
votes
1answer
147 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 ...
4
votes
2answers
145 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. ...
3
votes
1answer
107 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: ...
3
votes
1answer
2k 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 ...
7
votes
1answer
102 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 ...
4
votes
1answer
493 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 ...
3
votes
1answer
69 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 ...
5
votes
2answers
161 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 ...
4
votes
1answer
52 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 ...
5
votes
1answer
602 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 ...
3
votes
0answers
91 views

Instant to-and-from Roman Numeral Conversion

Ⅰ Roman numerals are composed of digits taken from a small set of uppercase characters. Lowercase characters were first used in the Middle Ages. $$I,V,X,L,C,D,M$$ With these digits we can represent ...
5
votes
2answers
39 views

A progression of quines - follow up

This is a follow up on A progression of quines. Based on the reviews I got, I have reworked my first and fifth programs. The nice quine The answer I received from ecm made me realize that my nice ...
9
votes
2answers
119 views

A progression of quines

A quine is a program whose only job it is to reproduce the source file that was used to create the executable in the first place. This stackoverflow post provides some reasoning about its usefulness. ...
3
votes
1answer
54 views

x64 fasm strlen

This is a simple strlen function with registers documented: ...
1
vote
1answer
650 views

Shifting bits in assembly (nasm)

I wrote a function which takes a byte and shifts the bits around. That is, there shall be the same number of 1 bits and 0 bits in the output but the bits will be shifted in position: ...
6
votes
1answer
221 views

Cat program in x86 NASM

I wrote cat program in x86 NASM and I would like to know if there is anything that can be improved. This implementation of cat ...
7
votes
4answers
104 views

Ubuntu 18.04.3 LTS get terminal columns and rows NASM

As part of the prologue of all my console applications, I need to determine the extents of the current terminal so if there are less than 132 columns or 43 lines the user can be warned output may not ...
5
votes
2answers
768 views

Display hexadecimal value stored at a register

I read a book about OS development and faced with a simple exercise: write a function that prints a hexadecimal value stored at a register. The program runs as a boot sector. I would really ...
7
votes
3answers
216 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 ...
14
votes
1answer
460 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 ...
5
votes
2answers
150 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 ...
3
votes
1answer
133 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: ...
-3
votes
2answers
751 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 ...
0
votes
1answer
338 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 ...
1
vote
0answers
83 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....
3
votes
1answer
99 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
1k 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 ...
4
votes
3answers
303 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: ...
6
votes
3answers
8k 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 ...
5
votes
1answer
108 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 ...
6
votes
4answers
632 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 ...
4
votes
2answers
202 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 ...