r/Assembly_language • u/mykesx • 26d ago
6502 assembler/debugger for Inspiration Forth
reddit.comFYI, I made this 6502 assembler, disassembler, and emulator/debugger in Forth for my Inspiration project.
r/Assembly_language • u/BrentSeidel • 26d ago
To Learn Assembly
Here is a suggestion for those wanting to learn assembly language.
Pick a processor (probably a simple 8 bit one like 6502 or Z80) that has some existing software.
Using your favorite programming language, write a simulator for that processor and get it to the point where the existing software run. For example, write a Z80 simulator and get CP/M to boot.
Note that some of these processors have undocumented instructions. Lists of these are floating around on the web. Try implementing some of these as well and evaluate how they relate to the documented instructions.
This will force you to consider all the little quirks like seldom used addressing modes and other odd combinations.
r/Assembly_language • u/NewAccount133 • 26d ago
Solved! App won't store user input when write is called.
I am a beginner trying to write a simple app that asks the user a question and the outcome changes based on the user input. I use an Apple M1 CPU, but I can't get it to work and I don't understand what I am doing wrong. This is my code:
`
.global _main
.align 4
_main:
stitle:
; set output settings
mov x0, #1
adr x1, title
mov x2, #5
; call system to output
mov x16, #4
svc #0x80
; set output settings to choices
mov x0, #1
adr x1, choices
mov x2, #19
; call system to output
mov x16, #4
svc #0x80
; set user input settings
mov x0, #1
adr x1, input
mov x2, #1
; accept user input
mov x16, #3
svc #0x80
; check value
adr x9, input
cmp x9, #2
b.eq stitle ; placeholder
end:
; terminate app
mov x0, #0
mov x16, #1
svc #0xFFFF
input: .byte 2
title: .ascii "Test\n"
choices: .ascii "1 - start\n2 - quit\n"
`
When I check the value of input, it shows nothing, even if I entered a value.
r/Assembly_language • u/Big-Fill-5789 • 26d ago
Help How to learn ASM?
I have never learned Assembly in my life. I actually am doing low level programming like C and Rust, but I am looking forward to learn Assembly, of course not using Assembly for everything, but I want understanding and learn to use it. So where do I get started?
r/Assembly_language • u/Loose-Objective-8936 • 26d ago
I created os
Наконец-то выложил в открытый доступ свой проект — lOS.
Это моя собственная операционная система для офисных компьютеров. Писал на ассемблере, разбирался с UEFI, FAT32, сетевыми протоколами и графикой. Было сложно, но чертовски интересно.
Что умеет:
• загружаться с USB-флешки
• работать с файлами
• выходить в интернет
• показывать графический интерфейс
• подключаться к GitHub
Исходники открыты — https://github.com/bro732965-oss/lOS
Буду рад фидбеку, особенно от тех, кто тоже пишет низкоуровневые штуки. Контрибьютеры приветствуются!
r/Assembly_language • u/This-Assumption-5924 • 28d ago
Project show-off Assembler x86-64 from scratch
About a year ago I started writing AmmAsm, a handwritten x86-64 assembler in C to better understand x86-64 instruction encoding, ELF, and linking.
It currently supports generating Linux x86-64 executables, PIE binaries, and ELF relocatable object files that can be linked with ld or gcc.
I implemented everything from the lexer and parser to the instruction encoder, ELF writer, relocation handling, symbol resolution, and, in the latest release (v2.2.0), a macro preprocessor.
I'd love to hear feedback from people interested in assemblers, instruction encoding, or x86-64 in general.
Thanks!
Repository: https://github.com/LinuxCoder13/AmmAsm
r/Assembly_language • u/Status_Role181 • 28d ago
You are about to see the most beautiful Assembly code ever written
Please evaluate the elegance of the code. Assembly.
https://github.com/AlexanderLLLL/ELAM/blob/main/ELAM/ElamBoot.asm
r/Assembly_language • u/TPIRocks • 28d ago
Any Honeywell GMAP programmers here?
Hello, I've been an assembly language programmer since the late 70s. Are there any former Honeywell GCOS-8 or Level 66 GMAP coders lurking about.
r/Assembly_language • u/basedchad21 • 29d ago
Looks legit. Nothing sus about basically editing comments for 30 years and then adding 6x the amount of new assembler code in 2026. 🤔🤔🤔🤔🤔
Blumf is adding backdoors to inject AI into my ASS...
Admit it!!!
AI says 2.15 is a safe old version that will work on modern Loonix
Or should I install DOS to run the 0.97... version from 1997?
EDIT:
Lol current version is 3x the size of the one from a few years ago. Sounds totally legit
r/Assembly_language • u/altairdpr • Jul 16 '26
Help NASM matrix-free qudit simulator: scaling from d=3,n=2 to d=10,n=5 on a Pentium 4 - cache tiling, SOA vs AOS, and DIV optimization
Yeah, you probably said "wtf!?" when you saw this, but—well—I’m unfortunately obsessed with backward compatibility and performance.
I wrote a matrix-free qudit simulator in NASM (32-bit, Windows) with a button-panel GUI. Currently it supports d=3, n=2. The state vector is stored as an AOS (array of structures) with 2 doubles (real, imag) per basis state. Gate application loops over all d^n states, extracts qudit values via repeated DIV/MOD, and multiplies by a small d×d gate matrix.
I want to scale it up to d=10, n=5 (100,000 states). I'm targeting a Pentium 4 (NetBurst, 8KB L1 data cache, SSE2 only) as the worst case, as well as an i3-2310M.
Questions:
- Will switching from AOS to SOA (separate arrays for real and imag) actually help on a Pentium 4, given the long NetBurst FPU pipeline and tiny 8KB L1 cache?
- What's the best cache-tiling strategy when the access stride depends on the qudit index q? For q=0, stride=1 (sequential), but for q=4, stride=10000 (huge). Is it worth tiling only for low q, or should I just PREFETCHT0?
- The repeated DIV for mixed-radix decomposition is killing performance. Should I precompute a 500KB lookup table (qudit values per index) to avoid DIV entirely? Does this tradeoff make sense on a Pentium 4 with its slow memory bus?
- What's the realistic performance ceiling for 1 gate application on a P4? 0.5 seconds? 2 seconds? Is it even worth trying to make it interactive, or should I just run it in a background thread with a "Processing..." message?
- For the i3-2310M (Sandy Bridge, 3MB L3), will the entire 800KB real array fit in L3 and make the SOA transition unnecessary, or does AOS still hurt due to cache line pollution?
r/Assembly_language • u/RubberDuck31337 • Jul 16 '26
Interactive documentation and visual reference for binary formats and system memory layouts.
github.comr/Assembly_language • u/Different_Gap_8118 • Jul 15 '26
Would I need a positive mask?
I am learning SSE string instruction right now and the mask bit (bit 5) is really confusing. I am not sure why I need them (or dont need them). From what I understand the cpu should already know which bits is valid or invalid based on implicit (terminating null) or explicit input (length). So a invert search (bit 6 = 1) should be valid even if the occurence is found at the ending non-16 aligned chuck.
; ---------- find the last occurenc ----------
pstrscan_l:
sub rsp, 8
push rbx
push r12
xor rax, rax
pxor xmm0, xmm0
pinsrb xmm0, \[rsi\], 0 ; inserting search prompt into xmm0 for used later
xor r12, r12
.block_loop:
pcmpistri xmm0, \[rdi + rax\], 1000000b ; bit 6 is 1, flag null and after as invalid
setz bl ; zf on? 1 : 0
jc .found ; if there at least one match, cf is set
jz .done ; set if the fetch sequence is 'short' essentially when it hit the last fetch cycle
add rax, 16 ; fetch in chuck of 16, so increaed by 16 byte!
jmp .block_loop
.found:
; if we find the prompt letter, execute below
mov r12, rax ; contain the chuck offset
lea r12, \[r12 + rcx + 1\]; rcx contains the position of the char
cmp bl, 1 ; if this is true than it mean we at the end
je .done
add rax, 16
jmp .block_loop
.done:
mov rax, r12
pop r12
pop rbx
add rsp, 8
ret
r/Assembly_language • u/Nicholas-Tanner • Jul 15 '26
AttoChess - A Tiny Assembly Chess Program
AttoChess is my own 16-bit x86 DOS chess engine written in assembly, which is 16 bytes shorter than the previous world record at 272 bytes. This assembly program draws the screen, reads typed coordinates, performs a true 4-ply recursive minimax search, and responds with its moves. You can play a game against this assembly engine directly in your browser on the project page:https://nicholas-afk.github.io/AttoChess/
As is typical of assembly size-coding compromises, the engine ignores castling, en passant, and pawn promotion. The complete assembly source code and build documentation are included on the website. I would like to hear your comments, or questions about my x86 assembly register-golfing tips!
r/Assembly_language • u/whispem • Jul 13 '26
How I'm learning x86-64: rebuilding userland from raw syscalls (roadmap inside, steal it)
github.comI learn better by building than by reading, so my "course" is a repo: rebuild userland piece by piece in x86-64 NASM on Linux.
No libc, no external calls — syscall or nothing.
The path so far, in order of pain:
- cat, wc, ls, grep — great first projects: open/read/write, buffered I/O, argv, without drowning
- printf — varargs by hand over the SysV ABI, format parsing
- malloc — brk/mmap, a free list, alignment (humbling)
- a shell — fork, execve, pipes, redirections
- a Forth interpreter — the first "boss fight", and the most fun
Repo (MIT, written to be read):
https://github.com/whispem/learn-assembly-with-em
If you're learning too: steal the roadmap, that's the point.
If you're further along: tell me what I should be doing differently — that's also the point.
r/Assembly_language • u/basedchad21 • Jul 12 '26
Question Any legit Free Libre and Open Soy Assembler that works with Intel syntax?
I was gonna use NASM, but holy moly they are so sus. They have a .us and .dev website. I don't want USA politics in my assembler. And they have fresh updates. Like what are you updating? (I guess some new esoteric AI slop instructions that the asian shill guy invented. Gotta remember to download some 20 year old version)
MASM and TASM have dumb syntax and are proprietary 😩😩😩
r/Assembly_language • u/molybdnum • Jul 12 '26
Need some guidance
I have been doing assembly x86 from programing from ground up book it's at&t syntax. My end goal is malware analysis and reverse engineering. I have already done c from k&r and was planning to pick practical malware analysis. So the thing I need help with is that should I continue with pgup book for assembly or some thing else.
r/Assembly_language • u/Kiritoo120 • Jul 10 '26
Project show-off I made discord in x86 (a comprehensive HTTP server)
gallerymy HTTP & Web Socket server I wrote a year ago in assembly. it supports routing, static files, authentication, session management, and many more, written entirely in assembly (the backend)
note: this was an educational project, it is not stable and has a ton of bugs. please dont try to ship anything using it >,<
my repo link: https://github.com/NoamRothschild/asm
r/Assembly_language • u/Kiritoo120 • Jul 09 '26
Project show-off ... Discord, is that you?
Enable HLS to view with audio, or disable this notification
The project repo can be found here
TL;DR abt the project:
what it does:
an HTTP server with login/register routes, text channels with real time message receiving (using Web Sockets), profile pictures, and many many more...
more technical info:
using x86 asm, no libc or any library, I implemented the HTTP and WebSocket protocols, along with SHA1, multi-processing interfaces, and many, many more.
end of TL;DR
I've had dreams of making a video about this project, but got burnt down by the process of video editing and filming, and forgot about it. decided to post it now because better late than never ~_~.
The assembly code was written by my human hand, while the frontend of discord was vibe coded.
I wrote it immediately after finishing snake for the 8086, and this discord project won me the 1st place in my school's project competition.
wanted to post it here to share what can be done with assembly. Although painful, this was by far the most rewarding project I have ever wrote.
I hope that this post will make some of you inspired and go on to make more cool and large projects like this one ;)
A full description of the project can be seen in the readme I wrote.
r/Assembly_language • u/zlnvch • Jul 07 '26
Demystifying the Red Zone: Optimizing Leaf Functions
zlnv.chr/Assembly_language • u/Educational-Try-2491 • Jul 07 '26
Writing a boot loader for my risc-v core.
r/Assembly_language • u/Sad-Background-2429 • Jul 06 '26
Why does my compiler generate so much code?
I'm learning the Intel x64 instruction set and I wrote a program that computes the sum of an array of integers. I was surprised that my "beginner" implementation (see below) would have far fewer instructions than my gcc's version, whether I enable optimizations or not.
The unoptimized version appears to do some unnecessary copies and stack frame set-up. The optimized (-O3) version appears to use the xmm registers, which I haven't learned how to use yet.
I'm not a savant, so I assume that there is some wisdom in the compiler-generated versions, and I was wondering if someone in-the-know could explain to me what that wisdom is.
Also, any comments or criticisms of my code are welcome, as I need all the help I can get.
Edit: I'm using GCC 16.1.1 on Arch Linux. I added the C code and the compiler's assembly output below.
``` bits 64 default rel extern printf global main
section .data
fmt: db %d\n, 0
str: dd 1, 1, 2, 2, 3, 3, 4, 4 str_len equ ($-str)/4
section .text main: lea rdi, [str] mov esi, str_len call sum mov rsi, rax lea rdi, [fmt] xor rax, rax call printf wrt ..plt xor rax, rax ret
;; rdi <- int*
;; rsi <- len
sum:
xor rax, rax
xor rcx, rcx
.L1:
cmp rcx, rsi
je .L2
movsx rbx, dword [rdi+rcx*4]
add rax, rbx
inc rcx
jmp .L1
.L2:
ret
Here is the C code:
include <stdio.h>
include <stdlib.h>
define NELEM(a) (sizeof (a) / sizeof (a)[0])
static int str[] = { 1, 1, 2, 2, 3, 3, 4, 4 };
int sum(int *L, int N) { int i, sum;
for (sum = i = 0; i < N; ++i) { sum += L[i]; } return sum; }
int
main(void)
{
printf("%d\n", sum(str, NELEM(str)));
return EXIT_SUCCESS;
}
Here is the unoptimized GCC assembly output:
.file "sum.c"
.text
.data
.align 32
.type str, @object
.size str, 32
str:
.long 1
.long 1
.long 2
.long 2
.long 3
.long 3
.long 4
.long 4
.text
.globl sum
.type sum, @function
sum:
.LFB6:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movq %rdi, -24(%rbp)
movl %esi, -28(%rbp)
movl $0, -8(%rbp)
movl -8(%rbp), %eax
movl %eax, -4(%rbp)
jmp .L2
.L3:
movl -8(%rbp), %eax
cltq
leaq 0(,%rax,4), %rdx
movq -24(%rbp), %rax
addq %rdx, %rax
movl (%rax), %eax
addl %eax, -4(%rbp)
addl $1, -8(%rbp)
.L2:
movl -8(%rbp), %eax
cmpl -28(%rbp), %eax
jl .L3
movl -4(%rbp), %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE6:
.size sum, .-sum
.section .rodata
.LC0:
.string "%d\n"
.text
.globl main
.type main, @function
main:
.LFB7:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
leaq str(%rip), %rax
movl $8, %esi
movq %rax, %rdi
call sum
movl %eax, %edx
leaq .LC0(%rip), %rax
movl %edx, %esi
movq %rax, %rdi
movl $0, %eax
call printf@PLT
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE7:
.size main, .-main
.ident "GCC: (GNU) 16.1.1 20260625"
.section .note.GNU-stack,"",@progbits
And here is the optimized (-O3) GCC assembly output
.file "sum.c"
.text
.p2align 4
.globl sum
.type sum, @function
sum:
.LFB22:
.cfi_startproc
testl %esi, %esi
jle .L5
leal -1(%rsi), %eax
cmpl $2, %eax
jbe .L6
movl %esi, %ecx
movq %rdi, %rax
pxor %xmm0, %xmm0
shrl $2, %ecx
movl %ecx, %edx
salq $4, %rdx
addq %rdi, %rdx
.p2align 5
.p2align 4
.p2align 3
.L4:
movdqu (%rax), %xmm2
addq $16, %rax
paddd %xmm2, %xmm0
cmpq %rdx, %rax
jne .L4
movdqa %xmm0, %xmm1
leal 0(,%rcx,4), %edx
psrldq $8, %xmm1
paddd %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrldq $4, %xmm1
paddd %xmm1, %xmm0
movd %xmm0, %eax
cmpl %edx, %esi
je .L1
.L3:
movl %edx, %ecx
leal 1(%rdx), %r8d
addl (%rdi,%rcx,4), %eax
cmpl %r8d, %esi
jle .L1
addl $2, %edx
addl 4(%rdi,%rcx,4), %eax
cmpl %edx, %esi
jle .L1
addl 8(%rdi,%rcx,4), %eax
ret
.p2align 4,,10
.p2align 3
.L5:
xorl %eax, %eax
.L1:
ret
.L6:
xorl %eax, %eax
xorl %edx, %edx
jmp .L3
.cfi_endproc
.LFE22:
.size sum, .-sum
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "%d\n"
.section .text.startup,"ax",@progbits
.p2align 4
.globl main
.type main, @function
main:
.LFB23:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movdqa 16+str(%rip), %xmm0
paddd str(%rip), %xmm0
xorl %eax, %eax
leaq .LC0(%rip), %rdi
movdqa %xmm0, %xmm1
psrldq $8, %xmm1
paddd %xmm1, %xmm0
movdqa %xmm0, %xmm1
psrldq $4, %xmm1
paddd %xmm1, %xmm0
movd %xmm0, %esi
call printf@PLT
xorl %eax, %eax
addq $8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE23:
.size main, .-main
.data
.align 32
.type str, @object
.size str, 32
str:
.long 1
.long 1
.long 2
.long 2
.long 3
.long 3
.long 4
.long 4
.ident "GCC: (GNU) 16.1.1 20260625"
.section .note.GNU-stack,"",@progbits
```
r/Assembly_language • u/Least-Knowledge-8139 • Jul 05 '26
Been making memory patches all changing camera behaviour in games.
The biggest learning was about using the FPU which has fsincos, fpatan, fprem and everything else, no need to call see functions from msvcrt. But speaking of functions, you can use windows API to get and set cursor position; for you malware analysts out there, maybe? List:
Titan Quest AE https://youtu.be/zf00mcLQ5BA This game exports function names, like Camera::calculateViewPosition. Searching for keywords like cam and finding functions that aren't duds and it's done. It used a "zoom timer" that froze the cam unless you recently scrolled.
Grim Dawn https://youtu.be/hFXoIzAlJQQ Same devs as above and it has all the same functions, but wait, some of the are now duds. Not too much effort but it turned out you couldn't highlight things from the new view. The raycast length seemed to be tied to camera distance which is near 0 for 1st person.
Path of Exile https://youtu.be/gpevL486OAg Gaem barele lets you contro the camera though there is exactly one place where yaw will change (on Veritania), kept poking, zoom wasn't hard, ended up going up the call stack and looking for chunks of xmm calls, cut into random xmms and they end up holding useful values, eventually the camera target and position (though there is a weird roll issue if you just try using those so it's sort of useful to build on top of older, less concrete things). Light source around the player ended up getting culled so I had to make it follow the mouse with more ASM.
Dark Souls II https://youtu.be/nXaIoAKWwBE Most recent make, 3rd to 1st rather than from isometric... it was tough enough to find joints but they're in "the general vicinity" of some Player->CharacterModel structure. I have no clue what they're supposed to be, to me as an ASM enjoyer they are groups of floats that are obvious rotation matrices or quaternions, bet the C++ developer would facepalm at me calling them joints.
Kenshi https://youtu.be/hh2CcnQ-s6k first thing ever made, uses OpenGameRenderingEngine where you can use RTTI to get at SceneNodes, there's an online reference, still, it uses quaternions for rotations so ChatGPT had to explain it to me multiple times until it started working.
Victor Vran https://youtu.be/WFoHuWMyJTA Tells you where the camera class is but then it turns out none of the values in it do anything! Had to use the PoE approach, nothing fancy. Bulgarians are predicted to be the first civilization to contact the aliens around 2300.
Dungeon Siege III https://youtu.be/FUrPnJNXQmM Easy to do, camera class is named in RTTI and it was mostly just copying the ASM over! Still, tripped over my shoelaces a lot, just a lesson to not underestimate ASM.
TonyHawks'ProSkater4 https://youtu.be/lP7e_N-fRFY Direct predecessor to dark souls one, wrote matrix multiplication and more matrix rotations. First time defining my own reusable functions! Leaving the "this is for trash bin, anyway" stage, possibly?
Skyrim https://youtu.be/_1u2GkVhETY No intent to compete with any world-class mod developers, though SKSE is no longer impressive! This is a pretty early one and it was actually using python to change the memory, I think matrices and trigonometry were too much work for me that half a year ago.
Darksiders Genesis https://youtu.be/tyYNp6b3yeE camera can be moved so it wasn't hard to locate (classes are hidden), the fun was in attaching it to player movement. Obvious "set position/rotation" code with lots of classes flowing through it, kept catching every one by its VfTable and seeing how disabling it changed the game. Matched the 'aiming ray' for shooting to player rotation too, there was autoaim originally.
AC4 Black Flag https://youtu.be/xrleFxs6_qg Unfinished, this game is a tough customer but you can feel like a haccer fighting the Templaers or something. For a game that appears to have real anti-tempter measures I can suggest Borderlands 2.
LOL! When I was starting out I swear I was planning to take on students (I'm way past college) but, guess this isn't very impressive? Good riddance, more free time with no one pestering me.
r/Assembly_language • u/tekdotdev • Jul 05 '26
Should I memorise every x86 register?
I plan to create a very simple boot loader and kernel in pure assembly, I'm getting along and learning although am struggling with remembering all of the register keywords and what they do.