r/asm • • Jan 01 '24

x86-64/x64 making a os in asm

0 Upvotes

I am getting annoyed at how non-customizable windows is and i want to take a try at making my own os in assembly, the problem I am having is whare to start. i would appreciate it if you could help me, and i am also excepting ideas for fetchers on the os( i have x86-64 bit intel processor)


r/asm • • Jun 21 '25

680x0/68K When your code assembles but segfaults harder than your life decisions

0 Upvotes

Nothing like the thrill of nasm -f elf64 and the crushing despair of a runtime segfault with zero context. Debugging in GDB feels like deciphering ancient alien runes. Meanwhile, C folks cry over segfaults with stack traces. Luxury. Join me in pain. Upvote if you've stared into %rsp and seen the void.


r/asm • • Jan 18 '21

x86 How do I convert a decimal to binary??

0 Upvotes

Hey guys, I'm working on creating a decimal-to-binary converter and I can't seem to figure it out. I'd prefer for the number to be a double digit. Any ideas what might have gone wrong with my code? I need to get it done ASAP and I would really appreciate any kind of help .

---

.MODEL small

.stack 200h

DIS MACRO STR

MOV AH,09H

LEA DX,STR

INT 21H

ENDM

.model small

.stack 100h

.data

msg db 'Enter a decimal number:$'

number db 0 

.code

ProgramStart:

mov bx, u/data

mov ds,bx

mov dx,offset msg

mov ah,09

int 21H

CharRead:

mov ah,01H

int 21H

cmp al, 0DH

je FinishedNumber

sub al,30h

mov bl,al

mov al,number

mov cl,10

mul cl

add al,bl

mov number,al

jmp CharRead

FinishedNumber:

;binary conversion

and al,0fh ;first 4 bits are set to 0

mov cl,3 ;cl used as counter

mov bl,al

mov bh,bl

shr bh,cl ;shift right three times

add bh,30h ;make binary value visible as 0 or 1

mov ah,2 ;print binary value

mov dl,bh

int 21h

xor bh,bh ;clear bh register

mov bh,bl

mov cl,2 ;counter=2

and bh,04h ;deletes all bits except the last third

shr bh,cl

add bh,30h

mov ah,2 ;print last three bit

mov dl,bh

int 21h

xor bh,bh

mov bh,bl

and bh,02h ;deletes all bits except the second last bit

shr bh,1

add bh,30h

mov ah,2 ;prints

mov dl,bh

int 21h

xor bh,bh

mov bh,bl

and bh,01h ;deletes all except the last one

add bh,30h

mov ah,2 ;prints

mov dl,bh

int 21h

jmp exit 

exit:

mov   ah,2     ;prints the number in binary 

mov dl,bh

int 21h

mov ah,4ch

int 21h

end ProgramStart


r/asm • • Mar 26 '24

How do I become an assembler

0 Upvotes

What exactly does a X86 assembler do, how difficult would it be to assemble something by hand and how would you do it?


r/asm • • Jun 18 '21

6502/65816 Steve Wozniak’s 256 bytes operating system in 6502 assembler: how it works? Free webinar

Thumbnail
smartykit.typeform.com
27 Upvotes

r/asm • • Jul 20 '24

I don't understand

0 Upvotes

I'm taking my first steps into the world of Assembly and I came across a problem that seems (probably) trivial. I asked chatGPT about it and it got me nowhere. In my console, the text "This is also my text" appears twice. To make each text appear once, I need to comment out the second syscall. I do not understand why.

section .text
global _start

_start:

mov rax, 1
mov rdi, 1
mov rsi, text
mov rdx, length
syscall

mov rax, 1
mov rdi, 1
mov rsi, text1
mov rdx, length1
syscall

mov rax, 60
xor rdi, rdi
syscall

section .data
text db "This is my text", 0ah
text1 db "This is also my text", 0ah
length equ $ - text
length1 equ $ - text1

r/asm • • Feb 01 '23

MIPS I think I am torturing ChatGPT...

0 Upvotes

Someone was calling ChatGPT a bullshit generator, but whatever it generates is fun!

Anyway, I gave it this prompt:

Write Dijkstra's shortest path algorithm in MIPS assembly

And it generated this:

# Constants
.data
INF: .word 999999999
N: .word 4 # number of nodes
M: .word 6 # number of edges
start: .word 1 # start node

# Graph representation
adj: .word 0, 2, INF, INF, INF, INF # adjacency matrix
    .word INF, 0, 3, INF, INF, INF
    .word INF, INF, 0, 1, INF, INF
    .word INF, INF, INF, 0, 4, INF

