I want to learn Assembly but how do I practice what I study?

I want to learn Assembly but how do I practice what I study?

Other urls found in this thread:

amazon.com/Professional-Assembly-Language-Richard-Blum/dp/0764579010/
amazon.com/Modern-X86-Assembly-Language-Programming/dp/1484200659/
beginners.re/
radare.org/r/
docs.python.org/2/extending/index.html#extending-index
lmgtfy.com/?q=c compilation process
en.wikipedia.org/wiki/Disassembler
en.wikipedia.org/wiki/Machine_language
twitter.com/NSFWRedditVideo

In my computer architecture course we did some simple projects at the beginning like:

> Implement arithmetic operators like increment, decrement, add, sub, mult, abs, divide. in assembly

> Break up machine language instruction by their parts (op code, destination, carry, etc.)

> See how things like structs, loops, etc. are implemented from C into assembly

D O S
O
S

Install Xilinx

Read ; assembly language step by step programming with linux
It covers everything.

You have to decide which CPU architecture you want to learn it for first, "assembly" is not a single language but an umbrella term for several processor-specific languages that aren't compatible with each other

If you want to write programs to run on your PC then chances are you want x86, pick up Assembly Language for x86 Processors and download NASM; there's also Art of Assembly and HLA if you're just starting out, but that one uses some code constructs created by the author that don't exist in "regular" x86 assembly in order to make it easier to work with

If you want to learn about computer architecture concepts in general then as far as I'm aware MIPS is still the instruction set of choice for educational uses, pick up See MIPS Run and download SPIM to test your programs in

Really though, you can pick any architecture that was made within the last 40 years and Google "[CPU name] assembly" and find a wealth of quality tutorials

What separates types of cpu? Brand and generation, or are there differences between individual models?

Tis-100

get IDA, write programs, reverse them
you're more likely to be reading assembly than writing it, unless you're trying to get into exploitation

The best answer I can give you is "all three", but the full picture is still more complicated than that

You'll need to ask more specific questions to get more specific answers here, but for general guidelines that are applicable today:
>the CPU in your desktop PC uses x86 if it's a 32-bit model, or x86-64 (also known as AMD64) if it's a 64-bit model (i.e., anything produced within the last 10 years)
>Macs used to use Motorola 68k from the mid-80's until around 1993, then they used PowerPC until around 2006 when they switched to x86/x86-64
>the CPU in your cell phone or tablet is 9 times out of 10 going to be some variant of ARM
>your PS4 or Xbox One both use x86-64, your Wii U uses PowerPC
>all three of PS3/Xbox 360/Wii used variants of PowerPC
>MIPS had its heyday in the CPU market through most of the 90's but today is most widely used in the classroom of a computer architecture course, it's still widely considered a good platform to learn the concepts of comp arch even if today's products aren't using it much anymore

If you're curious about a particular model you can Google the name to find out what architecture that model uses

i read this when i first started and it felt really slow,
this is the best way to learn if u have even a basic understanding of c, if you want to learn exploitation like he said you should still learn from a book dedicated to teaching introduction asm then read 'a shellcoders handbook'.
amazon.com/Professional-Assembly-Language-Richard-Blum/dp/0764579010/ this for gas syntax
amazon.com/Modern-X86-Assembly-Language-Programming/dp/1484200659/ this for nasm

This!
How do I get into reverse engineering?
Videos by skids and 10 year old forum posts don't count.

beginners.re/
lena's reversing tutorials

Literally just write a simple program, pop it into windbg, bp main, and step through execution, and see how the registers/stack gets modified.

windbg will show you where you are in source while you're stepping through assembly, it's really nice

>windbg, bp main
Uhhh and for visual studio?

read books, do crackmes, analyse binary samples of malware if u want to have some fun, learn what higher level languages look like when compiled, 100% you have to get ida pro.

For books I've used Reversing by Eldad Eilam and Practical Malware Analysis, IDA Pro is the Cadillac of static disassemblers but the full feature set is very expensive for hobbyists and other debuggers/disassemblers generally offer enough of what you need to start doing some basic projects

The IDA Pro Book published by No Starch is good since it talks about the "why" of doing certain things while reverse engineering just as much as the "how", so you'll still come out of it with some concepts that apply to RE in general even though most of the book is geared toward teaching you to use IDA Pro

Look for binary bombs on Google, these are toy programs that are made to practice your RE skills on; usually they involve things like cracking a simple password scheme or tweaking a program to get some specific change in the output

Also try writing small toy programs in C, disassembling them then making changes in one part of the program to see what changes in the disassembly (you might want to turn off compiler optimization for this though)

windbg is a debugger, it's engine is what the visual studio debugger runs on, it's just easier to step through code in than the vs debugger

search for windbg to download it
bp main is a command in windebug, to halt execution when the when you get there

so you write the program you want to reverse in visual studio, it gets compiled and generates a pdb, you open up the executable in windbg and watch how it runs that way

>I want to learn the language of a CPU
Why?

You're going to waste years practicing something that will almost never become useful unless you're doing some extreme optimizations on slow embedded hardware, which isn't even an issue anymore

First learn a regular OOP language, build something useful, then once you have a career you can develop your knowledge further by studying assembly if you wish.

Don't waste your time, none of this shit will make you a l33t h4ck3r

actually this is literally what you need to learn to get into exploitation, which is what most people would consider being a 'l33t h4ck3r'

What about OllyDbg and the default visual c++ debugger?
Also, can you guys just pick one must-read introductory book for beginner RE?

ollydbg is really old now and doesn't support x64, windbg is free there's no good reason not to use it, it has a super powerful feature set, just has a pretty steep learning curve.

Sure, if you're going to reverse engineer a compiled binary so you can remove some sort of protection from it, then yeah. Starting from here though, is a mistake.

First learn actual programming, jumping straight into Assembly and reverse engineering is like skipping algebra to learn calculus.

Oh and btw, most applications built using .NET/Java are not compiled into Assembly anyway, they're compiled into an IL (Intermediate Language) that is then converted to Assembly on the fly using the JIT (Just In Time) compiler.

I'm under the assumption that he already understands c and basic computer architecture, if he doesn't then he needs to start there, yeah.

do i really need the windows sdk as well?
i am very comfortable with c and c++ but all ive done is memory hacks via windows.h, and i think thats gay

it's worth installing, there's a lot of useful tools in there you might need eventually. look up how to use symbols with windbg also, idk if it works properly on normal installs

Shellcoders handbook requires some experience, first read hacking ; the art of exploitation.

radare.org/r/ is really good once you know it.

>not learning machine code directly

Very few people write assembly nowadays. It's generally only used in C compilers. Even other languages compile down to C code at the end of the day, and never touch assembly.

I would suggest learning C instead, it's essentially portable assembly with many constructs to make your life easier (variables, naming, scoping, functions, typing, structs etc). You can write raw assembly in C if required.

Take C and shove it up your ass. Assembly is too fun not to learn

everything is eventually turned into assembly opcodes before the cpu executes them

MSVC only allows x86 to be inlined, if you want inline x64 you need to get ICC or go for one of the linux compilers

It's slow because it starts from the basics ; what is hex & what is binary and how to do arithmetic with binary & hex conversions, it learns you how memory works & managing memory and of course how to write assembly code.
It's pretty critical to know these things if your doing low-level stuff like assembly.

OP is a fat fuck living in his moms basement
He's a freeloader and doesn't pay rent

OP is a faggot and loves the cock
OP is a faggot and loves the cock

He's lurks Sup Forums only 2, maybe 3 hours a day
He's loves the cock but insists he's not gay

OP is a faggot and loves the cock
OP is a faggot and loves the cock

OP would liek to be raped by a horde of guys
Yet he insists that he is only bi...

OP is a faggot and loves the cock
OP is a faggot and loves the cock

I'm saying the python/ruby/go developers never had to write any assembly. At the end of the day, they translate code written in their language to C code and don't worry about assembly.

Learn 6502 so you can make NES games.

>He doesn't apply certain bursts of electricity into the machine

scripted languages use an interpreter to convert their byte code in to actual assembly instructions, it's never 'translated into c'

literally this: the post

you can also learn reverse engineering by cracking games you're familiar. my first reverse engineering was multi client hack for ultima online.

> Implement arithmetic operators like increment, decrement, add, sub, mult, abs, divide. in assembly

what kind of CPU doesn't have instructions for that

>Assembly in 2017
enjoy your hello world/calculator app

The bytecode is then processed by a VM or interpreter, usually written in C. docs.python.org/2/extending/index.html#extending-index
When the virtual machine needs to request memory or access a file, it doesn't use assembly. To interact with the OS it uses C.

So you have python code, translated to byte code, which is then run by an interpreter written in C, calling kernel functions which have an API written in C. At no point are the developers actually writing assembly.

The VM is written in C, and it is what is doing the work.

About that pic, what would be between assembly language and C for example?

Cobol, for instance

making a C compiler would be a fun project.

the interpreter is compiled into assembly, and the pyc byte code gets interpreted into assembly, it literally would not execute if it wasn't eventually turned into assembly, nothing along the chain is written in assembly, but it all ends up being assembly anyways. it's good to know assembly so you can debug problems that actually show up, and telling the difference between a problem in your code and a bug in the actual interpreter

Yes, the interpreter is compiled into assembly by the C compiler. The python/ruby devs still don't write assembly.

So for example in today's computers. When you write C code , can you explain me the path/stages and processes/conversions from C code to binary?

Someone else here can answer better than me

Lets hope they will, I will wait i guess

lmgtfy.com/?q=c compilation process

TIS 100 is also a very entry level "game" that is fairly similar to assembly. It's not 1-1 but it's a place to start if you are lost

that was harsh , i was hoping for a simple layman explanation from some user, it would take 20sec to a knowledgeable person to write it down and i would be grateful for his time :(

OP here, I started Shenzhen I/O. Which is better?

it gets directly compiled to assembly, which is just a 'readable' version of the binary instructions the cpu executes

so mov eax, 2; ret; is
0xB8 (mov eax) 0x02 (source value) 0x00 0x00 0x00 (rest of the size of an int)
0xC3

i should clarify more
return 2;

gets compiled into
mov eax, 2;
ret;

Thank you so much. So C is that much low level... amazing

There's an option in visual studio to literally see the assembly code in grey text below yours.

Get an 8085 microprocessor trainer board. It will teach you arithmetic and logical operations and gives you a good basic idea of how assembly works.

nerdgasam

yeah, breakpoint main, start debugging, hit alt-8 and it will be there

Write C -> Compile it. The compiler is translating it into the machine language of your architecture. That is what the compiler is doing. Just like an assembler is translating assembly into machine language. The other guys talking about you translating your C code into assembly are fucking retarded.

I'm pretty sure I've seen people have that realtime, while writing code. Was I mistaken?

are you fucking stupid? 'machine language' is assembly

maybe, i've never seen that though, if so that's pretty cool

You're dumb. Assembly is not machine language. I know you're probably an CS student and don't understand electronics at all but you should just shut up right about now.

>Learning assembly for x86
literally why

>'machine language' is assembly

>not making C compiler with C complier

it is literally what's pushed to the cpu to execute are you high???????????

Machine language is in binary. All electronics work using binary to do things. Assembly is in hexadecimal.

?????????????????????????? there's literally no difference between binary and hex, it's literally just different ways to represent the same data. 0xb8 (mov eax) is 1011 1000, a direct translation of what that opcode is

i think the user is refering to literal circuits that do not know even hexadecimal but only low and high voltage

>are you high???????????
yes

yes its a 1:1 translation, but the computer still doesn't know what the fuck an x b or 8 is.

Are you dense? You're sitting here debating with an electrical engineer that is telling you what machine language is. Electronics can not use hexadecimal to produce high or low. You need an assembler to translate your assembly code into machine language(binary).

>You need an assembler to translate your assembly code into machine language(binary).
you were literally just arguing the opposite

No I wasn't. You just don't know what you're talking about.

You said a compiler creates machine code, it doesn't. A compiler converts c to assembly, an assembler converts assembly to binary

You're right, I don't actually need to assemble my assembly file first

No. A compiler takes a higher level language like C and converts it into machine language so the microprocessor can understand it. An assembler takes assembly and translates it into machine language so the microprocessor can understand it.

Directly to machine, without assembly step? Is this how C was designed? (not him btw)

>A compiler takes a higher level language like C and converts it into machine language

No. C-->Assembly-->Machine language(binary)

Lurker here, why do I feel sometimes Sup Forums has no understanding of tech

The compiler was designed for that. C can work on any machine that you can create a compiler for.

idk if you're being sarcastic or not, it's similar to how an interpreter works
so something like python
python - > pyc (bytecode) -> interpreter -> assembly -> assembler -> binary -> cpu

en.wikipedia.org/wiki/Disassembler

So now you're just arguing for me or what?
en.wikipedia.org/wiki/Machine_language

disassembling something is taking machine code and converting it to assembly, assembling is assembly to machine code

Damn why is every so hostile when it comes to assembly

I have to learn some basics on it in for computer architecture

Yeah, I understand what reverse engineering is. What are you arguing for now? You realize you are arguing for me now, right? Or are you some new guy in the discussion now?

i honestly don't know anymore, i took a shower and got food and came back and wanted to argue with someone

Well you can't argue with me when you're linking stuff that aligns with what I'm saying.

all im finna say is
assembler:
assembly -> machine code

disassembler:
machine code -> assembly

I was here from start and now you lost me... It was about machine language not being same as assembly which I think we all agree on and then topic switched on about stages of conversion between C code and binary where one user claimed that there is no assembly in that process bcs C is directly translated to machine

Yeah. You are correct. The assembler takes your assembly code and converts it to machine language. And an disassembler is reverse engineering machine language to show you assembly code so it's easier to read. If you are the original user that tried to fight with me then I'm glad you finally googled this stuff and learned something today.

I guess you confused yourself. Here is the most basic way of explaining everything. Assembly and programming languages like C/C++/python/etc all need a program that converts your programming language into machine code. Assembly needs an assembler which converts your program into machine language(binary) so your microprocessor understands. The other programming languages use a compiler which converts your program into machine language(binary) so your microprocessor understands it. Assembly for most microprocessors is somewhat similar so if you can learn to program one microprocessor you can program another one easily by just studying the opcodes.

We might be talking about different ideas here, a lot of modern compilers like clang will generate assembly objects as a build step then send them to be assembled

So Assembly is definitely not always present in conversion stages between some high level language and machine code. Assembly is just another programming language sort to say but with perk for being able to stay consistent across platforms and architectures?

I'm speaking of the most general way of how programming for a microprocessor works in accordance of what the OP was requesting. It's why I suggested he buy an 8085 microprocessor trainer board to learn assembly on that. I had to correct another user that was claiming that assembly was machine language, which it isn't. What you're describing is a very valid thing that can happen. I was trying to explain to another person how things work on a basic level.

If you want to do cool graphics stuff I think there's no other entry-level options than to do your stuff in DOS mode and modify the screen memory directly in mode 320x200. Also, learning C64 assembly is also advisable, it's superfun and simple and not many directives. Pic related, you will learn about interrupts and other principles that still apply.