r/Assembly_language

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.

reddit.com
u/tekdotdev — 15 hours ago
▲ 0 r/Assembly_language+1 crossposts

I need to learn c with memory and along with assembly mastering the memory...help with best yt channel...

currently learning c lang but i need to know more about the memory with assembly help me with thiss....

reddit.com
u/Mean_Parsnip_3007 — 16 hours ago

how to change style of assembly on windows?

so I've been learning assembly recently on windows and I really hate the way it is done on windows and I enjoy Linux much more and I am not willing to install Linux on my computer. this might be a stupid question but it doesn't hurt to ask if there is a way. 64 bit x86_64 intel nasm btw if you need to know.

reddit.com
u/GlassDouble9120 — 24 hours ago

beginner - don't understand div and mul operations

hi,

i recently started learning assembly and i don't understand what registers are used when doing the mul and div operations

For example:

div ebx

what other registers are in use to get the result, and why are those register used, is there a logic or it's a mnemonic thing and i wll have to look to a table to know which registers are actually used?

reddit.com
u/EntireAlarm6245 — 1 day ago
▲ 46 r/Assembly_language+4 crossposts

hobby 32-bit x86 operating system called **nyanOSv1 **

Hey guys,

For the past few months, I've been working on a hobby 32-bit x86 operating system called **nyanOS **. I wanted to move away from text mode as fast as possible, so I ended up programming the VGA registers directly (Mode 13h, 320x200x256 colors) to build a custom graphical user interface without relying on any BIOS calls after boot.

It's written in C and Assembly, booting via Multiboot.

### What's working right now:

* **Interrupts & Drivers:** Real IRQs for the PS/2 keyboard (IRQ1), mouse (IRQ12), and PIT timer (IRQ0). No busy loops for polling.

* **Window Manager:** Draggable, focusable, and z-ordered windows, complete with a taskbar and a start menu.

* **RAM File System:** A basic in-memory FS that handles real read, write, list, and delete operations.

* **Built-in Apps:** A working terminal shell, a text editor (Notepad with save/load), a basic mouse-driven paint program, and a local document viewer (packaged as a "browser" that reads a tiny custom markup from the RAM FS).

The source code is heavily commented, especially around the tricky parts like the GDT, IDT remapping, and direct VGA port I/O, because I wanted it to be readable.

* **GitHub:** https://github.com/yunusemreduran388-ux/NyanOS-v1

* **mywebsite** https://yunusemreduran388-ux.github.io/

* **Releases:** I also uploaded the pre-compiled `.iso` and `.elf` files to the GitHub Releases tab, so you can just grab the ISO and test it instantly in QEMU via `qemu-system-i386 -cdrom nyanos.iso` without needing to build it from source.

u/PickleFeatherRs — 2 days ago

(16-bit assembly graphical o.s. W.I.P.)(Dumb Question) How to make a simple algorithm in assembly (16-bit) to make filled circle of a certain radius (ive already made other shapes and have a _Make_Pixel label.)

