[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Assembly language. Write 3 pro and 3 con. Why should I learn

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 22
Thread images: 2

File: tmp_11255-serveimage408510304.jpg (62KB, 710x514px) Image search: [Google]
tmp_11255-serveimage408510304.jpg
62KB, 710x514px
Assembly language. Write 3 pro and 3 con. Why should I learn it? Why shouldn't I? Is it the best program language or is it obsolete?
>>
Pros:
You can crack software
You can write better software
You can optimize software
It gives you understanding how everything works
Its the lowest programmable abstraction level

Cons:
There is multiple assembly architectures.
Intel x86 manual is 4k pages long
You need to read at least 10k pages to learn it
>>
>>58546776

how similar are the assembly architectures? I know they're different, but how different?
also
>10k pages
how is this even possible
>>
>>58546725
>pro
in 2017 none
>cons
have to know a lot of repetitive bs
too simple
different for each cpu
>>
>>58546776
Which is the best book to learn assembly?
>>
>>58546725
x86? None.

ARM assembly might have some minimal usage if you're doing embedded dev.
>>
>>58546820
The Art of Assembly Language - 1.4k
Intel x86 manual - 4.1k
Windows Internals Part 1/Part 2 - 1.2k
Reversing : The secrets of reverse engineering - 600
Partical reverse engineering - 400
Hacking - The art of exploitation - 500
RE4BN - 1050
Modern x86 assembly - 700
>>
>>58546725
Pros:
1. If you want to understand a program without the source code, assembly is useful (but probably still won't help for anything particularly large).
2. Learning the basics of assembly may help you to write more optimal code in higher level languages such as C.
3. You can show off to your friends that you know assembly - If you have any friends left by the time you've finished learning it...

Cons:
1. C can do everything assembly can do, and it's often faster because of compiler optimisations.
2. Very hard to keep track of what's going on in a reasonable sized codebase (though I'm sure there's ways you can organise your code to mitigate this)
3. It won't land you a job

Don't ever *write* code in assembly - At best, you should use knowledge of assembly for reverse-engineering and small modifications to existing code. Compiling C code and using the assembler output in some way is preferable to writing the assembly yourself.
>>
>>58546925
C is not faster than ASM. Fastest MemMem is written entirely in ASM and beats C by 3X
>>
>>58546725
>There is multiple assembly architectures.
In reality there are only two you deal with - x86-like and bunch of RISC ones (mips, arm, sh4). The RISC ones are more or less similiar.

Thing is, if you're proficient in x86, mips and arm, you're pretty much set for life and not much else can (in terms of concepts) really surprise you. Addressing modes or load/store, link registers, delay slots or not, status flags or not, bunch of classes of weird optional operand modes catering to C compiler, and thats basically it.

There are really cool and difficult things at times (and awkward as hell) such as register windows, but for now, those are pretty much all dead architectures.

>You need to read at least 10k pages to learn it
Nah, you learn it as you go.

Now as for real disadvantages:

Even though the code can be fast, writing and debugging assembly code is painfuly slow, tedious process. Unless there's a good reason not to, simply use a C compiler.
>>
>>58546776
>Its the lowest programmable abstraction level
you still can get one lvl lower and go full retard and type the code in binary mode, that would be the most autistic thing to do and I never seen someone memeing about it so that tell the grade of pure mental abstraction
>>
>>58546986
How much time do I need to learn it?
>>
>>58546898
You don't need to read all that to learn assembly. Just decompile some software and read the relevant entries in the Intel or AMD software development manuals. Most of the intel manual is useless to reading and writing assembly anyway, as it deals with opcode encodings and rarely used instructions.
>>
>>58547109
Who knows? The weird thing is that assembly as such isn't hard - it is already broken down to basic building blocks which are easy to grasp.

The problem is not understanding, but having the ability to take building blocks and arrange it into something useful. And the more you can express in less, the more it tends to be faster ... to a point.

To get more out of it (and generally beat the C compiler), you then need to truly understand the CPU architecture, not just the ISA you did until now. That's where the part of reading 10k manual and googling around and reading foreign code steps in. Superscalar CPUs can be somewhat tricky to get used to before you adopt the attitude of avoiding data hazards.

tl;dr: A newcomer can learn asm pretty fast, but will write terrible, shitty assembly because he ignores various hidden CPU performance constraints. This is fine, if you need assembly for low level control, and not performance.

But writing *fast* asm code is much more of an art these days, truly mastered only by compiler and JIT writers - you know, the people who teach computers to write asm for you.
>>
I made this LED blinker program in Assembly:

; toggle port b bits

.INCLUDE "/usr/share/avra/2313def.inc"

;-----------initialise Stack Pointer
.EQU sph = 0x3e

LDI r16, low(RAMEND)
OUT spl, r16
LDI r16, high(RAMEND)
OUT sph, r16

;--------------- main program
;.ORG 0
LDI r16, 0xff ; all bits on 0b1111 1111
OUT ddrb, r16 ; port b output

begin:
LDI r16, 0x55 ; 0x55 = 0b0101 0101
OUT portb, r16 ; put 0x55 to port b

RCALL delay ; call delay subroutine
;NOP

LDI r16, 0xaa ; 0xaa = 0b1010 1010
OUT portb, r16 ; put 0xaa to port b

RCALL delay ; call delay subroutine
;NOP

rjmp begin ; jump back to l1!


;-----------delay subroutine
;.ORG 0x60

delay:
LDI r17, 20 ; outer loop counter

again:
LDI r18, 100 ; inner loop counter

yetmore:
LDI r19, 10 ; inner inner loop counter

here:
NOP
NOP

DEC r19
BRNE here

DEC r18 ; decrement inner by one
BRNE here ; go to here if not zero

DEC r17 ; decrement OUTer by one
BRNE again ; go to again if not zero
RET ; return to main program
>>
>>58547331
I hope for 2017 to be year when avr finally dies in a fire.
>>
>>58547324
Tks for the complet answer.
>>
>>58546725
use C

assembly is like trying to drive a nail with your bare hands
>>
File: 77480.gif (3MB, 1839x1080px) Image search: [Google]
77480.gif
3MB, 1839x1080px
>>58547324
Good to know, I'll think I'll stick to c for a bit as I only really want to make Vidya. Maybe I'll learn it someday for NES homebrew.
>>
>>58547455
Why
>>
>>58546969
yes but the point was usually you won't be good enough at ASM to write code that is better than what the compiler is going to spew out
>>
>>58547764
>I only really want to make Vidya
and you non-ironically considered asembly?
Thread posts: 22
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.