# Variables
.data
dis: .space 4 * 4 # distance array
vis: .space 4 * 4 # visited array
queue: .space 4 * 4 * 4 # priority queue
head: .word 0 # head of queue
tail: .word 0 # tail of queue

# Code
.text
.globl main
main:
    # Initialize distance array and visited array
    li $t0, 0 # $t0 = 0
    li $t1, 4 # $t1 = 4
    li $t2, 4 # $t2 = 4
    li $t3, 4 # $t3 = 4
    li $t4, start # $t4 = start
    sll $t4, $t4, 2 # $t4 = start * 4
    addi $t4, $t4, dis # $t4 = &dis[start]
    sw $zero, 0($t4) # dis[start] = 0
    loop1:
        bgt $t0, $t1, end1 # if $t0 >= $t1 then goto end1
        beq $t0, $t4, next1 # if $t0 == $t4 then goto next1
        addi $t3, $t3, 4 # $t3 = $t3 + 4
        sw INF, 0($t3) # dis[$t0] = INF
        j next1
    next1:
        addi $t0, $t0, 1 # $t0 = $t0 + 1
        addi $t3, $t3, 4 # $t3 = $t3 + 4
        j loop1
    end1:
        li $t0, 0 # $t0 = 0
        li $t1, 4 # $t1 = 4
        li $t3, 4 # $t3 = 4
        loop2:
        bgt $t0, $t1, end2 # if $t0 >= $t1 then goto end2
        sw $zero, 0($t3) # vis[$t0] = 0
        addi $t0, $t0, 1 # $t0 = $t0 + 1
        addi $t3, $t3, 4 # $t3 = $t3 + 4
        j loop2
    end2:
        # Push the start node into the queue
        li $t0, start # $t0 = start
        sll $t0, $t0, 2 # $t0 = start * 4
        addi $t0, $t0, dis # $t0 = &dis[start]
        lw $t1, 0($t0) # $t1 = dis[start]
        s

Is it correct/close enough to a correct implementation?


r/asm • • Jun 06 '26

x86 How do i load .obj file in x86 asm (mb opengl)

0 Upvotes

As the title says , i know it a hard task (ai said so)


r/asm • • Oct 08 '09

I am taking assembly at University. I came up with this today. I'm sorry.

Post image
1 Upvotes

r/asm • • Nov 14 '16

How would I go about shooting a character across the screen?

0 Upvotes

If I have a spaceship in the middle of the screen, how would I be able to shoot a character from all 4 sides like a laser If I hit 8 for example, it shoots upwards, 6 it shoots sideways etc.


r/asm • • Sep 21 '11

Why I'm sick of high-level limits, x86 asm is a godsend

Thumbnail supremexen.com
8 Upvotes

r/asm • • Jun 27 '25

ARM64/AArch64 ASM Beats Go: It’s 40.9% Or 1.4x Faster When Calculating SHA256

Thumbnail
programmers.fyi
2 Upvotes

tl;dr

ASM outperforms Go in runtime performance as expected when the programmer knows how to write effective and safe ASM code. It does not make sense to blindly use ASM in combination with Go. A good approach for programmers can be to benchmark compute intense parts of their Go application to estimate whether an ASM replacement would improve the runtime performance of the application.


r/asm • • Jul 04 '23

x86-64/x64 Assembly Beginner - ChatGPT confusion

0 Upvotes

Hello all,

I am teaching myself assembly and am using a pretty old book. It is quite clear that the instructions for assembly are as follows <instruction> <destination>,<source>

When asking chatGPT for some explanation of assembly I gave it the simple instruction of

movl 0x0, -0x4(%rbp)

It then tells me that it is actually movl <source>,<destination> and that this instruction is moving the immediate value 0x0 to 4 bytes below the stored value of %rbp. Logically when I read that instruction, it doesn't make sense for <instruction> <destination>,<source>. How can you move %rbp-4 into 0x0?

Which one is correct here? What am I misunderstanding? Is this some weird difference between 32 and x86-64/64?

Sorry if this is a poor explanation, I am brand new to assembly.

Edit: I should maybe say this is how the instructions were displayed to me using lldb. The book I am reading is using gdb


r/asm • • Aug 03 '24

WHERE do I get to work on C, so that I can learn more about it & get better in it ?

0 Upvotes

In my opinon, you learn something better if you use it somewhere.

At the end of day, languages are tools to make something you want to use.

I do this with most of the stuff I warn to learn.

But I'm not really sure where I can use C. I can't see where I can use it on real life stuff, except on kernels.


tl;dr Where I can use C to learn about computer fundamentals ? Except kernel stuff. (Trying to major in security)


To learn C, for starters, I solved all of my (data structures and algorithms) questions by myself, while referencing from internet/stackoverflow sometimes, to get ideas.

