[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 51EyaJeebHL-1177452295.jpg (61 KB, 800x1056)
61 KB JPG
Hello everyone. I'm looking for reccomendations for good Assembly/Computer architecture books. Prefereably stuff that is focused on x86, or can be relevant to modern embedded systems.

Pic related is the C book I like. I also like "C: A Reference Manual" by Samuel Harbison and Guy Steele Jr.

I'd also like a book on compilers and assemblers.

Overall, I am trying to learn about very low level computer stuff. I am confident with C and I know basic assembly, but I would love to be confident with my ability to understand exactly what the CPU is doing, and how programs/instructions are loaded and executed. So if the topics I have chosen for books is incorrect for this, please correct me.
>>
Unless you're trans, you have no place in worrying your silly brain over complicated stuff like assembly.
>>
>>108647906
Assembly is simple. And I want a job doing low level stuff. I assume the only places that deal with this are embedded systems now.
>>
Well, there's this Lovecraftian rabbit hole:
https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html
Maybe the actual Intel documentation is a bit too specific for what you're after, in which case, annas archive has a good selection of asm / x86 / cpu architecture / etc books on offer.
>>
>>108647951
I think I'm looking more for a book that explains what a CPU is and how it works, how instructions sets work, then how machine code works on a CPU

I chose x86 because it's popular. But I really just want to know how things work generically. And starting from the bottom and working up
>>
File: the_bible.png (112 KB, 1076x1393)
112 KB PNG
>>108647836
Look no further.
>>
>>108648011
Does this go over the basics of computer architecture or will I need a general understanding first?
>>
>>108648014
(I was trolling just a little). You'll need a general understanding of the instruction set first, but I don't know of anything that goes into more detail.
I'm not sure what the best intro would be, other than trying to write some asm programs and see what you run into.
To get started, you should learn these:
>what the typical x86 function prologue/epilogues look like
>how to use the stack
>the various ways to access memory (either with mov directly, or as operands to other instructions)
>general register conventions
You'll also want these for making programs:
>how to store data in an executable
>relocations, position independence (needed for ASLR)
If you're using Linux, you'll also want this: https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build
It says how registers are used for C function params/return values, what registers are clobbered, which have to be preserved by function calls, and a lot more detail about relocations.
>>
>>108648059
>>108648014
Also, if you're ever unsure of how something works, see how the C compilers do it with godbolt or gcc -S.
>>
>>108648059
All that might seem like a lot, but most of the topics are fairly straightforward and don't have much depth beyond a few simple rules. You can learn them in an afternoon.
Some of the more advanced topics are the memory ordering rules for multithreading, atomics, and all the tricks for optimizing code. Intel's optimization manuals are good at the latter, and uops.info is a great reference for instruction timings. Big thing is to learn the diff between instruction throughput and latency. Other things, you'll need to spend some time with.

Some college lectures/slides could be a good intro too. You should be able to find these by googling.
>>
https://beginners.re/
>>
>>108648059
>>108648066
>>108648129
>>108648149
I appreciate the help
>>
>>108648235
It's not x86, but the SPIM emulator (MIPS R2000/3000) is a fun thing to play with.
>>
File: 1728704788637136.jpg (41 KB, 410x410)
41 KB JPG
>>108647836
os spefically, there are various hacking linux kernel books that you can work through. one example is linux kernel programming which is in c++. os in assembly you're probably best served by reading the source code of baremetalOS in conjuction with a reference for assembly of some sort.

for assembly you're in a bit of trouble, it's typically treated as a hobbyist thing these days. the current paradigm for assembly is inline in c++ and that's mostly what you'll get. there is irvine's assembly program book but that is mainly in 16 and 32 bit, with 64 bit being addressed basically at the end of each chapter almost as an afterthought. then you have hydes art of 64 bit assembly programming, but that is really a reference manual more than anything. assembly code pedagogy is a bit of a nightmare.

that brings me to the next point, the assembly code programming world is filled with gatekeeping assholes, and most of them don't really know what they're doing but all of who are abrasive cunts who expect you to ask their permission to even think about it. good luck wading through that sea of shit and faggotry.

there is no reason to learn 32 or 16 bit assembly, but for some reason this is what everyone tells you to do in order to 'get the idea'. it's fucking retarded advice. 64 bit is relevant because all new systems are 64 bit, and it's also much easier and simpler than 16 and 32.

the intel and amd manuals are reference manuals for people who already know what you're doing. anyone who tells you to just read them is a fucking idiot who doesn't like you. which you'll discover is basically everyone.

the best assembly code programming tool is still visual studio. debugging wise you're not going to do better. good luck.
>>
>>108648011
Doesn’t explain computer architecture, linking, how to write effective code for the CPU (caching).
>>
File: 1682997955370640.png (609 KB, 771x737)
609 KB PNG
>>108647836
to continue there are basically two types of assembly programming because there are basically two types of program.

the first type is baremetal. this is tricky because you need to access system resources, especially the boot process, yourself. it's another layer of complexity to deal with early on and my advice is don't. do this later once you've got the idea. demoscene stuff does this and baremetalos should give you an idea about it.

the second type is a program that runs under the auspices of an operating system, which is really going to be windows or linux for x86/64. this type of program uses the operating system to access system resources, for example writing shit to screen. for windows this means you're calling functions in the windows api. it will get you up and running much faster, and then you can segway into baremetal shit later and easier.
>>
>>108648149
>Forbidden
>You don't have permission to access this resource.

Fun stuff.
>>
>>108648446
>>108648497
Not OP, but what if I want to do embedded shit?
>>
File: 1741358884276378.png (1.1 MB, 1920x1080)
1.1 MB PNG
>>108648535
you'll first have to chose the chipset you want to do embedded on, so pick a developer board. this is important, because even arm has a different implementation literally for each developer. and basically you'll be doing arm. then you're looking for resources for exactly that implementation/board.

embedded is typically done in c/c++ as well, but you can do assembly (usually arm) as well. jonathan valvano had a series of books for cortex m microcontrollers but i understand the specific boards he used are hard to come by these days. you can always emulate i suppose.

there is Computer Organization and Design RISC-V Edition, but i think that emulates a hypothetical risc-v machine and deals in c/c++ mainly before getting to assembly. seems like a bit of a fuck around. i haven't looked at it in a while so take everything i say on that with a grain of salt.

wading through this shit has cost me much time and frustration so i'll help as much as i can.
>>
File: 1729225230083336.png (372 KB, 396x632)
372 KB PNG
>>108648535
this is the jonathan valvano course i did on the cortex m. it's archived on edx and i don't know how much is available/accessible anymore due to the boards being hard to get or something.
https://www.edx.org/learn/embedded-systems/the-university-of-texas-at-austin-embedded-systems-shape-the-world-microcontroller-input-output

textbook
https://users.ece.utexas.edu/~valvano/Volume1/E-Book/

youtube
https://www.youtube.com/@JonathanWValvano

dude's homepage
https://users.ece.utexas.edu/~valvano/



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.