07125a No.1417
Sup /prog/. It saddens me that programmers proficient in assembly language are becoming increasingly rare. Even knowing enough to do some reverse engineering is considered a black art by some. There are still a few people who do it but far less than 15-10 years ago.
People say that it's too inconvenient and some even get hostile over it but writing code in assembly language is something that I've always loved. It's not about speed – in a lot of cases a compiler will spit out code that runs faster or as fast as anything that I could write. You can pretty easily out-sizecode a compiler though, and that is always nice but there's rarely a need for that unless you're writing demos. It's about that feeling of control and interacting with the machine on a level that you can't do with other languages.
Does anybody on /prog/ actually know assembly language? I'm thinking about writing an online book about programming in x86-64 assembly language from the ground up, would anybody be interested? I'm going to be releasing a fully featured Windows bittorrent client written in x86 assembly language (fasm) that is ~50kb unpacked into the public domain in a few months so stay tuned.
I've met some "x86 assembly programmers" lately who can't answer the simplest of questions, let's hope one of you out there can.
Save a byte while still using the test instruction: test ax, 256
If you can't answer this (extremely basic) question than you're still a beginner.
b0439f No.1418
>>1417I'm no expert on assembly, but I can read it, understand it, and use it. Not in large quantities though, don't expect me to make a huge program out of pure assembly (nobody does that these days anyway, for good reason).
I'm working on a compiler right now, but I haven't gotten to code generation yet.
b0439f No.1419
>>1417Also, why do you think it's important to be able to write assembly? I can understand it as a hobby, or for reverse engineering, or for compiler writing, for example, but for whole applications? A "feeling of control" doesn't equate to writing code that can be easily modified, other people can quickly understand, and can easily be ported to (or in many cases, simply "built for") other platforms/CPU architectures.
3b6382 No.1442
if you have a talent for explaining things, please do write a guide to using x86/64 assembly in a modern setting. this could be a great help to a small community that could end up changing the world
3b6382 No.1445
>>1442also I'd say you would want to go over specific ways to inline and how to invoke assembly routines in various compilers on various platforms. this is probably the scariest part for most people
187ae6 No.1453
I'd be interested. Hell, if it's decent, I'd even pay $5 - $20 for it. (Maybe you could do a similar thing to cryptography 101, Practical Common Lisp, etc; have a free html version on your website with the option to buy a PDF of it.)
eb6e99 No.1454
What sorts of projects would you suggest people try out in assembly?
96455b No.1459
>>1417I write small programs in 68k asm for the megadrive.
5ff89a No.1486
>>1417The only assembly I did much writing in was MIPS assembly and even then it's the basics. Most of the contact I had with x86 assembly was reading it in disassembler output while reverse engineering, which the actual hack written in a high level language.
>I'm going to be releasing a fully featured Windows bittorrent client written in x86 assembly language (fasm) that is ~50kb unpacked into the public domain in a few months so stay tuned.I'm interested.
fe9ca9 No.1496
I know a little x86 assembler and bits of other assemblies (assemblers ?), x86 is one ugly beast tbh.
There are already many books out on programming assembly. I think a good idea would be to read a few of them so that your book can really stick out.
I noticed a similar pattern with C++ books: They were pretty much all the same, unfortunately most of what was covered could have been done in plain C with no change.
It wasnt until I read Bjarne Stoustrupps book that I started to notice what made C++ unique.
305d5e No.1509
> If you can't answer this (extremely basic) question than you're still a beginner.I disagree completely. I know quite a bit of x86 assembly but don't have much experience with the instruction encoding. Despite that, I would say that I'm not a mere beginner. How can I claim this? It's simple, x86 machine code is so outrageously disconnected from x86 assembly that you can be pretty god damn experienced in one with just a basic understanding of the other. Just look at your fucking TEST instruction here:
http://x86.renejeschke.de/html/file_module_x86_id_315.htmlThese are nine different instructions with the same exact mnemonic. Absolutely atrocious.
07125a No.1510
OP here. Finally recovering from a sinus infection and food poisoning both at the same time. I was also thinking about doing a video series but it would probably take forever.
>>1419For entire applications it's more for the fun of it. Unless you're sizecoding something there are almost no practical reasons.
However I would say having the knowledge of assembly language is very important for C and C++ programming. C and C++ have their problems but what I like most about them is the fact that they give you a high level way to program but also let you "feel" the machine below. You have some sort of idea of the instruction patterns that are going to be generated by the compiler and I guess it gives you a sort of intuition and good feeling. Of course you don't know exactly due to the optimizer etc but it's comforting for me.
>>1445If I were to write a book it would thoroughly go over how the features of C and C++ are implemented under the hood and how to write inline asm.
>>1453I'd probably release it into the public domain but allow donations of some kind.
b6fada No.1517
>>1510Professional Assembly Language is a good x86 primer.
f7f4c8 No.1518
>Save a byte while still using the test instruction: test ax, 256
I have never heard of any (official) variant of test which saves the result of the and operation.
So one of the way I could do this is that I test for every bit using test then set the bits in my target byte.
686803 No.1522
>I'm going to be releasing a fully featured Windows bittorrent client written in x86 assembly language (fasm) that is ~50kb unpacked into the public domain in a few months so stay tuned.
>Windows
>x86 asm
>networking in asm
Why do you do this to yourself?
ff025b No.1531
is it test ah, 1
47d0e8 No.1542
I would be extremely interested in such book.
3e4f7c No.1625
1742dc No.1628
>>1417Sorry man, I only use assembly for microcontrollers
325f99 No.1852
Why x86? Pick a less shit architecture if you want to learn assembly and do something useful with it, e.g. armv8-a?
59b300 No.1861
>>1628>>1852These. I know x86 and kinda x64, but I love Z80 because its use case makes sense.
64d862 No.1863
I enjoy asm for 8-bit computers. x86 seems very complicated and there's fewer resources, especially in the case of x64, and that's not even considering the amount of hardware out there. That's unlike these old consoles that have standard hardware and have been so thoroughly documented by hackers and emulator developers that they are practically transparent.
Is there a community for PC assembly that's as fun and rich as atariage | nintendoage | nesdev?
4c2f1c No.1874
I was learning x86 assembly (16-bit and 32-bit) on my own during high school. I mastered it enough to be able to write bootsectors and very basic OS kernel. Last time I used it? Many months ago. This knowledge is pretty useless for ordinary programmers but I'm interested in language design and knowing assembly is good for designing custom bytecode-based languages, writing compilers and heavy optimization.
My favorite instruction is AAM, which simply does: AH = AL / 10, AL = AL mod 10. Undocumented feature: second byte can be changed from 0x0A to something else, which gives you small and fast way to divide AL by small constant number.
64d862 No.1875
Since this is now (retro) ASM thread lets dusciss de prog
How should I implement function invoke with parameters on 6502 (or rather 2a03) NES? Currently I'm doing something with macros, like:
> push arguments to the stack;
> JSR;
> pull return address from stack and place it in temp location;
> pull all arguments as needed;
> grab return address from temp, place it back on stack;
> RTS;
Some functions have their own macro interface in order to make use of A,X,Y in addition to the stack. It amounts to a lot of boilerplate.
FWIW I am actually retarded as well as brain damaged and stupid so I'd like to hear how de pros might do it.
Also any useful vocab? Surely "de return address thingy dat got dere when i did tha JSR" isn't very professional sounding and there's some fancy programming term for it that I don't know of.
4d8cd8 No.1878
>>14548bit game systems, I recommend the gameboy/gbc
>>1459ayyyy
>>1486I've always been a fan of mips, easy to write a dissassembler for
>>1496>>1509>>1852>>1863>>1874x86 is what happens when you start off with an 8bit cpu, and tack on more stuff over the course of decades, while also keeping it mostly backwards compatible. Very inelegant.
start with 8bit game systems or something mipsy like a ps1 (excluding the sega saturn and ps2 ofc, assembly in a heterogeneous multiprocessing environment borders on self harm)
>>1875read up on "Calling Conventions"
07125a No.1886
OP here. I've been busy lately. Nice to see this topic bumped.
>>1531Yes! Obviously you shave one byte off the opcode because 256 needs two bytes to be represented. Alternately test ax, 256 needs the prefix byte 66h, without it the opcodes would be the same size :)
>>1863The best forum that is still active is
http://board.flatassembler.net/There's also the masm and nasm forums but meh.
You might also like the APJ
http://web.textfiles.com/ezines/APJ/ 07125a No.1887
>>1852>>1861I know x86 and x64 assembly the best though I'm quite familiar with Z80 assembly and somewhat familiar with arm.
c832fe No.3312
>>1517
This is late but note PAL is written in AT&T syntax which while used by GCC is very unpopular compared to Intel syntax.
c8c639 No.3334
>>1417
Cudder is that you, senpai?
91ec50 No.3435
so, while we're on the subject, what is a good assembly book for a pleb who has barely even seen assembly code but wants to learn?
inb4 what assembly languege. nigga you tell me
a0d94d No.3449
>>3312
Fuck popularity, it's a more precise syntax.
a0d94d No.3450
I do a lot of assembly related stuff when needed for my job. Both x86 and ARM, 32-bit and 64-bit for both platforms. I'm also pretty good with SSE/AVX and NEON instruction set extensions.
The best way to learn is to just dive in, with the CPU instruction set references handy.
aa789e No.3472
I've taken an assembly class that taught PLP, a subset of MIPS. Final project was to write a sorting algorithm. Where do I go from there?