Skip to main content

Questions tagged [assembly]

Use this for code written in any assembly language. Assembly-language questions also need a tag to indicate the target processor's instruction set architecture (ISA).

Filter by
Sorted by
Tagged with
2 votes
1 answer
31 views

Simple GAS assembly program to print out all of the command line arguments provided to it

Although I've used assembly quite a bit for some simply things, I feel like I've never properly learnt how to write it idiomatically, by which I mean: which variables to use where, how best to ...
Jacob Garby's user avatar
2 votes
1 answer
53 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
2 votes
1 answer
43 views

stm32f103C8T6 - Controlling a stepper motor via DM422C (Digital Stepping Drive) - Assembler ARM7

...
TIMBO 2023's user avatar
0 votes
0 answers
52 views

Mac M1 .BF Compiler in Rust

I'm writing a brainfuck compiler in rust, that takes brainfuck instructions and converts them to a very basic assembly form, and then compiles that into binary, if you are not familiar with brainfuck ...
Jake Snell's user avatar
3 votes
2 answers
115 views

The core of the assembler (the part of the assembler that actually converts mnemonics to opcodes) is hard to follow due to many if-branchings

For my Bachelor thesis, I made a PicoBlaze Assembler and Emulator in JavaScript. I've discussed it on many Internet forums, and quite a few people have complained that the core of my assembler is hard-...
FlatAssembler's user avatar
2 votes
1 answer
195 views

Rust implementation of fibers

I am still new to rust, so any comment about what is the rust way of doing things is welcome. this is a hand-rolled implementation of fibers or user-land context-switching. ...
Ralender's user avatar
3 votes
2 answers
104 views

Functions to simplify printing strings and numbers in amd64 Assembly

I'm new to Assembly, and this is my very first "project" in Assembly. I wanted to store data (numbers) on the stack, then access and display them. Eventually, this "experiment" of ...
ghost's user avatar
  • 31
8 votes
2 answers
1k views

Number guessing game for x86

I'm new to assembly and I've just finished this guessing game that I wanted to make to improve my skills in this language. It runs in a Unix environment and does the following: generates a random ...
Abel Gérard's user avatar
5 votes
1 answer
855 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
2 votes
1 answer
2k views

part of a c++ program which mods a game using code injection

https://github.com/speedrun-program/amnesia_load_screen_tool/blob/main/code_injection.cpp https://github.com/speedrun-program/amnesia_load_screen_tool/blob/main/file_helper.h ...
my_stack_exchange_account's user avatar
3 votes
1 answer
151 views

`strdup` re-implementation in assembly

I am posting a message here because I am new to assembly programming. My goal today was to re-code strdup in assembly, so to save my first parameter which is a ...
pharaoh2000's user avatar
5 votes
2 answers
98 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
4 votes
1 answer
158 views

Perform a permutation on an array in MIPS assembly

I’m currently studying computer science at university and I’d been tasked with writing a MIPS assembly program that performs a permutation on an array. I’m asking here because my code actually worked ...
schuelermine's user avatar
5 votes
2 answers
161 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
229 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
131 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
11 votes
3 answers
2k views

Remove leading zeroes from the beginning of a string

