General Assembly Thread: Ask your questions about assembler languages here.
I'm just getting into assembly, and I noticed that there's twelve general purpose registers (not counting the base pointer, instriction pointer, etc -- just those that can be used for storing program values) on x86-64, and thirty on ARMv8. Are they usually all being used, or are there usually some registers that aren't being used for something and are empty? So far I've only written simple programs and I haven't disassembled more complicated programs yet, so I don't know.
Also, is it possible to add a value to a subsection of a register (i.e. add a value to al after moving something into eax) without destroying whatever is in the other 24 bits of the eax register, or is the eax register cleared before adding the value to al?
For example, if I was to assemble:
mov eax, 3 mov al, 2
and then read the value stored in eax, would it show 2 because the 3 stored in eax was overwritten, or would it show a composite value? Would it be any different if I used the add instruction instead of mov to put 2 into al? What about if I used ah instead of al?
If you're into assembly, have you tried kolibriOS? it's not one for regular desktop use, but it's incredibly small and really shows the power of assembly.
Adrian Carter
you can use EBP/ESP if you want meight. most compiled x86 code uses EBP/ESP for the local variables/function arguments but it doesn't have to. some instructions such as PUSH,POP,RETURN, etc use ESP/EBP though so it makes more sense to use them for the stack
EAX is just one value which is 32 bits or 4 bytes. AL and AH are just names for parts of EAX. If you modify AL you're saying to modify the least significant byte of EAX. If you read AL you're saying to read the least significant byte of EAX.
your picture is off or I'm not understanding it. EAX is more like the picture here (tor users cant upload pics): friedspace.com/assembly/cpuregs1.php
Landon Fisher
What is a good assembly language for a newbie like me to pickup after I learn C?
Alexander James
Yep. Think of it this way, there's one 64 bit 'A' register (rax) and you can access subsets of it with eax,ah,al. They're like pointers into the register.
Jaxon King
x86. It's designed to be written by humans and people actually write in it. Most other machines rarely have assembly sections outside of the OS.
Ayden Sanchez
Are there any good resources for x86 that use the AT&T syntax?
Noah Rogers
So what's the difference between x86 and ARM in terms of writing programs?
Carter Gomez
ARM is much more strict. As an example, unaligned access on x86 is a performance penalty but a fault on ARM. There's less syntactic sugar on ARM. But there's also less legacy cruft that a newbie doesn't know to ignore. Almost no one writes ARM assembly in the real world as ARM is usually used in low power applications, not high performance ones.
Nathan Martinez
But wouldn't people be more inclined to use handwritten assembly in situations where performance is limited?
And does anyone but OS and BIOS manufacturers still write handwritten assembly on any platform? I'm learning it both because I'm interested in the internal workings of programs and because I'm interested in researching malware, but unless you're an autiste or are going into the security industry I don't see it being used at all. I'm transferring from a community college to a four-year institution, so maybe that's why, but at my old school I saw lots of "learn Python" classes, but nothing on learning assembly. And when I see those "which programming languages to learn for the best probability of employment" polls, assembly isn't even part of the poll.
Does anyone outside of niche fields even use assembly any more? And will I ever get a job outside of niche type jobs where knowledge in assembly is required or even recommended? Will knowing assembly and having a CS degree help prevent me from being stuck with code monkey Pajeet jobs for the rest of my life?
I'm still going to learn assembly anyways, since I'm genuinely interested in the subject regardless of how it affects my employability, but I'm curious.
Nolan Ross
Cool thread. I don't know any languages but just yesterday began learning this stuff. Trying to learn, I should say.
dump resources, plox
Henry Allen
If they don't need more performance, why would they? Yeah, I do occasionally in networking but I do everything I can to avoid it. Knowing assembly usually lets me restructure C code until I get the compiler producing what I want or cobble it together with builtins. No. No one asking about employment prospects of learning assembly will ever be good enough to compete for those jobs, so don't worry about it.
Nathaniel Green
Those all get used. The rest of the world is much more sane (which isn't saying much), but cross-platform compilers and kernels have to carry around utterly retarded shit because x86 is so crippled in comparison.