One notable thing I learned, is how you're suppose to pass arrays to another function. Scracted my head for WEEKS to figure this out. "Is this not supported ? Damn dude how I'll pass my arrays to solve my problems" Then I found out that, you're first suppose to define the length of array, then the array itself with that earlier defined length variable. And now finally it pass to another method !

I had to use class-wide variables before this, and It left BAD taste in my mouth, because that's a bad security practice as well as bad coding practice.

But THEN, I learned about these magical things called "pointers" and "reference" !!! And how my solution was also retarded because I'm basically copying the array unecessarily causing extra memory bloat. This thing didn't existed on other languages and I thought they're just random useless complicated extra feature I shouldn't really care about.

I think I've got hold of pointers and references too (somewhat). Cool, but I cannot understand WHERE I can use this language further, to do flashy stuff as well as learn about it in the process.

For example, there are stuff like memory leaks, corruption, garbage values, and numerous other computer fundamental stuff associated with C that are often talked about in security, and I know NOTHING about them and idk how can I even come across such problems.

I was talking about rust & C with some dude and he told me about a tool used in C to fix memory leaks, and I was like wtf is that ? Never heard it !!! Where do i get to know about these stuff ?? I ONLY get to hear about them in security talks !


I want to advance in security. For example, binaries are decompiled/disassembled to both C & cpu centric assembly, in Ghidra & other decompilers. I heard how C and assembly are easy to convert back and forth, because C is close to assembly. I need to somehow learn about them so I can figure out wtf they're talking about in security talks. And also to improve myself in reverse engineering, malware analysis, vulnerability research, etc etc.

We were taught assembly in college. We coded stuffs in assembly, like how do you multiply without using mul, just by add, loop and nop. Then we coded it directly on Intel 8085/86 board. Well, that was cool (but) I learned lot of theory and stuff that didn't really went through my heard. Scored C on that subject. ( A+ on OOP/DSA btw )

Thanks for reading


r/asm • • May 14 '25

x86 0x48656C6C6F2C20576F726C6421

0 Upvotes
global _start

section .data
  msg db "Hello, World!", 0x0A
  msg_len equ $ - msg

section .text
_start:
  mov rax, 0x01
  mov rdi, 0x01
  lea rsi, [msg]
  mov rdx, msg_len
  syscall

  mov rax, 0x3C
  xor rdi, rdi
  syscall

r/asm • • Apr 19 '19

ASM complier

0 Upvotes

Is all asm files same? Why some files .asm can't run on Microsoft Visual Studio?

I'm really confused when there are global_start but it won't run in Microsoft visual studio


r/asm • • May 29 '13

How to write to a file in ARM Assembly?

0 Upvotes

Can anyone share a sample code with me.


r/asm • • Feb 21 '19

How can i generate the sound of 'a' character in 8086 assembly the following code is for generate sound of beeping how can i develop it to hear the the sound of 'a' character.

Post image
0 Upvotes

r/asm • • Mar 15 '15

AVR Posted this on stackoverflow, didnt get any help

0 Upvotes

r/asm • • Jul 01 '25

General Assembly Code Editor

Thumbnail deepcodestudio.pages.dev
0 Upvotes

Hello everyone, I want to share this code editor for assembly languages, which is really helpful when working with assembly.


r/asm • • Aug 10 '20

ARM How much data can contain arm registers?

0 Upvotes

What's the capacity of each register?


r/asm • • Feb 09 '25

x86 IMPOSSIBLE HOMEWORK TASK

0 Upvotes

I have a homework task asking me to create a buffer overflow to redirect a function to execv(/bin/bash,[/bin/bash,-p,NULL]. I have to create a payload, which will be input into this vulnerable code, which would perform the attack. Everything I try does not work, so I am pretty sure I am setting up the stack with the payload in the wrong way. The way I am doing right now is:

Garbage Info with Buffer Offset | Address of Execv() | Address of Exit() | Address of /bin/bash |Address of argv[] | Address of /bin/bash | Address of string "-p" | Address containing a NULL

PS: Im running this on a VM with Linux(Ubuntu). Everything is 32-bit code. Also I cannot simply just input everything as string, because the null value will stop the strcpy.

I NEED TO KNOW WHAT IS WRONG WITH MY PAYLOAD


r/asm • • Mar 27 '20

Bomb lab phase 4...please help!

Post image
0 Upvotes

r/asm • • Dec 09 '13

Multiply by shift and add?

2 Upvotes

Write an ARM function "multiply" which takes an integer arguments in R0 and R1 and returns the value of R0 x R1 in R0. The function must compute the value using shifts and adds (no multiplies). Again, write a main program to adequately test the function.

What does it mean to take integer arguments. I think i know how to do the shift and add but not sure.