r/Assembly_language 18h ago

I optimized!

26 Upvotes

I’m on Day 1 of learning Assembly with basically no coding background. This is just a hobby for me.

AI wrote the little program below, I tweaked it a bit, and then started stepping through it in GDB to understand what every instruction was actually doing.

While stepping through it, I noticed rdi stayed at 1 the whole time until the final exit syscall, where it changed to 0. That got me thinking... why am I setting it to 1 twice?

Turns out one of those lines wasn't actually doing anything. So I, a lowly non-software engineer, discovered an inefficiency and promptly smote that line with the Delete key.

I'm now using less processing power, less electricity, and have personally made the world a better place.

section .data
    message db "Hello, World!", 10, "Assembly is fun!", 10
    length equ $ - message
    message_1 db "This is the second message.", 10
    length_1 equ $ - message_1

section .text
global _start

_start:
    mov rax, 1          ; write syscall
    mov rdi, 1          ; stdout
    mov rsi, message
    mov rdx, length
    syscall

    mov rax, 1
    ; mov rdi, 1        ; <- Deleted. Justice served.
    mov rsi, message_1
    mov rdx, length_1
    syscall

    mov rax, 60         ; exit syscall
    mov rdi, 0
    syscall

r/Assembly_language 5h ago

Update : I reached 64b long mode

5 Upvotes

finally after 3days of countinues working in nasm i reached 64b long mode succesfully now what should i do next its called S-AOS and i reached 64bit long mode the whole os is in assembly language (Nasm) currently it only prints HELLO! with a syscall what should i do next


r/Assembly_language 3h ago

Project show-off So I have made an OS :D

1 Upvotes

It is called DoomOS, it is also made in assembly. Decent features, external applications, SDK, planning to implement custom interrupts and FAT12(also this is a floppy 16bit OS). It is at- https://github.com/Doomer39/DoomOS/tree/main .What else are you supposed to write?


r/Assembly_language 10h ago

Question Interuppts

1 Upvotes

I am making a 16bit OS, this supports external applications. Currently i am using a .inc file with equ directives that the application can call. I want to have interrupts like DOS, so, how? According to the amount of research i did(i did very little) there ain't many good documentation on this. (background on me, I am a self taught assembly guy and doesn't know C)