There are only a couple things-
1.- Must not like take a lot of variables.
2.- Must not be 300+ lines.
3.- Should be 12th grade or lower math (i'm dumb).
4.- please don't just put equations if you know programming lang. pls explain it in any programming lang.

Most importantly it should make a filled circle of any radius.

edit- I've already tried Brensaums algorithm (didnt work), 8 point algorithm (didnt work), graphing algorithm with tension and

=> x^2 + y^2 = d, t+factor>d>t-factor. (tried didnt work)

reddit.com
u/quatani313 — 3 days ago

Seeking advice: Building a strong foundation in C and x86 Assembly (Intel syntax) for OS development

Hi everyone,

​I am currently starting my journey into low-level programming with the goal of eventually developing my own operating system kernel.

​I have decided to focus on C and x86 Assembly (Intel syntax) as my core tools. I want to make sure I build a solid, professional foundation rather than just scratching the surface.

​Could you please share some advice or point me toward resources that would help me master these two languages in the context of OS development? Specifically, I’m looking for:

​Best practices for bridging C and Assembly effectively.

​Essential topics in x86 architecture (Intel syntax) that I should prioritize for kernel development.

​Recommended books or tutorials that bridge the gap between "learning the language" and "applying it to hardware/system development."

​I am highly motivated and willing to put in the hard work. Any guidance on where to start or common pitfalls to avoid would be greatly appreciated.

​Thanks in advance!

reddit.com
u/f16_511_SA — 4 days ago

How to receive input from keyboard/mouse?

So im learning windows x86_64 nasm assembly and i was wondering how I would be able to take inputs from external devices such as keyboards or mice. Im also hoping that learning this could also help me learn how to interact with the monitor

reddit.com
u/Willing_Mine3084 — 4 days ago

Best roadmap to learn assembly as malware analyst

hi,

I recently decided to try learning assembly, to get some experience in malware analysis (im currently studying to get blue team level 1 certificate).

Does anyone know some ctf like course, where i can get to learn some basic of assembly?

reddit.com
u/EntireAlarm6245 — 6 days ago

Help me optimize a simple x64 program

Hi there, I'm learning the Intel x64 ISA by doing some Project Euler problems. The first problem is to compute the sum of all the positive integers less than 1000 that are divisible by 3 or 5. I know that there is a closed-form expression for this problem that can be computed without loops or tests. My goal isn't to improve my solution to the problem, but to optimize the solution that I have, using what I learn about x64 optimizations. The code in file p1.s is below.

	bits 64			; Enable 64-bit instructions.
	default rel		; Declare that the program can be dynamically relocated.
	global main		; The entry point main must be exported.
	extern printf		; We must import the symbols of libc that we need.
	section .data

	CLOCK_MONOTONIC_RAW equ 4
	CLOCK_REALTIME equ 0
fmt:
	db "%d", 9, "%lu", 10, 0

	section .text

main:
	push rbp
	mov rbp, rsp
	sub rsp, 32 		; Allocate space for two timeval_t structures

	mov rax, 228                ; Call the clock_gettime() syscall
	mov rdi, CLOCK_MONOTONIC_RAW     ; Argument 1: Clock ID (0)
	lea rsi, [rbp-16]
	syscall

	xor rsi, rsi		; The sum starts at zero. ESI is also the second parameter of printf().
	mov ecx, 999		; The countdown starts at 999.

.L1:
	xor edx, edx		; Set the dividend EDX:EAX to the current count.
	mov eax, ecx
	mov ebx, 3		; Is the count divisible by 3?
	div ebx
	cmp edx, 0
	je .L2			; Add it if so.

	xor edx, edx		; Set the dividend EDX:EAX to the current count.
	mov eax, ecx
	mov ebx, 5		; Is the count divisible by 5?
	div ebx
	cmp edx, 0
	jne .L3			; Add it if so.

.L2:
	add esi, ecx

.L3:
	loop .L1		; Decrement the count and loop until the count is zero.

	push rsi
	mov rax, 228                ; Call the clock_gettime() syscall
	mov rdi, CLOCK_MONOTONIC_RAW     ; Argument 1: Clock ID (0)
	lea rsi, [rbp-32]                ; Argument 2: Pointer to the timespec struct on stack
	syscall
	pop rsi

	mov rdx, qword [rbp-24]
	sub rdx, qword [rbp-8]

	lea rdi, [fmt]		; Printf's first parameter is the format string. ESI holds the second parameter.
	xor rax, rax		; In the x64 ABI, since printf() is a variadic function, we must zero out EAX before calling.
	call printf wrt ..plt	; We must also call with-regards-to the PLT, which accounts for the fact that printf is dynamically loaded.

	add rsp, 32
	pop rbp
	
	xor rax, rax
	ret

I compiled this way:

nasm -f elf64 -g -o p1.o p1.s
cc -o p1 p1.o -ansi -pedantic -Wall -g

I then ran the program and cachegrind and saw this:

==132149== Cachegrind, a high-precision tracing profiler
==132149== Copyright (C) 2002-2024, and GNU GPL'd, by Nicholas Nethercote et al.
==132149== Using Valgrind-3.25.1 and LibVEX; rerun with -h for copyright info
==132149== Command: ./p1
==132149== 
--132149-- warning: L3 cache found, using its data for the LL simulation.
233168	418070
==132149== 
==132149== I refs:        133,262
==132149== I1  misses:      1,275
==132149== LLi misses:      1,253
==132149== I1  miss rate:    0.96%
==132149== LLi miss rate:    0.94%
==132149== 
==132149== D refs:         40,123  (28,356 rd   + 11,767 wr)
==132149== D1  misses:      1,591  ( 1,220 rd   +    371 wr)
==132149== LLd misses:      1,353  ( 1,011 rd   +    342 wr)
==132149== D1  miss rate:     4.0% (   4.3%     +    3.2%  )
==132149== LLd miss rate:     3.4% (   3.6%     +    2.9%  )
==132149== 
==132149== LL refs:         2,866  ( 2,495 rd   +    371 wr)
==132149== LL misses:       2,606  ( 2,264 rd   +    342 wr)
==132149== LL miss rate:      1.5% (   1.4%     +    2.9%  )

For such a small program, I was surprised that there are any cache misses. I tried applying align 16 to align the starts of loops, but it yielded no decrease in cache misses; it only increased the number of instructions.

Can you recommend any ways to optimize the code here?

reddit.com
u/Sad-Background-2429 — 7 days ago

what are the main instruction I should learn for assembly

Before, time and time again, I've always tried to take steps towards learning this language .most people(the high level language people), apparently call what I like to think as "the unreadable syntax". At first it was hard, but then I eventually realized the syntax wasn't even hard at all, especially with things like nasm, where there's no characters before something like an instruction. You just put the instruction name, and the arguments follow.

As time passed though ,I was always in this arc of going to assembly, and then next thing its as if I never learned it ever in my entire life, because I barely ever practice it.

Now its the time in my arc where I go back to assembly once again. This time I'm actually gonna practice what I learn, but recently I've been going through certain documentations, and realizing that hundreds of instructions exist, all for certain purposes.

can anyone please help me so my brain doesnt explode and tell me the everyday instructions that you need for things from changing register/RAM data all the way to being able to do things like simply write a black line on the screen (essentially making a simple GUI with extreme low level access to the screen)

thanks for the wisdom, and also if you see a sentence that doesnt make sense, please tell me about it so I can edit it and please dont dislike this.

Also the CPU im dealing with right now is x86_64

reddit.com
u/baramDeBoramians — 8 days ago