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
1 vote
1 answer
32 views

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

...
TIMBO 2023's user avatar
0 votes
0 answers
34 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
111 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
170 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
89 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
781 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
124 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
88 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
122 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
126 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
142 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
127 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
248 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
1 vote
1 answer
675 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
  • 78
1 vote
0 answers
173 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
231 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
  • 65.3k
4 votes
1 answer
416 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
369 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
191 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
441 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
2 votes
1 answer
749 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
268 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
155 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
210 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
142 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
115 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
631 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
92 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
195 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
141 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
514 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
564 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
  • 9,977
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
381 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
233 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
328 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,308
4 votes
0 answers
790 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
180 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
441 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
2k 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
447 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
6 votes
3 answers
384 views

Fastest (in clock cycles) 16-bit x 16-bit unsigned integer division algorithm for ATMEGA1284?

I am trying to create an optimized 16-bit division algorithm for the AVR ATMEGA1284. The goal is to reduce the number of clock cycles as much as possible. AVR INSTRUCTION SET MANUAL: https://ww1....
user4574's user avatar
  • 179
1 vote
1 answer
558 views

Converting decimal to binary in Assembly

The longest example program in my PicoBlaze Simulator in JavaScript is this decimal-to-binary converter: ...
FlatAssembler's user avatar

1
2 3 4 5
7