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.
30 questions
4
votes
5
answers
1k
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 ...
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 ...
3
votes
2
answers
320
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 ...
6
votes
2
answers
952
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 ...
13
votes
9
answers
693
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 ...
12
votes
2
answers
780
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, ...
8
votes
8
answers
727
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 ...
-3
votes
1
answer
382
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....
-13
votes
1
answer
652
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 ...
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 ...
10
votes
0
answers
314
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 ...
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)...
-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 (e....
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:
...
54
votes
38
answers
11k
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 ...
2
votes
0
answers
702
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 ...
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:
...
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 ...
2
votes
0
answers
279
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;
}
...
7
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 ...
6
votes
1
answer
376
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....
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 ...
3
votes
0
answers
226
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....
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, ...
8
votes
1
answer
815
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/...
3
votes
1
answer
540
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 ...
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 ...
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 ...
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 ...
26
votes
13
answers
8k
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, ...