I want to remove leading zeroes (for a big integer library I'm currently making) in numbers represented as char arrays. I chose assembly for speed, but in order to simplify making the algorithm and ...
avighnac's user avatar
  • 309
2 votes
1 answer
310 views

Increment a binary number represented as a string

I'm an amateur at assembly, but am trying to get better at it. For fun, I decided to write code that takes in a char array and increments the number represented in binary. Here are a few input-output ...
avighnac's user avatar
  • 309
-2 votes
2 answers
106 views

Optimizing Netwide Assembler codes in Microsoft Windows

I am a novice in assembler programing, I will will appreciate if someone could review these NASM assembler code for me. Is about encoder decoder. The encoder performs the following: pads the ...
Ben kubi's user avatar
2 votes
1 answer
907 views

"Hello world" in x64 assembly for Windows - Shadow space / Stack alignment

I`m currently trying to delve into x64 assembly under windows using NASM, and created a minimalistic "Hello World" application. It is mainly meant as an educational resource for me and ...
RaphM's user avatar
  • 88
0 votes
0 answers
209 views

Test and set a bit atomically using inline aarch64 assembly

The code below has been a vehicle for learning the syntax of inline assembly for gcc/clang and that is the focus of my question. In addition to anything else that I've missed I would also like ...
Robert Harris's user avatar
2 votes
1 answer
269 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
727 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
394 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
326 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
618 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
2 votes
1 answer
336 views

Base64 encoder in Assembly x86-64 Linux language

We were asked to create a Base64 encoder for Assembly x86-64 on Linux. Was wondering how my code below could be improved, be it notation or anything else. We only had Assembly for 3 months so I'm not ...
user avatar
5 votes
0 answers
174 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
225 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
4 votes
0 answers
126 views

RC4 stream cipher in ARM Assembly

Below is a complete implementation of RC4 in ARM assembly. Unit tests pass, including comparison to C implementation and to published test vectors. I'm appreciative of all feedback, comments (things ...
SRobertJames's user avatar
1 vote
0 answers
683 views

MIPS-32 assembly: Determine if n is prime

I'm new to assembly and I'm learning on my own, so I'd appreciate the feedback. My priorities are correctness (on all MIPS-32 with sllv) > speed > readability ...
Elliott's user avatar
  • 111
2 votes
1 answer
106 views

Project Euler 1 (sum of multiples of 3 or 5) in ARM Assembly

Project Euler #1 asks: Find the sum of all the multiples of 3 or 5 below 1000. In ARM Assembly; I did this in 3 loops, which avoids any MOD or DIV. Each loop is written out, without a common ...
SRobertJames's user avatar
4 votes
0 answers
222 views

Arm Assembly Tokenize String (strtok()), Load Move, Add Efficiency

Dabbling a bit more with arm assembly, I wrote a few functions to handle string splitting. The goal was to write a few reusable functions that could be combined to emulate (roughly) what C ...
David C. Rankin's user avatar
2 votes
1 answer
152 views

Writing an x64 Code Emitter to eventually make a full fledged Assembler like NASM

As the title suggests, I'm writing an x64 Code Emitter. Right now I've only encoded 1 instruction (The add instruction). I want to know if this API can be improved at all. This is how you I use it. <...
xKaihatsu's user avatar
4 votes
1 answer
613 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
7 votes
2 answers
1k views

Hack machine language assembler as required for project 6 of Nand2Tetris

This is the implementation of the Assembler required to parse source code written in the Hack Machine Language and output it to a 16-bit binary file. After writing one go in Swift, I decided I wanted ...
Henry Cooper's user avatar
1 vote
1 answer
773 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
407 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
2 votes
1 answer
254 views

FizzBuzz in arm64

I made a FizzBuzz program in arm64; I print out the values in hex instead of decimal. This was the first arm64 program I made and I'm looking for advice on how I can improve it. The code to print out ...
code writer 3000's user avatar
1 vote
0 answers
466 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,418
4 votes
0 answers
894 views

Binary to hex in ARM64 SIMD assembly

As an exercise in learning ARM64 assembly (aka AArch64), I wrote this function to convert 64-bit binary to hexadecimal with SIMD instructions. I'm most interested in feedback on the algorithm, ...
Nate Eldredge's user avatar
2 votes
1 answer
185 views

setjmp and longjmp implementation in mmix

I've written an implementation of setjmp and longjmp in MMIX (assuming no name mangling). I also hand-assembled it. Are there any mistakes anyone can spot? ...
NoLongerBreathedIn's user avatar
1 vote
1 answer
515 views

MASM) assembly implementation of recursive Fibonacci

I'm trying to teach myself assembly via MASM, below is my first implementation of the recursive form of the fibonacci sequence. I timed it against an equivalent C implementation in release mode and ...
Geoff's user avatar
  • 111
4 votes
1 answer
2k views

Decimal to binary conversion in ARM assembly

I'm "playing" with ARM assembly on a Raspberry Pi, reading various tutorials and posts to help - no, it's not a college assignment, I'm too old for college! I'm pleased with getting the ...
SimonH's user avatar
  • 41
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
-4 votes
1 answer
523 views

Fork Bomb virus in Assembly

I made a fork bomb virus in Assembly. Now, I want to make my code better. Here is my code: ...
Programmer's user avatar

1
2 3 4 5
7