Update
This commit is contained in:
parent
ff2b27ae85
commit
92a7870ce6
6 changed files with 22 additions and 8 deletions
|
@ -4,6 +4,8 @@ Assembly (also ASM) is, for any given hardware computing platform ([ISA](isa.md)
|
|||
|
||||
**Assembly is NOT a single language**, it differs for every architecture, i.e. every model of CPU has potentially different architecture, understands a different machine code and hence has a different assembly (though there are some standardized families of assembly like x86 that work on wide range of CPUs); therefore **assembly is not [portable](portability.md)** (i.e. the program won't generally work on a different type of CPU or under a different [OS](os.md))! And even the same kind of assembly language may have several different [syntax](syntax.md) formats which may differ in comment style, order of writing arguments and even instruction abbreviations (e.g. x86 can be written in [Intel](intel.md) and [AT&T](at_and_t.md) syntax). For the reason of non-portability (and also for the fact that "assembly is hard") you shouldn't write your programs directly in assembly but rather in a bit higher level language such as [C](c.md) (which can be compiled to any CPU's assembly). However you should know at least the very basics of programming in assembly as a good programmer will come in contact with it sometimes, for example during hardcore [optimization](optimization.md) (many languages offer an option to embed inline assembly in specific places), debugging, reverse engineering, when writing a C compiler for a completely new platform or even when designing one's own new platform. **You should write at least one program in assembly** -- it gives you a great insight into how a computer actually works and you'll get a better idea of how your high level programs translate to machine code (which may help you write better [optimized](optimization.md) code) and WHY your high level language looks the way it does.
|
||||
|
||||
**OK, but why doesn't anyone make a portable assembly?** Well, people do, they just usually call it a [bytecode](bytecode.md) -- take a look at that. [C](c.md) is portable and low level, so it is often called a "portable assembly".
|
||||
|
||||
The most common assembly languages you'll encounter nowadays are **[x86](x86.md)** (used by most desktop [CPUs](cpu.md)) and **[ARM](arm.md)** (used by most mobile CPUs) -- both are used by [proprietary](proprietary.md) hardware and though an assembly language itself cannot (as of yet) be [copyrighted](copyright.md), the associated architectures may be "protected" (restricted) e.g. by [patents](patent.md). **[RISC-V](risc_v.md)** on the other hand is an "[open](open.md)" alternative, though not yet so wide spread. Other assembly languages include e.g. [AVR](avr.md) (8bit CPUs used e.g. by some [Arduinos](arduino.md)) and [PowerPC](ppc.md).
|
||||
|
||||
To be precise, a typical assembly language is actually more than a set of nicknames for machine code instructions, it may offer helpers such as [macros](macro.md) (something aking the C preprocessor), pseudoinstructions (commands that look like instructions but actually translate to e.g. multiple instructions), [comments](comment.md), directives, named labels for jumps (as writing literal jump addresses would be extremely tedious) etc.
|
||||
|
@ -25,11 +27,12 @@ There are also no complex [data types](data_type.md), assembly only works with n
|
|||
Instructions are typically written as three-letter abbreviations and follow some unwritten naming conventions so that different assembly languages at least look similar. Common instructions found in most assembly languages are for example:
|
||||
|
||||
- **MOV** (move): move a number between registers and/or main memory (RAM).
|
||||
- **JMP** (jump): unconditional jump to far away instruction.
|
||||
- **BEQ** (branch if equal): jump if result of previous comparison was equality.
|
||||
- **JMP** (jump, also e.g. BRA for branch): unconditional jump to far away instruction.
|
||||
- **JEQ** (jump if equal, also BEQ etc.): jump if result of previous comparison was equality.
|
||||
- **ADD** (add): add two numbers.
|
||||
- **NOP** (no operation): do nothing (used e.g. for delays or as placeholders).
|
||||
- **CMP** (compare): compare two numbers and set relevant flags (typically for a subsequent conditional jump).
|
||||
- ...
|
||||
|
||||
## How To
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue