Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more

Questions tagged [assembly]

This challenge is related to assembly languages. Note that challenges that require the answers to be in a specific language are generally discouraged.

Filter by
Sorted by
Tagged with
4 votes
5 answers
636 views

What is the smallest possible binary output you can generate

Here is a challenge: What is the shortest possible compiled program? Writing one line programs are fun, but they often lean on language libraries that get pulled into the final bits. How lean can you ...
Roger Hill's user avatar
3 votes
4 answers
1k views

Write the smallest possible code in x86-64 to implement the "<=>" operator

Languages, such as C++, have introduced a new comparison operator: <=>. This operator returns -1, 0, or 1† when comparing two items together: −1 means the ...
Alexis Wilke's user avatar
3 votes
2 answers
279 views

Implement constant-latency branchless multiplication efficiently

Modern hardware can perform multiplication very fast in a constant latency of 3~4 cycles. But some tiny chips for embedded environments sometimes lack hardware multiplication, which has to be emulated ...
xiver77's user avatar
  • 2,365
6 votes
2 answers
834 views

Write the most optimized assembly program to detect a prime number (from a bigger range!)

This is the second version of the task. The original task had a defect that the given range of integers was too small. This was pointed out by @harold that other methods couldn't defeat the way of ...
xiver77's user avatar
  • 2,365
13 votes
9 answers
615 views

AoCG2021 Day 16: Interpret Duet

Related to AoC2017 Day 18, Part 2. (Anyone want to add Duet to esolangs?) Duet is an assembly-like language that involves two processes running the same program simultaneously. Each process of Duet ...
Bubbler's user avatar
  • 76.7k
12 votes
2 answers
645 views

Branchless (MIPS) assembly code for median of 3

I was trying to write a short MIPS32 code for computing the median of three registers. The rules: Assume that some values are pre-loaded into $t0, ...
M A's user avatar
  • 221
8 votes
8 answers
522 views

Tips for golfing in Z80 or SM83 machine code

There's only one question for machine-language golfing, and it's for the ia32 and amd64 architectures. Here's one for a predecessor of them: the Zilog Z80! The ISA is available here. As usual, if your ...
NoLongerBreathedIn's user avatar
-4 votes
1 answer
303 views

Fill the screen in 6502asm.com [closed]

Introduction I've always liked the idea of finding the most possible bang-for-your-buck squeezed out of a tiny chip, like the 6502. Of course, I'll need to start small. Filling the screen on 6502asm....
Tux1's user avatar
  • 59
-12 votes
1 answer
580 views

Red screen in FIVE bytes or less (msdos)

Your program is supposed to create a full red screen in MSDOS. The source of the binary (.com file) must be 5 bytes or less. No wild assumptions, the binary must work in MsDos, DosBox, and FreeDos ...
HellMood's user avatar
  • 618
6 votes
6 answers
2k views

Implement the named labels for assembly

Let's assume we've got an imaginary assembler. The assembler supports numerical labels. An infinite loop example: :1 jmp 1 Your task is, to write a ...
Kamila Szewczyk's user avatar
9 votes
0 answers
266 views

Fastest way to iterate over sublattice of discrete lattice

I need to construct a functor that iterates over the linear representation of a sub-lattice of size \$d_x,d_y,d_z,d_q\$ embedded in a lattice of size \$n_x,n_y,n_z,n_q\$. The sub-lattice corner is ...
user3646557's user avatar
34 votes
5 answers
3k views

8bit virtual machine

Background I like my old 8-bit 6502 chip. It's even fun to solve some of the challenges here on PPCG in 6502 machine code. But some things that should be simple (like, read in data or output to stdout)...
Felix Palmen's user avatar
  • 4,266
-3 votes
2 answers
1k views

Fastest way to perform the equivalent of an if-statement in x86 assembly

The task is simple: Create an if-statement from scratch in x86 assembly that runs in as few clock-cycles as possible. Must be x86 assembly. Can't use any of the conditional jump/branch instructions (...
Lance's user avatar
  • 245
15 votes
1 answer
1k views

How to reduce EXE size of x86 ASM compiled with FASM?

As an exercise, I've created a simple solution for this challenge, in x86 Assembly Language. I'm running this with FASM on Windows. Here's my source code: ...
vasilescur's user avatar
52 votes
35 answers
8k views

Tips for golfing in x86/x64 machine code

I noticed that there's no such question, so here it is: Do you have general tips for golfing in x86/x64 machine code? If the tip only applies to a certain environment or calling convention, please ...
ბიმო's user avatar
  • 16.8k
2 votes
0 answers
680 views

Hello World!... in pure x86 opcodes [duplicate]

This is a Hello World challenge! Those plain ones! Yeah.... However, it's different this time. Because here, you can't use C or C++ or Stuck or ArnoldC or whatever you want. You can only choose raw ...
180Five's user avatar
  • 47
11 votes
3 answers
2k views

Smallest possible runnable Mach-O executable

What is the smallest possible runnable Mach-O executable on x86_64? The program can do nothing (not even returning a return code), but must be a valid executable (must run without errors). My try: ...
Martin M.'s user avatar
  • 223
20 votes
1 answer
1k views

Bootloader golf: Brainf***

Create a bootloader that executes given Brainfuck program. This is code-golf, so the program with least bytes wins. Being a bootloader, the size of the program is counted in non-zero bytes in the ...
Hannes Karppila's user avatar
2 votes
0 answers
260 views

Help golfing MIPS assembly [closed]

I want to write 7 assembly instructions (28 bytes) that runs a logical equivalent of this C snippet: c = a + b + 6; while (c > 5) { c = c - a; b = b + 1; } ...
Patrick Roberts's user avatar
6 votes
4 answers
1k views

Box-256 Assembly - BIG SQUARE II

I'd like to start a series of challenges for http://box-256.com/ starting with the first challenge, “BIG SQUARE II”. After this one I'll add another for "CHECKERBOARD" and so on. Rules: Complete the ...
Baldrick's user avatar
  • 261
5 votes
1 answer
328 views

Copy Memory Only Using Store And Subtraction

A peer of mine approached me with this challenge and I wasn't able to come up with an elegant solution. After discussing my approach, we began to wonder what the people at Code Golf would come up with....
Brett's user avatar
  • 73
22 votes
14 answers
2k views

The Nano Core War

This is an adaption of Core War, a programming KOTH dating back to the 20th century. To be more specific, it is using an incredibly simplified instruction set primarily based off of the original ...
PhiNotPi's user avatar
  • 29.1k
2 votes
0 answers
221 views

Code the shortest for incremental adding up until > 100 in Hack Assembly Language [closed]

You can find the Hack Assembly Language specification here: http://www.cs.huji.ac.il/course/2002/nand2tet/docs/ch_4_machine_language.pdf You can download the Hack Computer emulator here: http://www....
Koray Tugay's user avatar
13 votes
2 answers
3k views

Fastest way to compute order of magnitude in x86 assembly

The task is simple: write assembly that computes the order of magnitude of an integer using as few clock cycles as possible. Order of magnitude is defined as log10,...
Lance's user avatar
  • 245
8 votes
1 answer
772 views

WinAli - Virtual CPU for understanding assembly language

WinAli is a model assembler for Windows. It emulates a real CPU and is meant to help students learning and understanding the Assembly language. German Wikipedia article: http://de.wikipedia.org/wiki/...
GiantTree's user avatar
  • 935
3 votes
1 answer
511 views

write an "operating system" that dims Num Lock

I want to write x86 assembler code that can be used to boot your computer from and dims NumLock. This means you cannot rely on glibc or any other of these "comfi" libraries you cannot rely on the ...
Thorsten Staerk's user avatar
4 votes
3 answers
1k views

Self-contained hello-world program

I want a program that outputs "hello world" on console on my x86_64 based Linux computer. Yes, a complete program, not something silly that needs an interpreter or a compiler to work. You may: use ...
Thorsten Staerk's user avatar
5 votes
5 answers
2k views

Prime sieve and sort (x86 asm)

Your challenge is to write a routine, in x86 assembly, which takes a buffer containing 32-bit signed integers and writes a sorted list of the prime values to another buffer, then returns the number of ...
Polynomial's user avatar
  • 4,506
7 votes
7 answers
2k views

Shortest code that return SIGSEGV among the given languages [duplicate]

I come across a question in a coding competion "write a code that returns SIGSEGV(Segmentation fault ) " . Points were given on the basis of length of code. The prgramming languages available ...
Anil Arya's user avatar
  • 1,377
26 votes
13 answers
7k views

Assembly Language Quine

Write the shortest possible assembly-language quine. Use any ISA you want, unless it has a print-quine instruction or equivalent. Examples include x86, MIPS, ...
Hoa Long Tam's user avatar
  • 2,092